|
Lines 413-423
x11_window_is_ours (Window window)
Link Here
|
| 413 |
gwindow = gdk_window_lookup (window); |
413 |
gwindow = gdk_window_lookup (window); |
| 414 |
if (gwindow && (window != GDK_ROOT_WINDOW ())) { |
414 |
if (gwindow && (window != GDK_ROOT_WINDOW ())) { |
| 415 |
ret = TRUE; |
415 |
ret = TRUE; |
| 416 |
} |
416 |
} |
| 417 |
|
417 |
|
| 418 |
return ret; |
418 |
return ret; |
| 419 |
} |
419 |
} |
| 420 |
|
420 |
|
|
|
421 |
#define GET_DISPLAY gdk_x11_display_get_xdisplay (gdk_display_get_default ()) |
| 422 |
|
| 423 |
static gboolean |
| 424 |
is_xvkbd_window (Window window) |
| 425 |
{ |
| 426 |
gboolean ret = FALSE; |
| 427 |
XClassHint class_hint; |
| 428 |
|
| 429 |
if (XGetClassHint (GET_DISPLAY, window, &class_hint) == Success) { |
| 430 |
if (g_strstr_len (class_hint.res_name, |
| 431 |
strlen (class_hint.res_name), |
| 432 |
"xvkbd")) |
| 433 |
ret = TRUE; |
| 434 |
} |
| 435 |
|
| 436 |
return ret; |
| 437 |
} |
| 438 |
|
| 439 |
static void |
| 440 |
setup_xvkbd_window (Window window) |
| 441 |
{ |
| 442 |
XWithdrawWindow (GET_DISPLAY, window, gdk_x11_get_default_screen ()); |
| 443 |
for(;;) { |
| 444 |
Atom type; |
| 445 |
int format; |
| 446 |
unsigned long length, after; |
| 447 |
unsigned char *data; |
| 448 |
int r; |
| 449 |
|
| 450 |
r = XGetWindowProperty (GET_DISPLAY, |
| 451 |
window, XInternAtom (GET_DISPLAY, "WM_STATE", TRUE), 0, 2, |
| 452 |
FALSE, AnyPropertyType, &type, &format, |
| 453 |
&length, &after, &data ); |
| 454 |
gboolean withdrawn = TRUE; |
| 455 |
if (r == Success && data && format == 32) { |
| 456 |
guint32 *wstate = (guint32 *) data; |
| 457 |
withdrawn = (*wstate == WithdrawnState ); |
| 458 |
XFree ((char *) data); |
| 459 |
} |
| 460 |
if (withdrawn) |
| 461 |
break; |
| 462 |
} |
| 463 |
|
| 464 |
XSelectInput (GET_DISPLAY, window, StructureNotifyMask); |
| 465 |
XWindowAttributes attr_geom; |
| 466 |
|
| 467 |
if (!XGetWindowAttributes (GET_DISPLAY, window, &attr_geom )) |
| 468 |
return; |
| 469 |
int x = XDisplayWidth (GET_DISPLAY, gdk_x11_get_default_screen ()) - attr_geom.width; |
| 470 |
int y = XDisplayHeight (GET_DISPLAY, gdk_x11_get_default_screen ()) - attr_geom.height; |
| 471 |
|
| 472 |
XSetWindowAttributes attr; |
| 473 |
attr.override_redirect = True; |
| 474 |
XChangeWindowAttributes (GET_DISPLAY, window, CWOverrideRedirect, &attr); |
| 475 |
XReparentWindow (GET_DISPLAY, window, GDK_ROOT_WINDOW(), x, y ); |
| 476 |
XMapWindow (GET_DISPLAY, window); |
| 477 |
} |
| 478 |
|
| 421 |
static void |
479 |
static void |
| 422 |
gs_window_xevent (GSWindow *window, |
480 |
gs_window_xevent (GSWindow *window, |
| 423 |
GdkXEvent *xevent) |
481 |
GdkXEvent *xevent) |
|
Lines 434-440
gs_window_xevent (GSWindow *window,
Link Here
|
| 434 |
XMapEvent *xme = &ev->xmap; |
492 |
XMapEvent *xme = &ev->xmap; |
| 435 |
|
493 |
|
| 436 |
if (! x11_window_is_ours (xme->window)) { |
494 |
if (! x11_window_is_ours (xme->window)) { |
| 437 |
gs_window_raise (window); |
495 |
if (is_xvkbd_window (xme->window)) |
|
|
496 |
setup_xvkbd_window (xme->window); |
| 497 |
else |
| 498 |
gs_window_raise (window); |
| 438 |
} else { |
499 |
} else { |
| 439 |
gs_debug ("not raising our windows"); |
500 |
gs_debug ("not raising our windows"); |
| 440 |
} |
501 |
} |
|
Lines 446-452
gs_window_xevent (GSWindow *window,
Link Here
|
| 446 |
XConfigureEvent *xce = &ev->xconfigure; |
507 |
XConfigureEvent *xce = &ev->xconfigure; |
| 447 |
|
508 |
|
| 448 |
if (! x11_window_is_ours (xce->window)) { |
509 |
if (! x11_window_is_ours (xce->window)) { |
| 449 |
gs_window_raise (window); |
510 |
if (is_xvkbd_window (xce->window)) |
|
|
511 |
XRaiseWindow (GET_DISPLAY, xce->window); |
| 512 |
else |
| 513 |
gs_window_raise (window); |
| 450 |
} else { |
514 |
} else { |
| 451 |
gs_debug ("not raising our windows"); |
515 |
gs_debug ("not raising our windows"); |
| 452 |
} |
516 |
} |