Hello,

Is the problem of events in systray clearly stated in my previous mail ?

I restate it if necessary.

Thanks in advance,

Cheers,

Gilles

Le 10/17/2004 04:13 PM, Gilles Foucault a écrit :

Hello,

I began to embed peksystray code inside the FvwmTaskBar
I have one problem for now : the systray window does not receive events when it is embeded inside FvwmTaskBar window.

In the file modules/FvwmTaskBar/Goodies.c, if I change
dockWindow = XCreateSimpleWindow (dpy, win, 0, 0, w, h, border_width, 0, 0);
to
dockWindow = XCreateSimpleWindow (dpy, Root, 0, 0, w, h, border_width, 0, 0); The systray is not the child of win (ie. FvwmTaskBar main window) anymore, and the dockWindow receives events as expected (it display/hide client on a left click, display the contextual menu of client on right-click).

Do you have any idea of what is wrong ?

Here follows the patch, (modifications are inside the files modules/FvwmTaskBar/Goodies.c modules/FvwmTaskBar/Goodies.h and modules/FvwmTaskBar/FvwmTaskBar.c).

Regards,

Gilles

diff -Nur /home/gilles/Program Files/fvwm/fvwm-2.5.12-orig/modules/FvwmTaskBar/FvwmTaskBar.1 FvwmTaskBar/FvwmTaskBar.1 --- /home/gilles/Program Files/fvwm/fvwm-2.5.12-orig/modules/FvwmTaskBar/FvwmTaskBar.1 2004-10-05 20:50:19.000000000 -0400
+++ FvwmTaskBar/FvwmTaskBar.1    1969-12-31 19:00:00.000000000 -0500
@@ -1,448 +0,0 @@
-.\" t
-.\" @(#)fvwm-2.5.12 6 October 2004
-.TH FvwmTaskBar 1 "6 October 2004 (2.5.12)" FVWM "FVWM Modules"
-.UC
-.SH NAME
-FvwmTaskBar \- the FVWM taskbar module
-.SH SYNOPSIS
-\fBFvwmTaskBar\fP [\fIname\fP]
-
-FvwmTaskBar is spawned by FVWM, so no command line invocation will work.
-
-.SH DESCRIPTION
-The FvwmTaskBar module provides a taskbar made up of buttons arranged by
-rows, each corresponding to a window that FVWM is managing.
-Clicking on first button gives focus to the corresponding top level window; -clicking on the middle button will hide a top level window; third mouse button
-is reserved for a future extension (context menu).
-Like the other modules, FvwmTaskBar only works when fvwm is used as the
-window manager.
-
-When started, the taskbar shows up as a single row of buttons filling the -full width of the screen, but during the work can be resized to accommodate
-up to 8 rows. In addition, if the AutoStick option is used, the taskbar
-will auto position itself at the top or bottom of the screen, and can be
-dragged from one position to another with a normal move operation.
-
-The first button of the taskbar, labelled "Start" sends a "Popup
-StartMenu" command to the FVWM, which can be used to pop-up a
-general-purpose menu when the button is pressed.
-
-The FvwmTaskBar also displays at the right side a window showing the
-current time and the built-in incoming mail indicator.
-
-.SH COPYRIGHTS
-The FvwmTaskBar module is derived from Mike Finger's FvwmWinList.
-
-Copyright 1994, Mike Finger. The author makes no guarantees or warranties of -any kind about the use of this module. Use this modules at your own risk. -You may freely use this module or any portion of it for any purpose as long
-as the copyright is kept intact.
-
-.SH INITIALIZATION
-During initialization, \fIFvwmTaskBar\fP gets configuration information
-from FVWM to find the options that pertain to it.
-These options are discussed in a later section.
-
-.SH INVOCATION
-FvwmTaskBar can be invoked by fvwm during initialization by inserting the
-line 'Module FvwmTaskBar' in the .fvwm2rc file.
-
-FvwmTaskBar must reside in a directory that is listed in the ModulePath
-option of FVWM for it to be executed by FVWM.
-
-.SH CONFIGURATION OPTIONS
-The following options can be placed in the .fvwm2rc file
-
-.IP "*FvwmTaskBar: Geometry \fI{+-}<X>{+-}<Y>\fP"
-Specifies the location and gravity of the FvwmTaskBar window.
-Currently, this option is scanned as a normal X geometry string.
-You can include the width and the height in addition to the "x" and
-"y" offset.  However, only the "x" and "y" offset are used.
-To avoid possible future compatibility problems, only code the "x" and
-"y" offset.
-
-The actual width of the taskbar is always the full width of the screen
-and the height is controlled by the *FvwmTaskBar: Rows option.
-
-If the AutoStick option
-is specified, the taskbar automatically "sticks" to the top or
-the bottom of the screen, whichever is closest to the geometry specification.
-
-To position the taskbar at the bottom of the screen, use a geometry of
-"+0-0".
-
-.IP  "*FvwmTaskBar: Rows r"
-Specifies the initial number in rows of the FvwmTaskBar window. Default
-is 1 and the maximum is 8.
-
-.IP "*FvwmTaskBar: Font \fIfont\fP"
-Specifies the default font to be used for labeling the buttons, when they
-are not depressed. If not specified, fixed font is assumed.
-
-.IP "*FvwmTaskBar: SelFont \fIfont\fP"
-Specifies the font to be used for the depressed buttons. Note that the
-Start button will use always this font even if is not pressed. If this
-option is not specified, the default font is used instead.
-
-.IP "*FvwmTaskBar: StatusFont \fIfont\fP"
-Specifies the font to be used for the clock and tip windows. If this
-option is not specified, fixed font is used.
-
-.IP "*FvwmTaskBar: Fore \fIcolor\fP"
-Specifies the color to use for the button names.
-
-.IP "*FvwmTaskBar: Back \fIcolor\fP"
-Specifies the background color for the bar and buttons.
-
-.IP "*FvwmTaskBar: Colorset \fIcolorset\fP"
-Tells the module to use colorset \fIcolorset\fP for the window
-background and the foreground color of the buttons.  Please refer
-to the man page of the FvwmTheme module for details about colorsets.
-
-.IP "*FvwmTaskBar: IconFore \fIcolor\fP"
-Specifies the color to use for the button names which represent iconified
-windows.
-
-.IP "*FvwmTaskBar: IconBack \fIcolor\fP"
-Specifies the color to use for the buttons which represent iconified windows.
-
-.IP "*FvwmTaskBar: IconColorset \fIcolorset\fP"
-Tells the module to use colorset \fIcolorset\fP for the
-buttons of iconified windows.  Please refer to the man page of
-the FvwmTheme module for details about colorsets.
-
-.IP "*FvwmTaskBar: FocusFore \fIcolor\fP"
-Specifies the color to use for the button which represents the window
-with the focus. If not specified the color specified by *FvwmTaskBar: Fore or
-*FvwmTaskBar: Colorset is used.
-
-.IP "*FvwmTaskBar: FocusBack \fIcolor\fP"
-Specifies the color to use for the button which represents the window
-with the focus. If not specified the color specified by *FvwmTaskBar: Back or -*FvwmTaskBar: Colorset is used. Note that the button which represents the window
-with the focus is also highlighted.  See "*FvwmTaskBar: NoBrightFocus".
-
-.IP "*FvwmTaskBar: FocusColorset \fIcolorset\fP"
-Tells the module to use colorset \fIcolorset\fP for the button
-which represents the window with the focus. Please refer to the man page of
-the FvwmTheme module for details about colorsets.
-
-.IP "*FvwmTaskBar: NoBrightFocus"
-By default the button which represents the window with the focus is
-highlighted. This option disables this feature.  \fINote:\fP you will
-want this option if you use a pixmap (via FvwmTheme) for the background.
-
-.IP "*FvwmTaskBar: TipsFore \fIcolor\fP"
-Specifies the color to be used for the text in the tips windows.
-
-.IP "*FvwmTaskBar: TipsBack \fIcolor\fP"
-Specifies the background color for the tips windows.
-
-.IP "*FvwmTaskBar: TipsColorset \fIcolorset\fP"
-Tells the module to use colorset \fIcolorset\fP for the tips windows.
-Please refer to the man page of the FvwmTheme module for details about
-colorsets.
-
-.IP "*FvwmTaskBar: AutoStick"
-This option causes the taskbar to "stick" either to the top or bottom
-of the screen, whichever is closest to the initial window placement. Any
-further move operation is also subject to that behavior.
-
-.IP "*FvwmTaskBar: AutoFocus"
-This option causes the taskbar to raise a window if the cursor stays on a
-button in taskbar and its tip is open.
-
-.IP "*FvwmTaskBar: AutoHide [\fIpixels\fP]"
-This option causes the taskbar to disappear leaving a narrow strip at the
-bottom of the screen, and reappear only when the mouse is moved to that
-strip.  This option automatically enables AutoStick.  The optional
-\fIpixels\fP parameter specifies thickness of a strip (3 pixels by default).
-
-.IP "*FvwmTaskBar: UseSkipList"
-Tells FvwmTaskBar to not show the windows that are listed on a WindowListSkip
-line in the configuration file.
-
-.IP "*FvwmTaskBar: DeskOnly"
-Tells FvwmTaskBar to show only windows that are on the current desktop.
-When desktops are switched, the list of windows changes accordingly.
-
-.IP "*FvwmTaskBar: PageOnly"
-Tells FvwmTaskBar to show only windows that are on the same page
-as the task bar.
-When a window enters or leaves the page, the list of windows changes
-accordingly.
-
-.IP "*FvwmTaskBar: ScreenOnly"
-Tells FvwmTaskBar to show only windows that are only on the same
-Xinerama screen as the task bar.  When a window enters or leaves the
-screen, the list of windows changes accordingly.
-
-.IP "*FvwmTaskBar: UseIconNames"
-Tells FvwmTaskBar to use the icon name of the window instead of the full
-window name.  This is useful to keep the width of the buttons small.
-
-.IP "*FvwmTaskBar: ShowTransients"
-Tells FvwmTaskBar to show the application transient windows also. By default
-they are not shown.
-
-.IP "*FvwmTaskBar: Action \fIaction response\fP"
-Tells FvwmTaskBar to do \fIresponse\fP when \fIaction\fP is done.  The
-currently supported \fIaction\fPs are: Click1, Click2, Click3 and so on.
-By default the module supports 5 mouse buttons, but it can be compiled
-to support more.  The currently
-supported \fIresponse\fPs are any fvwm built-in commands, including modules -and functions. Warning: Use of the former syntax that allowed to use comma -separated lists of commands is strongly discouraged due to synchronization -problems with fvwm. Please use complex fvwm functions instead (defined with
-the AddToFunc command of fvwm).
-
-In the \fIresponse\fP part, you can use a number of predefined
-variables: \fI$left\fP, \fI$right\fP, \fI$top\fP and \fI$bottom\fP
-are substituted by the left, right, top and bottom coordinates of
-the button pressed. \fI$-left\fP, \fI$-right\fP, \fI$-top\fP and
-\fI$-bottom\fP are substituted likewise, but the coordinates are
-calculated from the bottom or the right edge of the screen instead
-(for a button that is 5 pixels away from the right screen border,
-$-right will be 5). \fI$width\fP and \fI$height\fP are replaced by
-the width or height of the button.  All this is done regardless of
-any quoting characters. To get a literal '$' use the string '$$'.
-
-.IP "*FvwmTaskBar: Button Title \fItitle\fP, Icon \fIicon\fP, Action \fIaction\fP"
-Tells FvwmTaskBar to put a shortcut minibutton in the taskbar that does
-\fIaction\fP when clicked. The icon can have a caption denoted by \fItitle\fP, -an icon denoted by \fIicon\fP, or a combination of the two. The icons will -appear to the immediate right of the start button, and will appear in the
-order that they are declared in the .fvwm2rc file.
-
-To invoke different commands for different mouse clicks, use this syntax:
-
-.nf
-.sp
-*FvwmTaskBar: Button Title \fItitle\fP, Icon \fIicon\fP, \\
- Action (Mouse 1) \fIaction1\fP, Action (Mouse 2) \fIaction2\fP
-.sp
-.fi
-
-.IP "*FvwmTaskBar: ButtonWidth \fIwidth\fP"
-Indicates the maximum width that window buttons should reach.
-(the minimum is hard coded at 32).
-
-.IP "*FvwmTaskBar: WindowButtonsLeftMargin \fImargin\fP"
-Specifies the space (in pixels) between the left side of the left-most window
-button and the right side of the start button or right-most shortcut
-minibutton.  If this option is not specified, the default margin is 4.
-
-.IP "*FvwmTaskBar: WindowButtonsRightMargin \fImargin\fP"
-Specifies the space (in pixels) between the right side of the right-most
-window button and the left side of the clock and tip window. If this option
-is not specified, the default margin is 2.
-
-.IP "*FvwmTaskBar: StartButtonRightMargin \fImargin\fP"
-Specifies the space (in pixels) between the right side of the start button -and the left side of the left-most shortcut minibutton. If this option is
-not specified, the default margin is 0.
-
-.IP "*FvwmTaskBar: 3DFvwm"
-By default the buttons use a special (asymmetric) 3D look. This option enables
-a more classical 3D look (Ie., a la fvwm).
-
-.IP "*FvwmTaskBar: HighlightFocus"
-If the mouse pointer is over the taskbar, the window under the current
-button is active. This behavior is like the TVTWM Icon Manager or
-FvwmIconMan. \fINote:\fP If you use this option combined with FollowMouse
-focus style, you'll want the taskbar to be ClickToFocus.
-
-.IP "*FvwmTaskBar: ShowTips"
-Enables the tips windows (by default disabled).
-
-.IP "*FvwmTaskBar: NoIconAction \fIaction\fP"
-Tells FvwmTaskBar to do \fIaction\fP is when a NoIcon style window is
-iconified or de-iconified. Relevant coordinates are appended to \fIaction\fP so
-that the icon can be traced to an FvwmTaskBar button. An example action
-is "*FvwmTaskBar: NoIconAction SendToModule FvwmAnimate animate". A blank or
-null action turns this feature off.
-
-.SH ""
-
-The following options deal more specifically with the status indicators
-displayed at the right of the taskbar.
-
-.IP "*FvwmTaskBar: ClockFormat \fIformat-string\fP"
-This option specifies the time format for the digital clock.
-It is a \fIstrftime(3)\fP compatible format string.
-By default it is "%R". There is a 24 character limit for string
-expansion. The string depends of locale settings.
-
-.IP "*FvwmTaskBar: DateFormat \fIformat-string\fP"
-This option specifies the date and/or time format for clock tip.
-It is a \fIstrftime(3)\fP compatible format string.
-By default it is "%A, %B %d, %Y". There is 40 characters limit for
-string expansion. The string depends of locale settings now.
-
-.IP "*FvwmTaskBar: UpdateInterval \fIseconds\fP"
-Specifies how often the clock display should be refreshed, so that times of
-the form HH:MM:SS can be used. By default 60 seconds.
-
-.IP "*FvwmTaskBar: BellVolume \fIvolume\fP"
-This sets the volume of the bell when mail is detected.
-It is a value between 0 (no bell) and 100 (maximum volume).
-By default it is set to 20.
-
-.IP "*FvwmTaskBar: MailBox \fIpath\fP"
-This option instructs the module to look for mail at the specified place
-It is a full pathname to the user's mailbox.
-By default it is \fI/var/spool/mail/$USER_LOGIN\fP.
-A value of 'None' instructs the module not to have a mail indicator.
-
-.IP "*FvwmTaskBar: MailCommand \fIcommand\fP"
-Specifies a \fIfvwm\fP command to be executed when double-clicking
-on the mail icon.
-
-.IP "*FvwmTaskBar: MailCheck \fIseconds\fP"
-Specifies the interval between checks for new mail. The default is
-ten seconds. A value of zero or less switches mail checking off.
-
-Note, this value is only relable when greater than the \fIUpdateInterval\fP
-value. The mail check is done either on any redraw (like a focus change)
-or every nearest factor of the \fIUpdateInterval\fP value.
-
-.IP "*FvwmTaskBar: IgnoreOldMail"
-If set, draw no bitmap if there is no new mail.
-
-.SH ""
-The following options deal with the Start button at the left of the taskbar:
-
-.IP "*FvwmTaskBar: StartCommand \fIcommand\fP"
-This option specifies a command to run when the start button is
-pressed.  Some strings are replaced in the command when it is
-executed like for the other buttons.  See
-.B Action
-for details.  If both,
-.BR StartCommand " and " StartMenu
-have been defined, the command is executed first and the menu is
-opened afterwards.  The
-.B StartCommand
-can be used to exactly place a menu atop a button.
-
-.nf
-.sp
-*FvwmTaskBar: StartCommand Popup StartMenu rectangle \\
-    $widthx$height+$left+$top 0 -100m
-.sp
-.fi
-
-To invoke different commands for different mouse clicks, use this syntax:
-
-.nf
-.sp
-*FvwmTaskBar: StartCommand (Mouse 1) Popup Mouse1Menu
-*FvwmTaskBar: StartCommand (Mouse 3) Popup Mouse3Menu
-.sp
-.fi
-
-.IP "*FvwmTaskBar: StartName \fIstring\fP"
-This option specifies the string displayed in the Start button.
-('Start' by default).
-
-.IP "*FvwmTaskBar: StartMenu \fIstring\fP"
-This option specifies the pop up menu to invoke when the start button is
-pressed. ('StartMenu' by default). The module send a 'Popup StartMenu'
-command to the fvwm window manager.
-
-To invoke different menus for different mouse clicks, use this syntax:
-
-.nf
-.sp
-*FvwmTaskBar: StartMenu (Mouse 1) Mouse1Menu
-*FvwmTaskBar: StartMenu (Mouse 3) Mouse3Menu
-.sp
-.fi
-
-.IP "*FvwmTaskBar: StartIcon \fIicon-name\fP"
-This option specifies the name of the icon to display at the left of the Start
-button.
-
-.IP "*FvwmTaskBar: NoDefaultStartButton"
-This option removes the defaults start button if no start button configuration -options are given. It is useful to remove the start button. Note that this is
-the default if you use the Button configuration option.
-
-.SH SAMPLE CONFIGURATION
-The following are excepts from a .fvwm2rc file which describe FvwmTaskBar
-initialization commands:
-
-.nf
-.sp
-#
-# Start the taskbar on fvwm startup and restart
-#
-
-AddToFunc "StartFunction" "I" Module FvwmTaskBar
-
-#
-# For Click 1 action
-#
-
-AddToFunc DeiconifyRaiseAndFocus
-+ I Iconify off
-+ I Raise
-+ I Focus
-
-#
-# Set the style for the taskbar window, keep always on top of another
-# windows
-#
-
-Style "FvwmTaskBar" NoTitle,BorderWidth 4, HandleWidth 4,Sticky,\\
-StaysOnTop,WindowListSkip,CirculateSkip
-
-#------------------------------------ taskbar
-*FvwmTaskBar: Back #c3c3c3
-*FvwmTaskBar: Fore black
-*FvwmTaskBar: TipsBack bisque
-*FvwmTaskBar: TipsFore black
-*FvwmTaskBar: Geometry +0-0
-*FvwmTaskBar: Font -adobe-helvetica-medium-r-*-*-14-*-*-*-*-*-*-*
-*FvwmTaskBar: SelFont -adobe-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*
-*FvwmTaskBar: StatusFont fixed
-
-*FvwmTaskBar: Action Click1 DeiconifyRaiseAndFocus
-*FvwmTaskBar: Action Click2 Iconify On
-*FvwmTaskBar: Action Click3 Lower
-
-*FvwmTaskBar: UseSkipList
-*FvwmTaskBar: UseIconNames
-*FvwmTaskBar: AutoStick
-*FvwmTaskBar: ShowTips
-*FvwmTaskBar: NoIconAction SendToModule FvwmAnimate animate
-
-*FvwmTaskBar: ButtonWidth 180
-*FvwmTaskBar: BellVolume 20
-*FvwmTaskBar: MailBox /var/spool/mail/
-*FvwmTaskBar: MailCommand Exec xterm -e mail
-*FvwmTaskBar: ClockFormat %I:%M %p
-
-*FvwmTaskBar: StartName Start
-*FvwmTaskBar: StartMenu StartMenu
-*FvwmTaskBar: StartIcon mini-exp.xpm
-
-*FvwmTaskBar: Button Title Mozilla, Action exec exec /usr/local/mozilla/mozilla
-*FvwmTaskBar: Button Icon mini.term.xpm, Action exec exec xterm
-*FvwmTaskBar: Button Title Freeamp, Icon mini.cd.xpm, Action exec exec freeamp
-
-.sp
-.fi
-
-.SH BUGS
-There is a bug report that FvwmTaskBar doesn't work well with
-auto hide turned on.
-
-.SH AUTHOR
-.IP "\fIDavid Barth\fP <[EMAIL PROTECTED]>"
-
-.SH ACKNOWLEDGMENTS
-These people have contributed to \fBFvwmTaskBar\fP:
-
-.IP "\fIDanny Dulai\fP <[EMAIL PROTECTED]>"
-.IP "\fIfvwm workers\fP <fvwm-workers@fvwm.org>"
diff -Nur /home/gilles/Program Files/fvwm/fvwm-2.5.12-orig/modules/FvwmTaskBar/FvwmTaskBar.c FvwmTaskBar/FvwmTaskBar.c --- /home/gilles/Program Files/fvwm/fvwm-2.5.12-orig/modules/FvwmTaskBar/FvwmTaskBar.c 2004-09-01 10:38:18.000000000 -0400
+++ FvwmTaskBar/FvwmTaskBar.c    2004-10-17 15:50:00.936492344 -0400
@@ -1525,6 +1525,10 @@
    *redraw = -1;
    *expose_redraw = False;

