mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
compositor/x11: Move stage input region setting to MetaX11Display
It doesn't use anything specific to MetaCompositor, and MetaCompositorX11 isn't exposed, so move it to MetaX11Display. https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
This commit is contained in:
parent
984aad4b86
commit
8ee00cee60
@ -97,61 +97,6 @@ meta_compositor_x11_process_xevent (MetaCompositorX11 *compositor_x11,
|
||||
clutter_x11_handle_event (xevent);
|
||||
}
|
||||
|
||||
void
|
||||
meta_set_stage_input_region (MetaDisplay *display,
|
||||
XserverRegion region)
|
||||
{
|
||||
MetaCompositor *compositor = display->compositor;
|
||||
MetaCompositorX11 *compositor_x11 = META_COMPOSITOR_X11 (display->compositor);
|
||||
Display *xdisplay = meta_x11_display_get_xdisplay (display->x11_display);
|
||||
ClutterStage *stage = meta_compositor_get_stage (compositor);
|
||||
Window xstage;
|
||||
|
||||
/*
|
||||
* As a wayland compositor we can simply ignore all this trickery
|
||||
* for setting an input region on the stage for capturing events in
|
||||
* clutter since all input comes to us first and we get to choose
|
||||
* who else sees them.
|
||||
*/
|
||||
if (meta_is_wayland_compositor ())
|
||||
return;
|
||||
|
||||
xstage = clutter_x11_get_stage_window (stage);
|
||||
XFixesSetWindowShapeRegion (xdisplay, xstage, ShapeInput, 0, 0, region);
|
||||
|
||||
/*
|
||||
* It's generally a good heuristic that when a crossing event is generated
|
||||
* because we reshape the overlay, we don't want it to affect
|
||||
* focus-follows-mouse focus - it's not the user doing something, it's the
|
||||
* environment changing under the user.
|
||||
*/
|
||||
meta_display_add_ignored_crossing_serial (display, XNextRequest (xdisplay));
|
||||
XFixesSetWindowShapeRegion (xdisplay, compositor_x11->output,
|
||||
ShapeInput, 0, 0, region);
|
||||
}
|
||||
|
||||
void
|
||||
meta_empty_stage_input_region (MetaDisplay *display)
|
||||
{
|
||||
/*
|
||||
* Using a static region here is a bit hacky, but when running as X11
|
||||
* compositing manager we only ever open a single XDisplay.
|
||||
*/
|
||||
static XserverRegion region = None;
|
||||
|
||||
if (meta_is_wayland_compositor ())
|
||||
return;
|
||||
|
||||
if (region == None)
|
||||
{
|
||||
Display *xdisplay = meta_x11_display_get_xdisplay (display->x11_display);
|
||||
|
||||
region = XFixesCreateRegion (xdisplay, NULL, 0);
|
||||
}
|
||||
|
||||
meta_set_stage_input_region (display, region);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_compositor_x11_manage (MetaCompositor *compositor)
|
||||
{
|
||||
@ -167,7 +112,7 @@ meta_compositor_x11_manage (MetaCompositor *compositor)
|
||||
|
||||
XReparentWindow (xdisplay, xwindow, compositor_x11->output, 0, 0);
|
||||
|
||||
meta_empty_stage_input_region (display);
|
||||
meta_x11_display_clear_stage_input_region (display->x11_display);
|
||||
|
||||
/*
|
||||
* Make sure there isn't any left-over output shape on the overlay window by
|
||||
|
@ -23,9 +23,6 @@
|
||||
#ifndef MUTTER_H_
|
||||
#define MUTTER_H_
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
|
||||
#include "clutter/clutter.h"
|
||||
#include "meta/compositor.h"
|
||||
#include "meta/meta-window-actor.h"
|
||||
@ -53,13 +50,6 @@ void meta_disable_unredirect_for_display (MetaDisplay *display);
|
||||
META_EXPORT
|
||||
void meta_enable_unredirect_for_display (MetaDisplay *display);
|
||||
|
||||
META_EXPORT
|
||||
void meta_set_stage_input_region (MetaDisplay *display,
|
||||
XserverRegion region);
|
||||
|
||||
META_EXPORT
|
||||
void meta_empty_stage_input_region (MetaDisplay *display);
|
||||
|
||||
META_EXPORT
|
||||
void meta_focus_stage_window (MetaDisplay *display,
|
||||
guint32 timestamp);
|
||||
|
@ -63,4 +63,11 @@ META_EXPORT
|
||||
gboolean meta_x11_display_xwindow_is_a_no_focus_window (MetaX11Display *x11_display,
|
||||
Window xwindow);
|
||||
|
||||
META_EXPORT
|
||||
void meta_x11_display_set_stage_input_region (MetaX11Display *x11_display,
|
||||
XserverRegion region);
|
||||
|
||||
META_EXPORT
|
||||
void meta_x11_display_clear_stage_input_region (MetaX11Display *x11_display);
|
||||
|
||||
#endif /* META_X11_DISPLAY_H */
|
||||
|
@ -179,6 +179,8 @@ struct _MetaX11Display
|
||||
|
||||
MetaX11StartupNotification *startup_notification;
|
||||
MetaX11Stack *x11_stack;
|
||||
|
||||
XserverRegion empty_region;
|
||||
};
|
||||
|
||||
MetaX11Display *meta_x11_display_new (MetaDisplay *display, GError **error);
|
||||
|
@ -131,6 +131,13 @@ meta_x11_display_dispose (GObject *object)
|
||||
|
||||
x11_display->closing = TRUE;
|
||||
|
||||
if (x11_display->empty_region != None)
|
||||
{
|
||||
XFixesDestroyRegion (x11_display->xdisplay,
|
||||
x11_display->empty_region);
|
||||
x11_display->empty_region = None;
|
||||
}
|
||||
|
||||
meta_x11_startup_notification_release (x11_display);
|
||||
|
||||
meta_prefs_remove_listener (prefs_changed_callback, x11_display);
|
||||
@ -2207,3 +2214,44 @@ meta_x11_display_focus_sentinel_clear (MetaX11Display *x11_display)
|
||||
{
|
||||
return (x11_display->sentinel_counter == 0);
|
||||
}
|
||||
|
||||
void
|
||||
meta_x11_display_set_stage_input_region (MetaX11Display *x11_display,
|
||||
XserverRegion region)
|
||||
{
|
||||
Display *xdisplay = x11_display->xdisplay;
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
|
||||
Window stage_xwindow;
|
||||
|
||||
g_return_if_fail (!meta_is_wayland_compositor ());
|
||||
|
||||
stage_xwindow = clutter_x11_get_stage_window (stage);
|
||||
XFixesSetWindowShapeRegion (xdisplay, stage_xwindow,
|
||||
ShapeInput, 0, 0, region);
|
||||
|
||||
/*
|
||||
* It's generally a good heuristic that when a crossing event is generated
|
||||
* because we reshape the overlay, we don't want it to affect
|
||||
* focus-follows-mouse focus - it's not the user doing something, it's the
|
||||
* environment changing under the user.
|
||||
*/
|
||||
meta_display_add_ignored_crossing_serial (x11_display->display,
|
||||
XNextRequest (xdisplay));
|
||||
XFixesSetWindowShapeRegion (xdisplay,
|
||||
x11_display->composite_overlay_window,
|
||||
ShapeInput, 0, 0, region);
|
||||
}
|
||||
|
||||
void
|
||||
meta_x11_display_clear_stage_input_region (MetaX11Display *x11_display)
|
||||
{
|
||||
if (x11_display->empty_region == None)
|
||||
{
|
||||
x11_display->empty_region = XFixesCreateRegion (x11_display->xdisplay,
|
||||
NULL, 0);
|
||||
}
|
||||
|
||||
meta_x11_display_set_stage_input_region (x11_display,
|
||||
x11_display->empty_region);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user