mirror of
https://github.com/brl/mutter.git
synced 2025-08-06 08:34:41 +00:00
x11/window-controls: Pass around MetaX11Display directly
Instead of passing around an X11 Display pointer that is retrieved from the default Gdk backend, then finding the MetaX11Display from said X11 Display, pass the MetaX11Display directly. https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
This commit is contained in:

committed by
Florian Müllner

parent
da213febdc
commit
e17d70a592
@@ -253,6 +253,8 @@ void meta_x11_display_set_input_focus (MetaX11Display *x11_display,
|
||||
gboolean focus_frame,
|
||||
uint32_t timestamp);
|
||||
|
||||
MetaDisplay * meta_x11_display_get_display (MetaX11Display *x11_display);
|
||||
|
||||
const gchar * meta_x11_get_display_name (void);
|
||||
|
||||
#endif /* META_X11_DISPLAY_PRIVATE_H */
|
||||
|
@@ -1407,6 +1407,12 @@ meta_x11_display_get_screen_number (MetaX11Display *x11_display)
|
||||
return DefaultScreen (x11_display->xdisplay);
|
||||
}
|
||||
|
||||
MetaDisplay *
|
||||
meta_x11_display_get_display (MetaX11Display *x11_display)
|
||||
{
|
||||
return x11_display->display;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_x11_display_get_xdisplay: (skip)
|
||||
* @x11_display: a #MetaX11Display
|
||||
|
@@ -35,28 +35,14 @@
|
||||
#include "x11/window-x11-private.h"
|
||||
#include "x11/window-x11.h"
|
||||
|
||||
/* Looks up the MetaWindow representing the frame of the given X window.
|
||||
* Used as a helper function by a bunch of the functions below.
|
||||
*
|
||||
* FIXME: The functions that use this function throw the result away
|
||||
* after use. Many of these functions tend to be called in small groups,
|
||||
* which results in get_window() getting called several times in succession
|
||||
* with the same parameters. We should profile to see whether this wastes
|
||||
* much time, and if it does we should look into a generalised
|
||||
* meta_core_get_window_info() which takes a bunch of pointers to variables
|
||||
* to put its results in, and only fills in the non-null ones.
|
||||
*/
|
||||
static MetaWindow *
|
||||
get_window (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
window_from_frame (MetaX11Display *x11_display,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
MetaWindow *window;
|
||||
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
window = meta_x11_display_lookup_x_window (display->x11_display, frame_xwindow);
|
||||
|
||||
if (window == NULL || window->frame == NULL)
|
||||
window = meta_x11_display_lookup_x_window (x11_display, frame_xwindow);
|
||||
if (!window || !window->frame)
|
||||
{
|
||||
meta_bug ("No such frame window 0x%lx!\n", frame_xwindow);
|
||||
return NULL;
|
||||
@@ -66,10 +52,10 @@ get_window (Display *xdisplay,
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_queue_frame_resize (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
meta_x11_wm_queue_frame_resize (MetaX11Display *x11_display,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
MetaWindow *window = window_from_frame (x11_display, frame_xwindow);
|
||||
|
||||
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
|
||||
meta_window_frame_size_changed (window);
|
||||
@@ -115,11 +101,11 @@ lower_window_and_transients (MetaWindow *window,
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_user_lower_and_unfocus (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
guint32 timestamp)
|
||||
meta_x11_wm_user_lower_and_unfocus (MetaX11Display *x11_display,
|
||||
Window frame_xwindow,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
MetaWindow *window = window_from_frame (x11_display, frame_xwindow);
|
||||
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
|
||||
|
||||
lower_window_and_transients (window, NULL);
|
||||
@@ -134,10 +120,10 @@ meta_core_user_lower_and_unfocus (Display *xdisplay,
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_toggle_maximize_vertically (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
meta_x11_wm_toggle_maximize_vertically (MetaX11Display *x11_display,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
MetaWindow *window = window_from_frame (x11_display, frame_xwindow);
|
||||
|
||||
if (meta_prefs_get_raise_on_click ())
|
||||
meta_window_raise (window);
|
||||
@@ -149,10 +135,10 @@ meta_core_toggle_maximize_vertically (Display *xdisplay,
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_toggle_maximize_horizontally (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
meta_x11_wm_toggle_maximize_horizontally (MetaX11Display *x11_display,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
MetaWindow *window = window_from_frame (x11_display, frame_xwindow);
|
||||
|
||||
if (meta_prefs_get_raise_on_click ())
|
||||
meta_window_raise (window);
|
||||
@@ -164,10 +150,10 @@ meta_core_toggle_maximize_horizontally (Display *xdisplay,
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_toggle_maximize (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
meta_x11_wm_toggle_maximize (MetaX11Display *x11_display,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
MetaWindow *window = window_from_frame (x11_display, frame_xwindow);
|
||||
|
||||
if (meta_prefs_get_raise_on_click ())
|
||||
meta_window_raise (window);
|
||||
@@ -179,14 +165,14 @@ meta_core_toggle_maximize (Display *xdisplay,
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_show_window_menu (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
MetaWindowMenuType menu,
|
||||
int root_x,
|
||||
int root_y,
|
||||
guint32 timestamp)
|
||||
meta_x11_wm_show_window_menu (MetaX11Display *x11_display,
|
||||
Window frame_xwindow,
|
||||
MetaWindowMenuType menu,
|
||||
int root_x,
|
||||
int root_y,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
MetaWindow *window = window_from_frame (x11_display, frame_xwindow);
|
||||
|
||||
if (meta_prefs_get_raise_on_click ())
|
||||
meta_window_raise (window);
|
||||
@@ -196,13 +182,13 @@ meta_core_show_window_menu (Display *xdisplay,
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_show_window_menu_for_rect (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
MetaWindowMenuType menu,
|
||||
MetaRectangle *rect,
|
||||
guint32 timestamp)
|
||||
meta_x11_wm_show_window_menu_for_rect (MetaX11Display *x11_display,
|
||||
Window frame_xwindow,
|
||||
MetaWindowMenuType menu,
|
||||
MetaRectangle *rect,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
MetaWindow *window = window_from_frame (x11_display, frame_xwindow);
|
||||
|
||||
if (meta_prefs_get_raise_on_click ())
|
||||
meta_window_raise (window);
|
||||
@@ -212,21 +198,21 @@ meta_core_show_window_menu_for_rect (Display *xdisplay,
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_core_begin_grab_op (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
MetaGrabOp op,
|
||||
gboolean pointer_already_grabbed,
|
||||
gboolean frame_action,
|
||||
int button,
|
||||
gulong modmask,
|
||||
guint32 timestamp,
|
||||
int root_x,
|
||||
int root_y)
|
||||
meta_x11_wm_begin_grab_op (MetaX11Display *x11_display,
|
||||
Window frame_xwindow,
|
||||
MetaGrabOp op,
|
||||
gboolean pointer_already_grabbed,
|
||||
gboolean frame_action,
|
||||
int button,
|
||||
gulong modmask,
|
||||
uint32_t timestamp,
|
||||
int root_x,
|
||||
int root_y)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
MetaWindow *window = window_from_frame (x11_display, frame_xwindow);
|
||||
MetaDisplay *display;
|
||||
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
display = meta_x11_display_get_display (x11_display);
|
||||
|
||||
return meta_display_begin_grab_op (display, window,
|
||||
op, pointer_already_grabbed,
|
||||
@@ -236,44 +222,44 @@ meta_core_begin_grab_op (Display *xdisplay,
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_end_grab_op (Display *xdisplay,
|
||||
guint32 timestamp)
|
||||
meta_x11_wm_end_grab_op (MetaX11Display *x11_display,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
display = meta_x11_display_get_display (x11_display);
|
||||
|
||||
meta_display_end_grab_op (display, timestamp);
|
||||
}
|
||||
|
||||
MetaGrabOp
|
||||
meta_core_get_grab_op (Display *xdisplay)
|
||||
meta_x11_wm_get_grab_op (MetaX11Display *x11_display)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
display = meta_x11_display_get_display (x11_display);
|
||||
|
||||
return display->grab_op;
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_grab_buttons (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
meta_x11_wm_grab_buttons (MetaX11Display *x11_display,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
display = meta_x11_display_get_display (x11_display);
|
||||
|
||||
meta_verbose ("Grabbing buttons on frame 0x%lx\n", frame_xwindow);
|
||||
meta_display_grab_window_buttons (display, frame_xwindow);
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_set_screen_cursor (Display *xdisplay,
|
||||
Window frame_on_screen,
|
||||
MetaCursor cursor)
|
||||
meta_x11_wm_set_screen_cursor (MetaX11Display *x11_display,
|
||||
Window frame_on_screen,
|
||||
MetaCursor cursor)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_on_screen);
|
||||
MetaWindow *window = window_from_frame (x11_display, frame_on_screen);
|
||||
|
||||
meta_frame_set_screen_cursor (window->frame, cursor);
|
||||
}
|
||||
|
@@ -27,54 +27,55 @@
|
||||
|
||||
#include "meta/boxes.h"
|
||||
#include "meta/common.h"
|
||||
#include "x11/meta-x11-display-private.h"
|
||||
|
||||
void meta_core_queue_frame_resize (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
void meta_x11_wm_queue_frame_resize (MetaX11Display *x11_display,
|
||||
Window frame_xwindow);
|
||||
|
||||
void meta_core_user_lower_and_unfocus (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
guint32 timestamp);
|
||||
void meta_x11_wm_user_lower_and_unfocus (MetaX11Display *x11_display,
|
||||
Window frame_xwindow,
|
||||
uint32_t timestamp);
|
||||
|
||||
void meta_core_toggle_maximize (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
void meta_core_toggle_maximize_horizontally (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
void meta_core_toggle_maximize_vertically (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
void meta_x11_wm_toggle_maximize (MetaX11Display *x11_display,
|
||||
Window frame_xwindow);
|
||||
void meta_x11_wm_toggle_maximize_horizontally (MetaX11Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
void meta_x11_wm_toggle_maximize_vertically (MetaX11Display *x11_display,
|
||||
Window frame_xwindow);
|
||||
|
||||
void meta_core_show_window_menu (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
MetaWindowMenuType menu,
|
||||
int root_x,
|
||||
int root_y,
|
||||
guint32 timestamp);
|
||||
void meta_x11_wm_show_window_menu (MetaX11Display *x11_xdisplay,
|
||||
Window frame_xwindow,
|
||||
MetaWindowMenuType menu,
|
||||
int root_x,
|
||||
int root_y,
|
||||
uint32_t timestamp);
|
||||
|
||||
void meta_core_show_window_menu_for_rect (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
MetaWindowMenuType menu,
|
||||
MetaRectangle *rect,
|
||||
guint32 timestamp);
|
||||
void meta_x11_wm_show_window_menu_for_rect (MetaX11Display *x11_display,
|
||||
Window frame_xwindow,
|
||||
MetaWindowMenuType menu,
|
||||
MetaRectangle *rect,
|
||||
uint32_t timestamp);
|
||||
|
||||
gboolean meta_core_begin_grab_op (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
MetaGrabOp op,
|
||||
gboolean pointer_already_grabbed,
|
||||
gboolean frame_action,
|
||||
int button,
|
||||
gulong modmask,
|
||||
guint32 timestamp,
|
||||
int root_x,
|
||||
int root_y);
|
||||
void meta_core_end_grab_op (Display *xdisplay,
|
||||
guint32 timestamp);
|
||||
MetaGrabOp meta_core_get_grab_op (Display *xdisplay);
|
||||
gboolean meta_x11_wm_begin_grab_op (MetaX11Display *x11_display,
|
||||
Window frame_xwindow,
|
||||
MetaGrabOp op,
|
||||
gboolean pointer_already_grabbed,
|
||||
gboolean frame_action,
|
||||
int button,
|
||||
gulong modmask,
|
||||
uint32_t timestamp,
|
||||
int root_x,
|
||||
int root_y);
|
||||
void meta_x11_wm_end_grab_op (MetaX11Display *x11_display,
|
||||
uint32_t timestamp);
|
||||
MetaGrabOp meta_x11_wm_get_grab_op (MetaX11Display *x11_display);
|
||||
|
||||
|
||||
void meta_core_grab_buttons (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
void meta_x11_wm_grab_buttons (MetaX11Display *x11_display,
|
||||
Window frame_xwindow);
|
||||
|
||||
void meta_core_set_screen_cursor (Display *xdisplay,
|
||||
Window frame_on_screen,
|
||||
MetaCursor cursor);
|
||||
void meta_x11_wm_set_screen_cursor (MetaX11Display *x11_display,
|
||||
Window frame_on_screen,
|
||||
MetaCursor cursor);
|
||||
|
||||
#endif /* META_X11_WINDOW_CONTROL_H */
|
||||
|
Reference in New Issue
Block a user