+    /** Gilles Foucault Systray */
+    systray_eventLoop(*evp);
+    /** End */
+
    switch(evp->type)
    {
    case ButtonRelease:
@@ -2291,7 +2295,7 @@

XSelectInput(dpy,win,(ExposureMask | KeyPressMask | PointerMotionMask |
             EnterWindowMask | LeaveWindowMask |
-             StructureNotifyMask));
+             StructureNotifyMask | SubstructureNotifyMask ));

   InitGoodies();
   atexit(ShutMeDown);
diff -Nur /home/gilles/Program Files/fvwm/fvwm-2.5.12-orig/modules/FvwmTaskBar/Goodies.c FvwmTaskBar/Goodies.c --- /home/gilles/Program Files/fvwm/fvwm-2.5.12-orig/modules/FvwmTaskBar/Goodies.c 2004-08-30 04:11:25.000000000 -0400
+++ FvwmTaskBar/Goodies.c    2004-10-17 15:56:17.047314808 -0400
@@ -88,6 +88,29 @@

void cool_get_inboxstatus(void);

+/** SysTray : Gilles Foucault */
+#define SYSTEM_TRAY_REQUEST_DOCK    0
+#define SYSTEM_TRAY_BEGIN_MESSAGE   1
+#define SYSTEM_TRAY_CANCEL_MESSAGE  2
+
+/* Flags for _XEMBED_INFO */
+#define XEMBED_MAPPED                   (1 << 0)
+
+#define DEBUG(x) fprintf(stdout,"%s\n", x)
+
+#define MAX_ICONS 4 /* Please don't change this otherwise it'll break */
+Atom selection_atom, opcode_atom, data_atom;
+
+int is_full = 0;        /* Can we accept more icons ? */
+int no_tray_icon = 0;        /* No, of embedded icons */
+Window tray_icons[MAX_ICONS];
+
+int icon_size = 16;
+int border_width = 0;
+
+Window dockWindow;
+/** End Systray*/
+
#define gray_width  8
#define gray_height 8
extern unsigned char gray_bits[];
@@ -149,6 +172,10 @@
  {
      goodies_width += 0;
  }
