PATCH: -multiwindow with root window hidden...

Early Ehlinger
Tue Apr 29 20:45:00 GMT 2003

Alright!  I'm having good results with my attempt to hide the root window
when running in
-multiwindow mode.  I've got it to where when I use the startxwin batch file
that gets set up during the cygwin install, XWin.exe adds a tray icon and
hides its root window.  The batch file then launches an xterm and it shows
up and works fine.  I can then launch more xterms, ssl sessions, redirect
galeon from my linux box, etc.

The patch needs a few tweaks before I will feel comfortable releasing it:

1. Right now simply clicking on the icon closes it.  This was more a matter
of laziness than anything else.  It takes a half a second to put the
WM_CLOSE post and a *lot* longer to generate the menus and whatnot.

2. It currently hides the root window indiscriminately. That is, it assumes
-multiwindow is on the command line, creates the tray icon and hides the
root window without checking that assumption at all.  This was more due to
my lack of familiarity with the code.  I didn't quite know what variables to
look for and frankly didn't care since I'm only planning on running with
the -multiwindow switch anyway ;)  If somebody wants to tackle this, my
approach would be to add a new command line switch, say -trayicon, so that
you would launch XWin.exe with:

  XWin.exe -trayicon -multiwindow -nowinkill -clipboard

Except for these two caveats, I'm quite happy with the new behavior.  I'd
still like to see different icons for each X Window, but that is much less
important to me than getting rid of that annoying root window, so I won't
tackle that one for a *very* long time, if ever.

I won't be able to work on this again for a while - I've got it where I need
it for my purposes and my time is *very* limited.  So, if anybody wants to
try it out with the knowledge that these two problems exist, or wants to
take over development to remove these problems, here are the changes I made:

in x-devel/build/std/programs/Xserver/hw/xwin/winwndproc.c:

add the following just after the other #includes:

#include <shellapi.h>

void init_notify_icon( HWND hwnd )
  nid.cbSize = sizeof( nid );
  nid.hWnd = hwnd;
  nid.uID = 0;
  nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP /* | NIF_INFO */;
  nid.uCallbackMessage = WM_APP;
  nid.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_XWIN));

  strncpy(  nid.szTip , "Cygwin/XFree86 Server" , sizeof( nid.szTip ) );

  if ( ! Shell_NotifyIcon( NIM_ADD , &nid ) )
    ErrorF( "Shell_NotifyIcon Failed, dammit" );

LRESULT handle_icon_message( HWND hwnd , UINT message , WPARAM wParam ,
LPARAM lParam )
  switch( lParam )
    case WM_LBUTTONUP:
      PostMessage( hwnd , WM_CLOSE , 0 , 0 );
  return 0;

in winWindowProc( ... ), add this to the switch(message) :

case WM_APP:
  return handle_icon_message( hwnd , message , wParam , lParam );

And add this to the case WM_CREATE in the switch(message), just above the
return 0 :

init_notify_icon( hwnd );

-- Early Ehlinger CEO, ResPower Inc - Toll-Free : 866-737-7697
-- -- 500+ GHz Supercomputer Starting At USD$0.50/GHz*Hour

More information about the Cygwin-xfree mailing list