mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-30 18:32:34 +01:00
Set missing WM_COMMAND using pid given from libXRes
For apps which are not setting the window WM_COMMAND property like those old apps using Motif toolkit (I am thinking of NEdit for example) it's bringing some issues in windowmaker which is relying on it for a few interactions. Especially, *an app without WM_COMMAND will not be saved during the workspace state (so session restore is not working for them) *when added to the dock, the settings parameters are empty and need to be filled *cannot autostart from the dock (even if the settings are manually filled and saved) *right click on the app titlebar, and choosing Launch has no effect Most of the time, those apps are also not setting the X11_NET_WM_PID property. With the pid we could have a chance to find the running program. To link a window to a pid, there is the X11 Resource extension library (libXRes). After checking, gnome and xfce are also using the same method to handle such issues. The patch is checking if the libXRes is present on the system (but it's not mandatory to compile). Then, it adds a layer on top of wNETWMGetPidForWindow to not only check the window property but if necessary to get the underlying pid from libXRes if available. That's solving the points mentioned above.
This commit is contained in:
committed by
Carlos R. Mafra
parent
5ee19c2308
commit
d902477efd
40
src/window.c
40
src/window.c
@@ -29,6 +29,9 @@
|
||||
#ifdef KEEP_XKB_LOCK_STATUS
|
||||
#include <X11/XKBlib.h>
|
||||
#endif /* KEEP_XKB_LOCK_STATUS */
|
||||
#ifdef USE_XRES
|
||||
#include <X11/extensions/XRes.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -475,6 +478,41 @@ Bool wWindowObscuresWindow(WWindow *wwin, WWindow *obscured)
|
||||
return True;
|
||||
}
|
||||
|
||||
/* Get the corresponding Process Identification Number of the active window */
|
||||
static pid_t getWindowPid(Window win)
|
||||
{
|
||||
pid_t pid = -1;
|
||||
|
||||
pid = wNETWMGetPidForWindow(win);
|
||||
#ifdef USE_XRES
|
||||
if (pid > 0)
|
||||
return pid;
|
||||
else {
|
||||
XResClientIdSpec spec;
|
||||
int status;
|
||||
long i, num_ids = 0;
|
||||
XResClientIdValue *client_ids = NULL;
|
||||
|
||||
spec.client = win;
|
||||
spec.mask = XRES_CLIENT_ID_PID_MASK;
|
||||
|
||||
status = XResQueryClientIds(dpy, 1, &spec, &num_ids, &client_ids);
|
||||
|
||||
if (status != Success)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < num_ids; i++) {
|
||||
if (client_ids[i].spec.mask == XRES_CLIENT_ID_PID_MASK) {
|
||||
pid = XResGetClientPid(&client_ids[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
XResClientIdsDestroy(num_ids, client_ids);
|
||||
}
|
||||
#endif
|
||||
return pid;
|
||||
}
|
||||
|
||||
static void fixLeaderProperties(WWindow *wwin)
|
||||
{
|
||||
XClassHint *classHint;
|
||||
@@ -487,7 +525,7 @@ static void fixLeaderProperties(WWindow *wwin)
|
||||
|
||||
classHint = XAllocClassHint();
|
||||
clientHints = XGetWMHints(dpy, wwin->client_win);
|
||||
pid = wNETWMGetPidForWindow(wwin->client_win);
|
||||
pid = getWindowPid(wwin->client_win);
|
||||
if (pid > 0)
|
||||
haveCommand = GetCommandForPid(pid, &argv, &argc);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user