diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-03-16 21:58:44 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-03-16 21:58:44 +0900 |
commit | ab3e99d8ee8ef5b53dcd1e6f90e3cdbbc08322e3 (patch) | |
tree | e622bfddde12ec89c8a84bfefec8dce7140109db /src/util.cpp | |
parent | d9e1d9fa71544a674d213117c0b675a0e874e556 (diff) | |
download | tdedocker-ab3e99d8ee8ef5b53dcd1e6f90e3cdbbc08322e3.tar.gz tdedocker-ab3e99d8ee8ef5b53dcd1e6f90e3cdbbc08322e3.zip |
Conversion to TDE application.
Notable changes:
1) save/restore data are saved in TDE session files.
2) remove -a, -l options. Removed "Launch on startup" option.
3) docked application are restored automatically by the TDE session
manager. After being restored, tdedocker will wait for 5 seconds to let
the various applications be restored, then it will try to grab the
required windows.
4) save/restore of docked applications is now working properly.
5) due to the way TDE manages command line options, at the moment
additional parameters cannot be passed to the application to be
docked. This will be address in a subsequent commit.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
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) { |