mirror of
https://github.com/brl/mutter.git
synced 2025-08-05 08:04:50 +00:00
Wrap XSetInputFocus, making display->expected_focus_window a little more
2004-12-22 Elijah Newren <newren@gmail.com> Wrap XSetInputFocus, making display->expected_focus_window a little more reliable (see #154598) * src/display.h: (struct _MetaDisplay): add a large comment about the expected_focus_window, add a last_focus_time field, (XSERVER_TIME_IS_BEFORE): new macro moved from window.c but fixed for 64-bit systems, (meta_display_set_input_focus_window): new function * src/display.c (meta_display_open): initialize last_focus_time, add a comment about brokenness of trying to set intial focus window, (meta_display_set_input_focus_window): new function that wraps XSetInputFocus, (meta_display_focus_the_no_focus_window): make this function closer to a wrapping of XSetInputFocus for the no_focus_window. * src/window.c (XSERVER_TIME_IS_LATER): remove this macro in favor of the improved one added to display.h * src/display.c (meta_display_open): * src/window.c (meta_window_focus): use meta_display_focus_the_no_focus_window and meta_display_set_input_focus instead of XSetInputFocus
This commit is contained in:

committed by
Elijah Newren

parent
e46fc46701
commit
892cb8a8dd
@@ -632,6 +632,7 @@ meta_display_open (const char *name)
|
||||
timestamp = event.xproperty.time;
|
||||
}
|
||||
|
||||
display->last_focus_time = timestamp;
|
||||
display->compositor = meta_compositor_new (display);
|
||||
|
||||
screens = NULL;
|
||||
@@ -676,20 +677,28 @@ meta_display_open (const char *name)
|
||||
/* kinda bogus because GetInputFocus has no possible errors */
|
||||
meta_error_trap_push (display);
|
||||
|
||||
/* FIXME: This is totally broken; see comment 9 of bug 88194 about this */
|
||||
focus = None;
|
||||
ret_to = RevertToPointerRoot;
|
||||
XGetInputFocus (display->xdisplay, &focus, &ret_to);
|
||||
|
||||
/* Force a new FocusIn (does this work?) */
|
||||
if (focus == None || focus == PointerRoot)
|
||||
focus = display->no_focus_window;
|
||||
|
||||
/* Use the same timestamp that was passed to meta_screen_new(),
|
||||
* as it is the most recent timestamp.
|
||||
*/
|
||||
XSetInputFocus (display->xdisplay, focus, RevertToPointerRoot,
|
||||
timestamp);
|
||||
|
||||
if (focus == None || focus == PointerRoot)
|
||||
meta_display_focus_the_no_focus_window (display, timestamp);
|
||||
else
|
||||
{
|
||||
MetaWindow * window;
|
||||
window = meta_display_lookup_x_window (display, focus);
|
||||
if (window)
|
||||
meta_display_set_input_focus_window (display, window, FALSE, timestamp);
|
||||
else
|
||||
meta_display_focus_the_no_focus_window (display, timestamp);
|
||||
}
|
||||
|
||||
meta_error_trap_pop (display, FALSE);
|
||||
}
|
||||
|
||||
@@ -4596,15 +4605,40 @@ meta_display_focus_sentinel_clear (MetaDisplay *display)
|
||||
return (display->sentinel_counter == 0);
|
||||
}
|
||||
|
||||
void
|
||||
meta_display_set_input_focus_window (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
gboolean focus_frame,
|
||||
Time timestamp)
|
||||
{
|
||||
if (XSERVER_TIME_IS_BEFORE (timestamp, display->last_focus_time))
|
||||
return;
|
||||
|
||||
XSetInputFocus (display->xdisplay,
|
||||
focus_frame ? window->frame->xwindow : window->xwindow,
|
||||
RevertToPointerRoot,
|
||||
timestamp);
|
||||
display->expected_focus_window = window;
|
||||
display->last_focus_time = timestamp;
|
||||
|
||||
if (window != display->autoraise_window)
|
||||
meta_display_remove_autoraise_callback (window->display);
|
||||
}
|
||||
|
||||
void
|
||||
meta_display_focus_the_no_focus_window (MetaDisplay *display,
|
||||
Time timestamp)
|
||||
{
|
||||
if (XSERVER_TIME_IS_BEFORE (timestamp, display->last_focus_time))
|
||||
return;
|
||||
|
||||
XSetInputFocus (display->xdisplay,
|
||||
display->no_focus_window,
|
||||
RevertToPointerRoot,
|
||||
timestamp);
|
||||
display->expected_focus_window = NULL;
|
||||
display->last_focus_time = timestamp;
|
||||
|
||||
meta_display_remove_autoraise_callback (display);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user