From f22b9dfd940b3e593f03b4b83e6d7b43ea877eca Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 7 Oct 2001 23:06:19 +0000 Subject: [PATCH] set _NET_ACTIVE_WINDOW hint 2001-10-07 Havoc Pennington * src/display.c (meta_display_update_active_window_hint): set _NET_ACTIVE_WINDOW hint * src/window.c (meta_window_client_message): support _NET_ACTIVE_WINDOW client message --- ChangeLog | 8 ++++++ src/display.c | 67 ++++++++++++++++++++++++++++++++++++++------------- src/display.h | 3 +++ src/window.c | 22 +++++++++++++++++ 4 files changed, 83 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index f50dcc9ad..53bc11ece 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-10-07 Havoc Pennington + + * src/display.c (meta_display_update_active_window_hint): + set _NET_ACTIVE_WINDOW hint + + * src/window.c (meta_window_client_message): support + _NET_ACTIVE_WINDOW client message + 2001-10-07 Havoc Pennington * src/window.c (meta_window_client_message): don't allow diff --git a/src/display.c b/src/display.c index 24ea36adb..c3e80e89e 100644 --- a/src/display.c +++ b/src/display.c @@ -135,7 +135,8 @@ meta_display_open (const char *name) "UTF8_STRING", "WM_ICON_SIZE", "_KWM_WIN_ICON", - "_NET_WM_MOVERESIZE" + "_NET_WM_MOVERESIZE", + "_NET_ACTIVE_WINDOW" }; Atom atoms[G_N_ELEMENTS(atom_names)]; @@ -222,6 +223,7 @@ meta_display_open (const char *name) display->atom_wm_icon_size = atoms[40]; display->atom_kwm_win_icon = atoms[41]; display->atom_net_wm_moveresize = atoms[42]; + display->atom_net_active_window = atoms[43]; /* Offscreen unmapped window used for _NET_SUPPORTING_WM_CHECK, * created in screen_new @@ -905,27 +907,29 @@ event_callback (XEvent *event, screen = meta_display_screen_for_root (display, event->xclient.window); - if (screen && - event->xclient.message_type == - display->atom_net_current_desktop) + if (screen) { - int space; - MetaWorkspace *workspace; + if (event->xclient.message_type == + display->atom_net_current_desktop) + { + int space; + MetaWorkspace *workspace; - space = event->xclient.data.l[0]; + space = event->xclient.data.l[0]; - meta_verbose ("Request to change current workspace to %d\n", - space); + meta_verbose ("Request to change current workspace to %d\n", + space); - workspace = - meta_display_get_workspace_by_screen_index (display, - screen, - space); + workspace = + meta_display_get_workspace_by_screen_index (display, + screen, + space); - if (workspace) - meta_workspace_activate (workspace); - else - meta_verbose ("Don't know about workspace %d\n", space); + if (workspace) + meta_workspace_activate (workspace); + else + meta_verbose ("Don't know about workspace %d\n", space); + } } } break; @@ -1674,3 +1678,32 @@ meta_display_increment_event_serial (MetaDisplay *display) XDeleteProperty (display->xdisplay, display->leader_window, display->atom_motif_wm_hints); } + +void +meta_display_update_active_window_hint (MetaDisplay *display) +{ + GSList *tmp; + + unsigned long data[2]; + + if (display->focus_window) + data[0] = display->focus_window->xwindow; + else + data[0] = None; + data[1] = None; + + tmp = display->screens; + while (tmp != NULL) + { + MetaScreen *screen = tmp->data; + + meta_error_trap_push (display); + XChangeProperty (display->xdisplay, screen->xroot, + display->atom_net_active_window, + XA_WINDOW, + 32, PropModeReplace, (guchar*) data, 2); + meta_error_trap_pop (display); + + tmp = tmp->next; + } +} diff --git a/src/display.h b/src/display.h index b2552dab4..fe2a9e6bb 100644 --- a/src/display.h +++ b/src/display.h @@ -100,6 +100,7 @@ struct _MetaDisplay Atom atom_wm_icon_size; Atom atom_kwm_win_icon; Atom atom_net_wm_moveresize; + Atom atom_net_active_window; /* This is the actual window from focus events, * not the one we last set @@ -194,4 +195,6 @@ void meta_display_ungrab_window_buttons (MetaDisplay *display, /* make a request to ensure the event serial has changed */ void meta_display_increment_event_serial (MetaDisplay *display); +void meta_display_update_active_window_hint (MetaDisplay *display); + #endif diff --git a/src/window.c b/src/window.c index 8d380f780..9303b39b3 100644 --- a/src/window.c +++ b/src/window.c @@ -2449,6 +2449,25 @@ meta_window_client_message (MetaWindow *window, return TRUE; } + else if (event->xclient.message_type == + display->atom_net_active_window) + { + meta_verbose ("_NET_ACTIVE_WINDOW request for window '%s'", window->desc); + + /* Switch to window's workspace - alternatively we could move + * window back to this workspace. I don't know which is right. + */ + if (!meta_workspace_contains_window (window->screen->active_workspace, + window) && + /* this check shouldn't actually be required, I don't think it is */ + window->workspaces) + meta_workspace_activate (window->workspaces->data); + + meta_window_raise (window); + meta_window_focus (window, CurrentTime); /* FIXME CurrentTime */ + + return TRUE; + } return FALSE; } @@ -2523,6 +2542,9 @@ meta_window_notify_focus (MetaWindow *window, meta_frame_queue_draw (window->frame); } + /* Now set _NET_ACTIVE_WINDOW hint */ + meta_display_update_active_window_hint (window->display); + return FALSE; }