#include "appcore-internal.h"
static Atom a_pid;
+static Atom a_active_win;
static pid_t __get_win_pid(Display *d, Window win)
{
unsigned long nitems;
unsigned long bytes_after;
unsigned char *prop_ret;
+ XWindowAttributes attr;
_retv_if(d == NULL || !a_pid, -1);
+ if (!XGetWindowAttributes(d, win, &attr))
+ return -1;
+
+ if (attr.override_redirect || attr.class == InputOnly)
+ return -1;
+
prop_ret = NULL;
r = XGetWindowProperty(d, win, a_pid, 0, 1, False, XA_CARDINAL,
&a_type, &format, &nitems, &bytes_after,
static int __raise_win(Display *d, Window win)
{
- XWindowAttributes attr;
-
- XMapRaised(d, win);
- XGetWindowAttributes(d, win, &attr);
- _retv_if(attr.map_state != IsViewable, -1);
-
- /*
- * Window Manger sets the Input Focus.
- * Appcore does not need to enforce this anymore.
- *
- * XSetInputFocus(d, win, RevertToPointerRoot, CurrentTime);
- *
- */
+ XEvent xev;
+ Window root;
+
+ if (!a_active_win)
+ a_active_win = XInternAtom(d, "_NET_ACTIVE_WINDOW", False);
+
+ root = XDefaultRootWindow(d);
+
+ xev.xclient.type = ClientMessage;
+ xev.xclient.display = d;
+ xev.xclient.window = win;
+ xev.xclient.message_type = a_active_win;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = 1;
+ xev.xclient.data.l[1] = CurrentTime;
+ xev.xclient.data.l[2] = 0;
+ xev.xclient.data.l[3] = 0;
+ xev.xclient.data.l[4] = 0;
+ XSendEvent(d, root, False,
+ SubstructureRedirectMask | SubstructureNotifyMask, &xev);
return 0;
}
-int x_raise_win(pid_t pid)
+EXPORT_API int x_raise_win(pid_t pid)
{
int r;
_retv_if(d == NULL, -1);
win = XDefaultRootWindow(d);
-
if (!a_pid)
a_pid = XInternAtom(d, "_NET_WM_PID", True);