Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: E.h iconify.c x.c Log Message: Systray fixes (avoid crashing certain clients on close). =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v retrieving revision 1.425 retrieving revision 1.426 diff -u -3 -r1.425 -r1.426 --- E.h 12 May 2005 16:53:46 -0000 1.425 +++ E.h 12 May 2005 19:02:12 -0000 1.426 @@ -2255,6 +2255,7 @@ int EServerIsGrabbed(void); void EFlush(void); void ESync(void); +Time EGetTimestamp(void); void ERegisterWindow(Window win); void EUnregisterWindow(Window win); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/iconify.c,v retrieving revision 1.144 retrieving revision 1.145 diff -u -3 -r1.144 -r1.145 --- iconify.c 12 May 2005 18:08:25 -0000 1.144 +++ iconify.c 12 May 2005 19:02:14 -0000 1.145 @@ -429,11 +429,11 @@ } } + EDestroyWindow(ib->win); + if (ib->objs) Efree(ib->objs); - EDestroyWindow(ib->win); - Efree(ib); if (!exiting) @@ -3014,6 +3014,8 @@ static Atom _NET_SYSTEM_TRAY_Sx = 0; static Atom _NET_SYSTEM_TRAY_OPCODE = 0; static Atom _NET_SYSTEM_TRAY_MESSAGE_DATA = 0; +static Window systray_sel_win = None; +static Time systray_sel_time = 0; static void SystrayEvent(XEvent * ev, void *prm); @@ -3184,6 +3186,7 @@ XUnmapWindow(disp, swin->win); XReparentWindow(disp, swin->win, VRoot.win, 0, 0); + ESync(); } Efree(swin); @@ -3280,27 +3283,46 @@ XInternAtom(disp, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False); /* Acquire selection */ - XSetSelectionOwner(disp, _NET_SYSTEM_TRAY_Sx, win, CurrentTime); - - if (XGetSelectionOwner(disp, _NET_SYSTEM_TRAY_Sx) != win) + if (systray_sel_win != None) { + DialogOK(_("Systray Error!"), _("Only one systray is allowed")); + return; + } + systray_sel_win = ECreateEventWindow(VRoot.win, -100, -100, 1, 1); + systray_sel_time = EGetTimestamp(); + XSetSelectionOwner(disp, _NET_SYSTEM_TRAY_Sx, systray_sel_win, + systray_sel_time); + if (XGetSelectionOwner(disp, _NET_SYSTEM_TRAY_Sx) != systray_sel_win) + { + DialogOK(_("Systray Error!"), _("Could not activate systray")); Eprintf("Failed to acquire selection %s\n", buf); + EDestroyWindow(systray_sel_win); + systray_sel_win = None; return; } - if (EventDebug(EDBUG_TYPE_ICONBOX)) - Eprintf("Window %#lx is now system tray\n", win); + Eprintf("Window %#lx is now %s owner, time=%ld\n", + systray_sel_win, buf, systray_sel_time); + + ESelectInput(systray_sel_win, + SubstructureRedirectMask | SubstructureNotifyMask); + EventCallbackRegister(systray_sel_win, 0, SystrayEvent, ib); ESelectInputAdd(win, SubstructureRedirectMask | ResizeRedirectMask | SubstructureNotifyMask); EventCallbackRegister(win, 0, SystrayEvent, ib); ecore_x_client_message32_send(VRoot.win, E_XA_MANAGER, StructureNotifyMask, - CurrentTime, _NET_SYSTEM_TRAY_Sx, win, 0, 0); + CurrentTime, _NET_SYSTEM_TRAY_Sx, + systray_sel_win, 0, 0); } static void SystrayExit(Iconbox * ib) { + XSetSelectionOwner(disp, _NET_SYSTEM_TRAY_Sx, None, systray_sel_time); + EventCallbackUnregister(systray_sel_win, 0, SystrayEvent, ib); EventCallbackUnregister(ib->win, 0, SystrayEvent, ib); + EDestroyWindow(systray_sel_win); + systray_sel_win = None; } =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/x.c,v retrieving revision 1.87 retrieving revision 1.88 diff -u -3 -r1.87 -r1.88 --- x.c 12 May 2005 16:50:52 -0000 1.87 +++ x.c 12 May 2005 19:02:15 -0000 1.88 @@ -1245,6 +1245,29 @@ disp = NULL; } +Time +EGetTimestamp(void) +{ + static Window win_ts = None; + XSetWindowAttributes attr; + XEvent ev; + + if (win_ts == None) + { + attr.override_redirect = 1; + win_ts = XCreateWindow(disp, VRoot.win, -100, -100, 1, 1, 0, + CopyFromParent, InputOnly, CopyFromParent, + CWOverrideRedirect, &attr); + XSelectInput(disp, win_ts, PropertyChangeMask); + } + + XChangeProperty(disp, win_ts, XA_WM_NAME, XA_STRING, 8, + PropModeAppend, (unsigned char *)"", 0); + XWindowEvent(disp, win_ts, PropertyChangeMask, &ev); + + return ev.xproperty.time; +} + void EDrawableDumpImage(Drawable draw, const char *txt) { ------------------------------------------------------- This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes! http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs