mirror of
https://github.com/brl/mutter.git
synced 2024-11-30 12:00:44 -05:00
workspace: use triggering device to focus the default window on workspace switch
This commit is contained in:
parent
dfcd079ec2
commit
95b2e6fafc
@ -250,9 +250,19 @@ lower_window_and_transients (MetaWindow *window,
|
|||||||
void
|
void
|
||||||
meta_core_user_lower_and_unfocus (Display *xdisplay,
|
meta_core_user_lower_and_unfocus (Display *xdisplay,
|
||||||
Window frame_xwindow,
|
Window frame_xwindow,
|
||||||
|
int device_id,
|
||||||
guint32 timestamp)
|
guint32 timestamp)
|
||||||
{
|
{
|
||||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||||
|
MetaDevice *pointer;
|
||||||
|
|
||||||
|
pointer = meta_device_map_lookup (window->display->device_map, device_id);
|
||||||
|
|
||||||
|
if (pointer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!META_IS_DEVICE_POINTER (pointer))
|
||||||
|
pointer = meta_device_get_paired_device (pointer);
|
||||||
|
|
||||||
lower_window_and_transients (window, NULL);
|
lower_window_and_transients (window, NULL);
|
||||||
|
|
||||||
@ -261,6 +271,7 @@ meta_core_user_lower_and_unfocus (Display *xdisplay,
|
|||||||
* this will be invoked via keyboard action or by a mouse action;
|
* this will be invoked via keyboard action or by a mouse action;
|
||||||
* in either case the window or a modal child will have been focused.) */
|
* in either case the window or a modal child will have been focused.) */
|
||||||
meta_workspace_focus_default_window (window->screen->active_workspace,
|
meta_workspace_focus_default_window (window->screen->active_workspace,
|
||||||
|
pointer,
|
||||||
NULL,
|
NULL,
|
||||||
timestamp);
|
timestamp);
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,7 @@ void meta_core_user_raise (Display *xdisplay,
|
|||||||
Window frame_xwindow);
|
Window frame_xwindow);
|
||||||
void meta_core_user_lower_and_unfocus (Display *xdisplay,
|
void meta_core_user_lower_and_unfocus (Display *xdisplay,
|
||||||
Window frame_xwindow,
|
Window frame_xwindow,
|
||||||
|
int device_id,
|
||||||
guint32 timestamp);
|
guint32 timestamp);
|
||||||
|
|
||||||
void meta_core_user_focus (Display *xdisplay,
|
void meta_core_user_focus (Display *xdisplay,
|
||||||
|
@ -2057,7 +2057,7 @@ event_callback (XEvent *event,
|
|||||||
|
|
||||||
if (new_screen != NULL && display->active_screen != new_screen)
|
if (new_screen != NULL && display->active_screen != new_screen)
|
||||||
meta_workspace_focus_default_window (new_screen->active_workspace,
|
meta_workspace_focus_default_window (new_screen->active_workspace,
|
||||||
NULL,
|
device, NULL,
|
||||||
evtime);
|
evtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2206,6 +2206,7 @@ event_callback (XEvent *event,
|
|||||||
"brain-damage in the X protocol (see bug "
|
"brain-damage in the X protocol (see bug "
|
||||||
"125492). Setting the default focus window.\n");
|
"125492). Setting the default focus window.\n");
|
||||||
meta_workspace_focus_default_window (screen->active_workspace,
|
meta_workspace_focus_default_window (screen->active_workspace,
|
||||||
|
meta_device_get_paired_device (device),
|
||||||
NULL,
|
NULL,
|
||||||
meta_display_get_current_time_roundtrip (display));
|
meta_display_get_current_time_roundtrip (display));
|
||||||
}
|
}
|
||||||
@ -2218,6 +2219,7 @@ event_callback (XEvent *event,
|
|||||||
"gnome-session logout dialog usage (see bug "
|
"gnome-session logout dialog usage (see bug "
|
||||||
"153220). Setting the default focus window.\n");
|
"153220). Setting the default focus window.\n");
|
||||||
meta_workspace_focus_default_window (screen->active_workspace,
|
meta_workspace_focus_default_window (screen->active_workspace,
|
||||||
|
meta_device_get_paired_device (device),
|
||||||
NULL,
|
NULL,
|
||||||
meta_display_get_current_time_roundtrip (display));
|
meta_display_get_current_time_roundtrip (display));
|
||||||
}
|
}
|
||||||
@ -2619,8 +2621,15 @@ event_callback (XEvent *event,
|
|||||||
meta_screen_show_desktop (screen, timestamp);
|
meta_screen_show_desktop (screen, timestamp);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
MetaDevice *pointer;
|
||||||
|
|
||||||
|
pointer = meta_device_map_lookup (screen->display->device_map,
|
||||||
|
META_CORE_POINTER_ID);
|
||||||
|
|
||||||
meta_screen_unshow_desktop (screen);
|
meta_screen_unshow_desktop (screen);
|
||||||
meta_workspace_focus_default_window (screen->active_workspace, NULL, timestamp);
|
meta_workspace_focus_default_window (screen->active_workspace,
|
||||||
|
pointer,
|
||||||
|
NULL, timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event->xclient.message_type ==
|
else if (event->xclient.message_type ==
|
||||||
|
@ -2892,12 +2892,13 @@ process_workspace_switch_grab (MetaDisplay *display,
|
|||||||
{
|
{
|
||||||
MetaWorkspace *workspace;
|
MetaWorkspace *workspace;
|
||||||
guint evtype, keycode;
|
guint evtype, keycode;
|
||||||
MetaDevice *device;
|
MetaDevice *pointer, *keyboard;
|
||||||
MetaGrabInfo *grab_info;
|
MetaGrabInfo *grab_info;
|
||||||
Time evtime;
|
Time evtime;
|
||||||
|
|
||||||
device = meta_input_event_get_device (display, event);
|
keyboard = meta_input_event_get_device (display, event);
|
||||||
grab_info = meta_display_get_grab_info (display, device);
|
pointer = meta_device_get_paired_device (keyboard);
|
||||||
|
grab_info = meta_display_get_grab_info (display, pointer);
|
||||||
|
|
||||||
if (screen != grab_info->grab_screen || !screen->ws_popup)
|
if (screen != grab_info->grab_screen || !screen->ws_popup)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -2909,7 +2910,7 @@ process_workspace_switch_grab (MetaDisplay *display,
|
|||||||
evtime = meta_input_event_get_time (display, event);
|
evtime = meta_input_event_get_time (display, event);
|
||||||
|
|
||||||
if (evtype == KeyRelease &&
|
if (evtype == KeyRelease &&
|
||||||
end_keyboard_grab (display, device, keycode))
|
end_keyboard_grab (display, keyboard, keycode))
|
||||||
{
|
{
|
||||||
/* We're done, move to the new workspace. */
|
/* We're done, move to the new workspace. */
|
||||||
MetaWorkspace *target_workspace;
|
MetaWorkspace *target_workspace;
|
||||||
@ -2923,12 +2924,13 @@ process_workspace_switch_grab (MetaDisplay *display,
|
|||||||
{
|
{
|
||||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||||
"Ending grab so we can focus on the target workspace\n");
|
"Ending grab so we can focus on the target workspace\n");
|
||||||
meta_display_end_grab_op (display, device, evtime);
|
meta_display_end_grab_op (display, pointer, evtime);
|
||||||
|
|
||||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||||
"Focusing default window on target workspace\n");
|
"Focusing default window on target workspace\n");
|
||||||
|
|
||||||
meta_workspace_focus_default_window (target_workspace,
|
meta_workspace_focus_default_window (target_workspace,
|
||||||
|
pointer,
|
||||||
NULL,
|
NULL,
|
||||||
evtime);
|
evtime);
|
||||||
|
|
||||||
@ -3007,7 +3009,7 @@ process_workspace_switch_grab (MetaDisplay *display,
|
|||||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||||
"Ending workspace tabbing & focusing default window; uninteresting key pressed\n");
|
"Ending workspace tabbing & focusing default window; uninteresting key pressed\n");
|
||||||
workspace = meta_screen_workspace_popup_get_selected (screen);
|
workspace = meta_screen_workspace_popup_get_selected (screen);
|
||||||
meta_workspace_focus_default_window (workspace, NULL, evtime);
|
meta_workspace_focus_default_window (workspace, pointer, NULL, evtime);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3025,8 +3027,13 @@ handle_show_desktop (MetaDisplay *display,
|
|||||||
|
|
||||||
if (screen->active_workspace->showing_desktop)
|
if (screen->active_workspace->showing_desktop)
|
||||||
{
|
{
|
||||||
|
MetaDevice *keyboard;
|
||||||
|
|
||||||
|
keyboard = meta_input_event_get_device (display, event);
|
||||||
|
|
||||||
meta_screen_unshow_desktop (screen);
|
meta_screen_unshow_desktop (screen);
|
||||||
meta_workspace_focus_default_window (screen->active_workspace,
|
meta_workspace_focus_default_window (screen->active_workspace,
|
||||||
|
meta_device_get_paired_device (keyboard),
|
||||||
NULL, evtime);
|
NULL, evtime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -182,6 +182,7 @@ void meta_screen_tile_preview_update (MetaScreen *screen,
|
|||||||
void meta_screen_tile_preview_hide (MetaScreen *screen);
|
void meta_screen_tile_preview_hide (MetaScreen *screen);
|
||||||
|
|
||||||
MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen,
|
MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen,
|
||||||
|
MetaDevice *pointer,
|
||||||
MetaWindow *not_this_one);
|
MetaWindow *not_this_one);
|
||||||
|
|
||||||
const MetaMonitorInfo* meta_screen_get_current_monitor (MetaScreen *screen,
|
const MetaMonitorInfo* meta_screen_get_current_monitor (MetaScreen *screen,
|
||||||
|
@ -1963,28 +1963,23 @@ meta_screen_tile_preview_hide (MetaScreen *screen)
|
|||||||
|
|
||||||
MetaWindow*
|
MetaWindow*
|
||||||
meta_screen_get_mouse_window (MetaScreen *screen,
|
meta_screen_get_mouse_window (MetaScreen *screen,
|
||||||
|
MetaDevice *pointer,
|
||||||
MetaWindow *not_this_one)
|
MetaWindow *not_this_one)
|
||||||
{
|
{
|
||||||
MetaWindow *window;
|
MetaWindow *window;
|
||||||
Window root_return, child_return;
|
|
||||||
int root_x_return, root_y_return;
|
int root_x_return, root_y_return;
|
||||||
int win_x_return, win_y_return;
|
|
||||||
unsigned int mask_return;
|
|
||||||
|
|
||||||
if (not_this_one)
|
if (not_this_one)
|
||||||
meta_topic (META_DEBUG_FOCUS,
|
meta_topic (META_DEBUG_FOCUS,
|
||||||
"Focusing mouse window excluding %s\n", not_this_one->desc);
|
"Focusing mouse window excluding %s\n", not_this_one->desc);
|
||||||
|
|
||||||
meta_error_trap_push (screen->display);
|
meta_error_trap_push (screen->display);
|
||||||
XQueryPointer (screen->display->xdisplay,
|
meta_device_pointer_query_position (META_DEVICE_POINTER (pointer),
|
||||||
screen->xroot,
|
screen->xroot,
|
||||||
&root_return,
|
NULL, NULL,
|
||||||
&child_return,
|
|
||||||
&root_x_return,
|
&root_x_return,
|
||||||
&root_y_return,
|
&root_y_return,
|
||||||
&win_x_return,
|
NULL, NULL, NULL);
|
||||||
&win_y_return,
|
|
||||||
&mask_return);
|
|
||||||
meta_error_trap_pop (screen->display);
|
meta_error_trap_pop (screen->display);
|
||||||
|
|
||||||
window = meta_stack_get_default_focus_window_at_point (screen->stack,
|
window = meta_stack_get_default_focus_window_at_point (screen->stack,
|
||||||
|
@ -1539,11 +1539,20 @@ meta_window_unmanage (MetaWindow *window,
|
|||||||
* invariants.
|
* invariants.
|
||||||
*/
|
*/
|
||||||
if (meta_window_appears_focused (window))
|
if (meta_window_appears_focused (window))
|
||||||
meta_window_propagate_focus_appearance (window,
|
meta_window_propagate_focus_appearance (window, FALSE);
|
||||||
window->focus_keyboard,
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
if (window->focus_keyboard)
|
if (window->focus_keyboard)
|
||||||
|
{
|
||||||
|
meta_topic (META_DEBUG_FOCUS,
|
||||||
|
"Focusing default window since we're unmanaging %s\n",
|
||||||
|
window->desc);
|
||||||
|
meta_workspace_focus_default_window (window->screen->active_workspace,
|
||||||
|
meta_device_get_paired_device (window->focus_keyboard),
|
||||||
|
window,
|
||||||
|
timestamp);
|
||||||
|
}
|
||||||
|
else if (window->focus_keyboard &&
|
||||||
|
window->expecting_focus_in)
|
||||||
{
|
{
|
||||||
if (window->expecting_focus_in)
|
if (window->expecting_focus_in)
|
||||||
{
|
{
|
||||||
@ -1558,6 +1567,7 @@ meta_window_unmanage (MetaWindow *window,
|
|||||||
window->desc);
|
window->desc);
|
||||||
|
|
||||||
meta_workspace_focus_default_window (window->screen->active_workspace,
|
meta_workspace_focus_default_window (window->screen->active_workspace,
|
||||||
|
meta_device_get_paired_device (window->focus_keyboard),
|
||||||
window,
|
window,
|
||||||
timestamp);
|
timestamp);
|
||||||
}
|
}
|
||||||
@ -3144,7 +3154,7 @@ meta_window_hide (MetaWindow *window)
|
|||||||
* gotten FocusIn/FocusOut events. A more complete comprehensive
|
* gotten FocusIn/FocusOut events. A more complete comprehensive
|
||||||
* fix for these type of issues is described in the bug.
|
* fix for these type of issues is described in the bug.
|
||||||
*/
|
*/
|
||||||
if (window->has_focus && window->expecting_focus_in)
|
if (window->focus_keyboard && window->expecting_focus_in)
|
||||||
{
|
{
|
||||||
MetaWindow *not_this_one = NULL;
|
MetaWindow *not_this_one = NULL;
|
||||||
MetaWorkspace *my_workspace = meta_window_get_workspace (window);
|
MetaWorkspace *my_workspace = meta_window_get_workspace (window);
|
||||||
@ -3162,6 +3172,7 @@ meta_window_hide (MetaWindow *window)
|
|||||||
not_this_one = window;
|
not_this_one = window;
|
||||||
|
|
||||||
meta_workspace_focus_default_window (window->screen->active_workspace,
|
meta_workspace_focus_default_window (window->screen->active_workspace,
|
||||||
|
meta_device_get_paired_device (window->focus_keyboard),
|
||||||
not_this_one,
|
not_this_one,
|
||||||
timestamp);
|
timestamp);
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ GList* meta_workspace_get_onmonitor_region (MetaWorkspace *workspace,
|
|||||||
int which_monitor);
|
int which_monitor);
|
||||||
|
|
||||||
void meta_workspace_focus_default_window (MetaWorkspace *workspace,
|
void meta_workspace_focus_default_window (MetaWorkspace *workspace,
|
||||||
|
MetaDevice *pointer,
|
||||||
MetaWindow *not_this_one,
|
MetaWindow *not_this_one,
|
||||||
guint32 timestamp);
|
guint32 timestamp);
|
||||||
|
|
||||||
|
@ -687,8 +687,13 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
MetaDevice *pointer;
|
||||||
|
|
||||||
|
pointer = meta_device_map_lookup (screen->display->device_map,
|
||||||
|
META_CORE_POINTER_ID);
|
||||||
meta_topic (META_DEBUG_FOCUS, "Focusing default window on new workspace\n");
|
meta_topic (META_DEBUG_FOCUS, "Focusing default window on new workspace\n");
|
||||||
meta_workspace_focus_default_window (workspace, NULL, timestamp);
|
meta_workspace_focus_default_window (workspace, pointer,
|
||||||
|
NULL, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit switched signal from screen.c */
|
/* Emit switched signal from screen.c */
|
||||||
@ -1205,6 +1210,7 @@ meta_workspace_get_name (MetaWorkspace *workspace)
|
|||||||
|
|
||||||
void
|
void
|
||||||
meta_workspace_focus_default_window (MetaWorkspace *workspace,
|
meta_workspace_focus_default_window (MetaWorkspace *workspace,
|
||||||
|
MetaDevice *pointer,
|
||||||
MetaWindow *not_this_one,
|
MetaWindow *not_this_one,
|
||||||
guint32 timestamp)
|
guint32 timestamp)
|
||||||
{
|
{
|
||||||
@ -1221,7 +1227,8 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MetaWindow * window;
|
MetaWindow * window;
|
||||||
window = meta_screen_get_mouse_window (workspace->screen, not_this_one);
|
window = meta_screen_get_mouse_window (workspace->screen,
|
||||||
|
pointer, not_this_one);
|
||||||
if (window &&
|
if (window &&
|
||||||
window->type != META_WINDOW_DOCK &&
|
window->type != META_WINDOW_DOCK &&
|
||||||
window->type != META_WINDOW_DESKTOP)
|
window->type != META_WINDOW_DESKTOP)
|
||||||
|
@ -1416,9 +1416,11 @@ meta_frame_titlebar_event (MetaUIFrame *frame,
|
|||||||
int action)
|
int action)
|
||||||
{
|
{
|
||||||
MetaFrameFlags flags;
|
MetaFrameFlags flags;
|
||||||
|
GdkDevice *pointer;
|
||||||
Display *display;
|
Display *display;
|
||||||
|
|
||||||
display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
||||||
|
pointer = gdk_event_get_device ((GdkEvent *) event);
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
@ -1501,6 +1503,7 @@ meta_frame_titlebar_event (MetaUIFrame *frame,
|
|||||||
case META_ACTION_TITLEBAR_LOWER:
|
case META_ACTION_TITLEBAR_LOWER:
|
||||||
meta_core_user_lower_and_unfocus (display,
|
meta_core_user_lower_and_unfocus (display,
|
||||||
frame->xwindow,
|
frame->xwindow,
|
||||||
|
gdk_x11_device_get_id (pointer),
|
||||||
event->time);
|
event->time);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user