+ +  /** Systray init */
+  systray_init(0,NULL);
+  /* End systray */

}

@@ -453,6 +480,9 @@
        if (newmail)
            XBell(dpy, BellVolume);
    }
+    /** Systray draw */
+
+    /* End systray */

    if (!mailcleared && (unreadmail || newmail))
    {
@@ -654,7 +684,7 @@
  winattr.override_redirect = True;
  winattr.save_under = True;
  winattr.event_mask = ExposureMask;
- Tip.win = XCreateWindow(dpy, Root, x, y, w+4, h+4, 0, Pdepth, InputOutput, + Tip.win = XCreateWindow(dpy, win, x, y, w+4, h+4, 0, Pdepth, InputOutput,
              Pvisual, winattrmask, &winattr);

  gcmask = GCForeground | GCBackground | GCGraphicsExposures;
@@ -898,3 +928,268 @@
  lastclick = event.xbutton.time;
  mailcleared = 1;
}
+
+/** Systray */
+void systray_add_tray_icon (Window win_icon)
+{
+  XEvent xevent;
+  Window tmp;
+ fprintf (stderr, "%s: %i, no_tray_icon=%d\n", __FUNCTION__, win_icon, no_tray_icon);
+
+  tmp = dockWindow;
+  tray_icons[no_tray_icon] = win_icon;
+  XReparentWindow (dpy, win_icon, tmp, no_tray_icon * icon_size,
+               border_width);
+
+  XMapRaised (dpy, win_icon);
+
+ /** See http://freedesktop.org/Standards/systemtray-spec/systemtray-spec-0.1.html#messages
+   * for the explanation of the freedesktop.org systray
+   * implemented bellow
+   */
+  memset(&xevent, 0, sizeof(xevent));
+  xevent.xclient.window = win_icon;
+  xevent.xclient.type = ClientMessage;
+  xevent.xclient.message_type = XInternAtom (dpy, "_XEMBED", False);
+  xevent.xclient.format = 32;
+  xevent.xclient.data.l[0] = CurrentTime;
+  xevent.xclient.data.l[1] = SYSTEM_TRAY_REQUEST_DOCK;
+  xevent.xclient.data.l[2] = 0;
+  xevent.xclient.data.l[3] = tmp;
+  xevent.xclient.data.l[4] = 0;
+  FSendEvent (dpy, Root, False, NoEventMask, &xevent);
+
+  tray_icons[no_tray_icon] = win_icon;
+
+  no_tray_icon++;
+}
+
+void
+systray_rm_tray_icon (Window win_icon)
+{
+  int i;
+
+ fprintf (stderr, "%s: %i, no_tray_icon = %d\n", __FUNCTION__, win_icon, no_tray_icon);
+
+  if (no_tray_icon == 0)
+    {
+      return;
+    }
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      if (tray_icons[i] == win_icon)
+    {
+      tray_icons[i] = tray_icons[no_tray_icon];
+      tray_icons[no_tray_icon] = 0;
+      no_tray_icon--;
+      break;
+    }
+    }
+}
+
+void systray_handle_event (XEvent ev)
+{
+  XClientMessageEvent *event = (XClientMessageEvent *) & ev;
+  XWindowAttributes tray_icon_attr;
+
+  fprintf (stderr, "%s\n", __FUNCTION__);
+
+  switch (event->data.l[1])
+    {
+    case SYSTEM_TRAY_REQUEST_DOCK:
+      {
+    if (no_tray_icon == MAX_ICONS)
+      {
+        fprintf (stderr, "full\n");
+        return;
+      }
+
+    XGetWindowAttributes (dpy, event->data.l[2], &tray_icon_attr);
+    fprintf (stderr, "Width: %i\t Height:%i\tBorder: %i\n",
+         tray_icon_attr.width, tray_icon_attr.height,
+         tray_icon_attr.border_width);
+
+    XResizeWindow (dpy, event->data.l[2], icon_size, icon_size);
+
+    systray_add_tray_icon (event->data.l[2]);
+    return;
+      }
+    case SYSTEM_TRAY_BEGIN_MESSAGE:
+      {
+
+    return;
+      }
+    case SYSTEM_TRAY_CANCEL_MESSAGE:
+      {
+
+    return;
+      }
+    default:
+      break;
+    }
+}
+
+void
+systray_handle_message_data (XEvent ev)
+{
+  fprintf (stderr, "%s\n", __FUNCTION__);
+}
+
+void
+systray_eventLoop (XEvent ev)
+{
+      switch (ev.type)
+        {
+        case ReparentNotify:
+          {
+        XReparentEvent *xev = (XReparentEvent *) & ev;
+        fprintf (stderr, "ReparentNotify\n");
+/* Handle this */
+        if (xev->parent == dockWindow)
+          {
+
+          }
+        else
+          {
+          }
+        break;
+          }
+        case UnmapNotify:
+          {
+        XUnmapEvent *xev = (XUnmapEvent *) & ev;
+        fprintf (stderr, "UnmapNotify\n");
+        if (xev->window != dockWindow)
+          {
+            systray_rm_tray_icon (xev->window);
+          }
+        break;
+          }
+        case DestroyNotify:
+          {
+        XDestroyWindowEvent *xev = (XDestroyWindowEvent *) & ev;
+        fprintf (stderr, "DestroyNotify\n");
+        if (xev->window == dockWindow)
+          {
+            return;
+          }
+        else
+          {
+            systray_rm_tray_icon (xev->window);
+            break;
+          }
+          }
+        case ClientMessage:
+          {
+          fprintf (stderr, "ClientMessage\n");
+        if (ev.xclient.message_type == opcode_atom)
+          {
+            systray_handle_event (ev);
+          }
+        else if (ev.xclient.message_type == data_atom)
+          {
+            systray_handle_message_data (ev);
+          }
+        break;
+          }
+        case SelectionClear:
+          {   +          fprintf (stderr, "SelectionClear\n");
+        if (XGetSelectionOwner (dpy, selection_atom) ==
+            dockWindow)
+          {
+            XSetSelectionOwner (dpy, selection_atom, None,
+                    CurrentTime);
+          }
+        return;
+          }
+        default:
+          break;
+        }
+}
+
+int
+systray_init (int argc, char *argv[])
+{
+  XClassHint *classHint;
+  XWMHints *hints;
+  int w, h;
+
+/*  win[0] = 0;
+  win[1] = 0;
+  win[2] = 0;
+  win[3] = 0;
+*/
+
+  h = icon_size;
+  w = 64;
+
+  if (border_width)
+    {
+      h += border_width;
+    }
+
+  dockWindow =    XCreateSimpleWindow (dpy, win, 0, 0,
+                 w, h, border_width, 0, 0);
+
+  if ((classHint = XAllocClassHint ()) == NULL)
+    {
+      printf ("Failed to allocate class hint\n");
+      return;
+    }
+  classHint->res_class = PACKAGE;
+  classHint->res_name = PACKAGE;
+  XSetClassHint (dpy, dockWindow, classHint);
+  XFree (classHint);
+
+  if ((hints = XAllocWMHints ()) == NULL)
+    {
+      printf ("Failed to allocate hints\n");
+      return;
+    }
+  hints->flags = StateHint | WindowGroupHint | IconWindowHint;
+  hints->initial_state = WithdrawnState;
+  hints->window_group = dockWindow;
+
+  XSetWMHints (dpy, dockWindow, hints);
+  XFree (hints);
+
+/* Set the background */
+  XSetWindowBackgroundPixmap (dpy, dockWindow, ParentRelative);
+
+  selection_atom = XInternAtom (dpy, "_NET_SYSTEM_TRAY_S0", False);
+  XSetSelectionOwner (dpy, selection_atom, dockWindow, CurrentTime);
+ +  if (XGetSelectionOwner (dpy, selection_atom) == dockWindow)
+    {
+      XClientMessageEvent xev;
+      xev.type = ClientMessage;
+      xev.window = Root;
+      xev.message_type = XInternAtom (dpy, "MANAGER", False);
+
+      xev.format = 32;
+      xev.data.l[0] = CurrentTime;
+      xev.data.l[1] = selection_atom;
+      xev.data.l[2] = dockWindow;
+      xev.data.l[3] = 0;    /* manager specific data */
+      xev.data.l[4] = 0;    /* manager specific data */
+
+ FSendEvent (dpy, Root, False, StructureNotifyMask, (XEvent *) & xev);
+
+      opcode_atom = XInternAtom (dpy, "_NET_SYSTEM_TRAY_OPCODE", False);
+
+ data_atom = XInternAtom (dpy,"_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
+
+    }
+  else
+      {
+      fprintf(stderr, "Systray : XGetSelectionOwner\n");
+      }
+
+  /*  XSelectInput (dpy, dockWindow, ExposureMask);
+      XSelectInput (dpy, dockWindow, ButtonPressMask);*/
+  XSelectInput (dpy, dockWindow, SubstructureNotifyMask);
+  XMapRaised (dpy, dockWindow);
+  XFlush (dpy);
+
+  return 0;
+}
diff -Nur /home/gilles/Program Files/fvwm/fvwm-2.5.12-orig/modules/FvwmTaskBar/Goodies.h FvwmTaskBar/Goodies.h --- /home/gilles/Program Files/fvwm/fvwm-2.5.12-orig/modules/FvwmTaskBar/Goodies.h 2004-07-13 05:39:37.000000000 -0400
+++ FvwmTaskBar/Goodies.h    2004-10-17 12:55:42.899355648 -0400
@@ -42,5 +42,13 @@
void HandleMouseClick(XEvent event);
void HandleMailClick(XEvent event);
Bool change_goody_colorset(int cset, Bool force);
+/** Gilles Foucault Systray */
+int systray_init (int argc, char *argv[]);
+void systray_eventLoop (XEvent ev);
+void systray_handle_message_data (XEvent ev);
+void systray_handle_event (XEvent ev);
+void systray_rm_tray_icon (Window win_icon);
+void systray_add_tray_icon (Window win_icon);
+/** End Systray */

#endif
diff -Nur /home/gilles/Program Files/fvwm/fvwm-2.5.12-orig/modules/FvwmTaskBar/Systray.c FvwmTaskBar/Systray.c --- /home/gilles/Program Files/fvwm/fvwm-2.5.12-orig/modules/FvwmTaskBar/Systray.c 1969-12-31 19:00:00.000000000 -0500
+++ FvwmTaskBar/Systray.c    2004-10-16 14:57:26.000000000 -0400
@@ -0,0 +1,30 @@
+
+void
+rm_tray_icon (Window win)
+{
+  int i;
+
+  fprintf (stderr, "%s: %i\n", __FUNCTION__, win);
+
+  if (no_tray_icon == 0)
+    {
+      return;
+    }
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      if (icon[i] == win)
+    {
+      if (multiple)
+        {
+          XDestroyWindow (display, dock[i]);
+        }
+      dock[i] = dock[no_tray_icon];
+      icon[i] = icon[no_tray_icon];
+      dock[no_tray_icon] = 0;
+      icon[no_tray_icon] = 0;
+      no_tray_icon--;
+      break;
+    }
+    }
+}
+

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [EMAIL PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [EMAIL PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

Reply via email to