diff options
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/util.cpp b/src/util.cpp index afbb578..541aece 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2004 Girish Ramakrishnan All Rights Reserved. - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -54,7 +54,7 @@ bool isNormalWindow(Display *display, Window w) Atom *data = NULL; unsigned long nitems; Window transient_for = None; - + static Atom wmState = XInternAtom(display, "WM_STATE", False); static Atom windowState = XInternAtom(display, "_NET_WM_STATE", False); static Atom modalWindow = @@ -71,11 +71,11 @@ bool isNormalWindow(Display *display, Window w) &nitems, &left, (unsigned char **) &data); TRACE("0x%x (%i)", (unsigned) w, (unsigned) w); - + if (ret != Success || data == NULL) return false; TRACE("\tHas WM_STATE"); if (data) XFree(data); - + ret = XGetWindowProperty(display, w, windowState, 0, 10, False, AnyPropertyType, &type, &format, &nitems, &left, (unsigned char **) &data); @@ -126,9 +126,9 @@ pid_t pid(Display *display, Window w) pid_t pid_return = -1; if (XGetWindowProperty(display, w, - XInternAtom(display, "_NET_WM_PID", False), 0, - 1, False, XA_CARDINAL, &actual_type, - &actual_format, &nitems, &leftover, &pid) == Success) + XInternAtom(display, "_NET_WM_PID", False), 0, + 1, False, XA_CARDINAL, &actual_type, + &actual_format, &nitems, &leftover, &pid) == Success) { if (pid) pid_return = *(pid_t *) pid; XFree(pid); @@ -162,10 +162,13 @@ bool analyzeWindow(Display *display, Window w, pid_t epid, const TQString &ename { XClassHint ch; pid_t apid = pid(display, w); - - TRACE("WID=0x%x PID=%i ExpectedName=%s", (unsigned) w, (unsigned) epid, - ename.latin1()); + + TRACE("WID=0x%x EPID=%i APID=%i ExpectedName=%s", (unsigned) w, (unsigned) epid, (unsigned) apid, + ename.local8Bit()); if (epid == apid) return true; + // Only analyze window name if no process pid was provided, to avoid associating + // the wrong window to a given process + if (epid) return false; // no plans to analyze windows without a name char *window_name = NULL; @@ -256,7 +259,7 @@ Window selectWindow(Display *display, const char **err) if (err) *err = "Failed to grab mouse"; return None; } - + XAllowEvents(display, SyncPointer, CurrentTime); XEvent event; XWindowEvent(display, root, ButtonPressMask, &event); @@ -309,7 +312,7 @@ bool getCardinalProperty(Display *display, Window w, Atom prop, long *data) int format; unsigned long nitems, bytes; unsigned char *d = NULL; - + if (XGetWindowProperty(display, w, prop, 0, 1, False, XA_CARDINAL,&type, &format, &nitems, &bytes, &d) == Success && d) { |