From a6595e320d0b1c16143be3a3a9c0f451ce5400da Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Tue, 2 Apr 2019 19:38:44 +0300 Subject: [PATCH 1/2] Map application icon window without focus switch for applications executed with argument `-autolaunch YES` in WindowMaker environment. --- ChangeLog | 7 +++++++ Source/x11/XGServerWindow.m | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3a922a0..1069e2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-04-02 Sergii Stoian + + * Source/x11/XGServerWindow.m: + (orderwindow:::) Map application icon window without focus flickering + for applications executed with argument `-autolaunch YES` in WindowMaker + environment. + 2019-03-26 Sergii Stoian * Source/x11/XGServerWindow.m: (setwindowlevel::) Set `Utility` window type for NSFloatingWindowLevel. diff --git a/Source/x11/XGServerWindow.m b/Source/x11/XGServerWindow.m index a77c81e..090c50e 100644 --- a/Source/x11/XGServerWindow.m +++ b/Source/x11/XGServerWindow.m @@ -2815,6 +2815,24 @@ static BOOL didCreatePixmaps; */ if ((window->win_attrs.window_style & NSIconWindowMask) != 0) { + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + if (op != NSWindowOut && window->map_state == IsUnmapped && + [[defaults objectForKey: @"autolaunch"] isEqualToString:@"YES"]) + { + XEvent ev; + + // Inform WM to ignore focus events + ev.xclient.type = ClientMessage; + ev.xclient.message_type = XInternAtom(dpy,"WM_IGNORE_FOCUS_EVENTS", False); + ev.xclient.format = 32; + ev.xclient.data.l[0] = True; + XSendEvent(dpy, ROOT, True, EnterWindowMask, &ev); + // Display application icon + XMapWindow(dpy, ROOT); + // Inform WM to process focus events again + ev.xclient.data.l[0] = False; + XSendEvent(dpy, ROOT, True, EnterWindowMask, &ev); + } return; } if ((window->win_attrs.window_style & NSMiniWindowMask) != 0) From 233c129a5c027a92b99f0b31952f0e3238e1ed61 Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Wed, 3 Apr 2019 19:13:30 +0300 Subject: [PATCH 2/2] WM_IGNORE_FOCUS_EVENTS atom was added. Use new atom in orderwindow::: code added in last commit. --- Headers/x11/XGGeneric.h | 4 +++- Source/x11/XGServerWindow.m | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Headers/x11/XGGeneric.h b/Headers/x11/XGGeneric.h index ec02b0b..6b3415a 100644 --- a/Headers/x11/XGGeneric.h +++ b/Headers/x11/XGGeneric.h @@ -108,7 +108,8 @@ static char *atom_names[] = { "_GNUSTEP_WM_MINIATURIZE_WINDOW", "_GNUSTEP_WM_ATTR", "_GNUSTEP_TITLEBAR_STATE", - "_GNUSTEP_FRAME_OFFSETS" + "_GNUSTEP_FRAME_OFFSETS", + "WM_IGNORE_FOCUS_EVENTS" }; /* @@ -181,6 +182,7 @@ static char *atom_names[] = { #define _GNUSTEP_WM_ATTR_ATOM atoms[64] #define _GNUSTEP_TITLEBAR_STATE_ATOM atoms[65] #define _GNUSTEP_FRAME_OFFSETS_ATOM atoms[66] +#define WM_IGNORE_FOCUS_EVENTS_ATOM atoms[67] /* * Frame offsets for window inside parent decoration window. diff --git a/Source/x11/XGServerWindow.m b/Source/x11/XGServerWindow.m index 090c50e..fbc927d 100644 --- a/Source/x11/XGServerWindow.m +++ b/Source/x11/XGServerWindow.m @@ -2821,15 +2821,15 @@ static BOOL didCreatePixmaps; { XEvent ev; - // Inform WM to ignore focus events + // Inform WindowMaker to ignore focus events ev.xclient.type = ClientMessage; - ev.xclient.message_type = XInternAtom(dpy,"WM_IGNORE_FOCUS_EVENTS", False); + ev.xclient.message_type = generic.WM_IGNORE_FOCUS_EVENTS_ATOM; ev.xclient.format = 32; ev.xclient.data.l[0] = True; XSendEvent(dpy, ROOT, True, EnterWindowMask, &ev); // Display application icon XMapWindow(dpy, ROOT); - // Inform WM to process focus events again + // Inform WindowMaker to process focus events again ev.xclient.data.l[0] = False; XSendEvent(dpy, ROOT, True, EnterWindowMask, &ev); }