473
473
screen_set_selection(XfceDesktop *desktop)
477
gchar selection_name[100];
478
Atom selection_atom, manager_atom;
477
gchar selection_name[100], common_selection_name[32];
478
Atom selection_atom, common_selection_atom, manager_atom;
480
480
xwin = GDK_WINDOW_XID(GTK_WIDGET(desktop)->window);
481
481
xscreen = gdk_screen_get_number(desktop->priv->gscreen);
484
484
selection_atom = XInternAtom(GDK_DISPLAY(), selection_name, False);
485
485
manager_atom = XInternAtom(GDK_DISPLAY(), "MANAGER", False);
487
if(xfdesktop_check_is_running(&xid)) {
488
/* the previous check in src/main.c occurs too early, so workaround by
489
* adding this one. Hopefully it should help for lp #329616 */
487
g_snprintf(common_selection_name, 32, "_NET_DESKTOP_MANAGER_S%d", xscreen);
488
common_selection_atom = XInternAtom(GDK_DISPLAY(), common_selection_name, False);
490
/* the previous check in src/main.c occurs too early, so workaround by
491
* adding this one. Hopefully it should help for lp #329616 */
492
if(XGetSelectionOwner(GDK_DISPLAY(), selection_atom) != None) {
490
493
g_warning("%s: already running, quitting.", PACKAGE);
497
/* Check that _NET_DESKTOP_MANAGER_S%d isn't set, as it means another
498
* desktop manager is running, e.g. nautilus */
499
if(XGetSelectionOwner (GDK_DISPLAY(), common_selection_atom) != None) {
500
g_warning("%s: another desktop manager is running.", PACKAGE);
494
504
XSelectInput(GDK_DISPLAY(), xwin, PropertyChangeMask | ButtonPressMask);
495
505
XSetSelectionOwner(GDK_DISPLAY(), selection_atom, xwin, GDK_CURRENT_TIME);
506
XSetSelectionOwner(GDK_DISPLAY(), common_selection_atom, xwin, GDK_CURRENT_TIME);
497
508
/* Check to see if we managed to claim the selection. If not,
498
509
* we treat it as if we got it then immediately lost it */