Apply patch from Gregory Merchan to avoid using CurrentTime when setting

2003-11-24  Havoc Pennington  <hp@redhat.com>

	* Apply patch from Gregory Merchan to avoid using CurrentTime when
	setting input focus. Bug #108881
This commit is contained in:
Havoc Pennington 2003-11-24 17:47:48 +00:00 committed by Havoc Pennington
parent 927a6def1b
commit feefcdd892
6 changed files with 85 additions and 59 deletions

View File

@ -1,3 +1,8 @@
2003-11-24 Havoc Pennington <hp@redhat.com>
* Apply patch from Gregory Merchan to avoid using CurrentTime when
setting input focus. Bug #108881
2003-11-23 Havoc Pennington <hp@redhat.com>
* src/compositor.c: move xcompmgr code in here (minus drop

View File

@ -123,9 +123,10 @@ meta_compositor_new (MetaDisplay *display)
{
compositor->composite_event_base = 0;
compositor->composite_error_base = 0;
meta_verbose ("XCompositeQueryExtension() returned FALSE\n");
}
meta_verbose ("Composite extension event base %d error base %d",
meta_verbose ("Composite extension event base %d error base %d\n",
compositor->composite_event_base,
compositor->composite_error_base);
@ -137,7 +138,7 @@ meta_compositor_new (MetaDisplay *display)
compositor->damage_error_base = 0;
}
meta_verbose ("Damage extension event base %d error base %d",
meta_verbose ("Damage extension event base %d error base %d\n",
compositor->damage_event_base,
compositor->damage_error_base);
@ -149,7 +150,7 @@ meta_compositor_new (MetaDisplay *display)
compositor->fixes_error_base = 0;
}
meta_verbose ("Fixes extension event base %d error base %d",
meta_verbose ("Fixes extension event base %d error base %d\n",
compositor->fixes_event_base,
compositor->fixes_error_base);
@ -161,7 +162,7 @@ meta_compositor_new (MetaDisplay *display)
compositor->render_error_base = 0;
}
meta_verbose ("Render extension event base %d error base %d",
meta_verbose ("Render extension event base %d error base %d\n",
compositor->render_event_base,
compositor->render_error_base);
@ -209,7 +210,8 @@ meta_compositor_unref (MetaCompositor *compositor)
*/
remove_repair_idle (compositor);
g_hash_table_destroy (compositor->window_hash);
if (compositor->window_hash)
g_hash_table_destroy (compositor->window_hash);
g_free (compositor);
#endif /* HAVE_COMPOSITE_EXTENSIONS */
@ -599,8 +601,6 @@ meta_compositor_add_window (MetaCompositor *compositor,
XRenderPictFormat *format;
XRenderPictureAttributes pa;
g_print ("compositor adding window 0x%lx\n", xwindow);
if (!compositor->enabled)
return; /* no extension */
@ -669,8 +669,6 @@ meta_compositor_remove_window (MetaCompositor *compositor,
MetaCompositorWindow *cwindow;
MetaScreen *screen;
g_print ("compositor removing window 0x%lx\n", xwindow);
if (!compositor->enabled)
return; /* no extension */
@ -716,6 +714,14 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
g_assert (screen->root_picture == None);
/* FIXME add flag for whether we're composite-managing each
* screen and detect failure here
*/
XCompositeRedirectSubwindows (screen->display->xdisplay,
screen->xroot,
CompositeRedirectManual);
g_print ("Subwindows redirected\n");
pa.subwindow_mode = IncludeInferiors;
screen->root_picture =

View File

@ -187,6 +187,7 @@ meta_display_open (const char *name)
GSList *screens;
GSList *tmp;
int i;
Time timestamp;
/* Remember to edit code that assigns each atom to display struct
* when adding an atom name here.
*/
@ -532,6 +533,41 @@ meta_display_open (const char *name)
meta_verbose ("Not compiled with Shape support\n");
#endif /* !HAVE_SHAPE */
/* Create the leader window here. Set its properties and
* use the timestamp from one of the PropertyNotify events
* that will follow.
*/
{
XSetWindowAttributes attrs;
gulong data[1];
XEvent event;
attrs.event_mask = PropertyChangeMask;
attrs.override_redirect = True;
display->leader_window = meta_create_offscreen_window (display->xdisplay,
DefaultRootWindow (display->xdisplay));
set_utf8_string_hint (display,
display->leader_window,
display->atom_net_wm_name,
"Metacity");
data[0] = display->leader_window;
XChangeProperty (display->xdisplay,
display->leader_window,
display->atom_net_supporting_wm_check,
XA_WINDOW,
32, PropModeReplace, (guchar*) data, 1);
XWindowEvent (display->xdisplay,
display->leader_window,
PropertyChangeMask,
&event);
timestamp = event.xproperty.time;
}
display->compositor = meta_compositor_new (display);
screens = NULL;
@ -541,7 +577,7 @@ meta_display_open (const char *name)
{
MetaScreen *screen;
screen = meta_screen_new (display, i);
screen = meta_screen_new (display, i, timestamp);
if (screen)
screens = g_slist_prepend (screens, screen);
@ -559,25 +595,6 @@ meta_display_open (const char *name)
return FALSE;
}
/* display->leader_window was created as a side effect of
* initializing the screens
*/
set_utf8_string_hint (display,
display->leader_window,
display->atom_net_wm_name,
"Metacity");
{
gulong data[1];
data[0] = display->leader_window;
XChangeProperty (display->xdisplay,
display->leader_window,
display->atom_net_supporting_wm_check,
XA_WINDOW,
32, PropModeReplace, (guchar*) data, 1);
}
meta_display_grab (display);
/* Now manage all existing windows */
@ -603,9 +620,11 @@ meta_display_open (const char *name)
if (focus == None || focus == PointerRoot)
focus = display->no_focus_window;
/* FIXME CurrentTime evil */
/* Use the same timestamp that was passed to meta_screen_new(),
* as it is the most recent timestamp.
*/
XSetInputFocus (display->xdisplay, focus, RevertToPointerRoot,
CurrentTime);
timestamp);
meta_error_trap_pop (display, FALSE);
}
@ -1616,14 +1635,28 @@ event_callback (XEvent *event,
if (event->type == FocusIn &&
event->xfocus.detail == NotifyDetailNone)
{
XEvent property_event;
/* FIXME _() gettextify on HEAD */
meta_warning ("Working around an application which called XSetInputFocus (None) or with RevertToNone instead of RevertToPointerRoot, this is a minor bug in some application. If you can figure out which application causes this please report it as a bug against that application.\n");
/* Fix the problem */
/* Using the property XA_PRIMARY because it's safe;
* nothing would use it as a property. The type
* doesn't matter.
*/
XChangeProperty (display->xdisplay,
display->leader_window,
XA_PRIMARY, XA_STRING, 8,
PropModeAppend, NULL, 0);
XWindowEvent (display->xdisplay,
display->leader_window,
PropertyChangeMask,
&property_event);
XSetInputFocus (display->xdisplay,
display->no_focus_window,
RevertToPointerRoot,
CurrentTime); /* CurrentTime FIXME */
property_event.xproperty.time);
}
}
break;

View File

@ -376,7 +376,8 @@ reload_xinerama_infos (MetaScreen *screen)
MetaScreen*
meta_screen_new (MetaDisplay *display,
int number)
int number,
Time timestamp)
{
MetaScreen *screen;
Window xroot;
@ -442,24 +443,7 @@ meta_screen_new (MetaDisplay *display,
new_wm_sn_owner = meta_create_offscreen_window (xdisplay, xroot);
{
/* Generate a timestamp */
XSetWindowAttributes attrs;
XEvent event;
attrs.event_mask = PropertyChangeMask;
XChangeWindowAttributes (xdisplay, new_wm_sn_owner, CWEventMask, &attrs);
XChangeProperty (xdisplay,
new_wm_sn_owner, XA_WM_CLASS, XA_STRING, 8,
PropModeAppend, NULL, 0);
XWindowEvent (xdisplay, new_wm_sn_owner, PropertyChangeMask, &event);
attrs.event_mask = NoEventMask;
XChangeWindowAttributes (display->xdisplay,
new_wm_sn_owner, CWEventMask, &attrs);
manager_timestamp = event.xproperty.time;
}
manager_timestamp = timestamp;
XSetSelectionOwner (xdisplay, wm_sn_atom, new_wm_sn_owner,
manager_timestamp);
@ -561,6 +545,7 @@ meta_screen_new (MetaDisplay *display,
screen->compositor_windows = NULL;
screen->damage_region = None;
screen->root_picture = None;
{
XGCValues gc_values;
@ -583,10 +568,6 @@ meta_screen_new (MetaDisplay *display,
meta_screen_set_cursor (screen, META_CURSOR_DEFAULT);
if (display->leader_window == None)
display->leader_window = meta_create_offscreen_window (display->xdisplay,
screen->xroot);
if (display->no_focus_window == None)
{
display->no_focus_window = meta_create_offscreen_window (display->xdisplay,

View File

@ -121,7 +121,8 @@ struct _MetaScreen
};
MetaScreen* meta_screen_new (MetaDisplay *display,
int number);
int number,
Time timestamp);
void meta_screen_free (MetaScreen *screen);
void meta_screen_manage_all_windows (MetaScreen *screen);
MetaScreen* meta_screen_for_x_screen (Screen *xscreen);

View File

@ -3126,7 +3126,7 @@ meta_window_focus (MetaWindow *window,
XSetInputFocus (window->display->xdisplay,
window->frame->xwindow,
RevertToPointerRoot,
CurrentTime);
timestamp);
window->display->expected_focus_window = window;
}
}