[mutter/bilelmoussaoui/x11-frame-guard: 2/2] core/frame: Guard X11 Frame usage
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/bilelmoussaoui/x11-frame-guard: 2/2] core/frame: Guard X11 Frame usage
- Date: Wed, 1 Jun 2022 13:02:51 +0000 (UTC)
commit 1de90530fd9436c07e7f1ea57082b96d3362ceea
Author: Bilal Elmoussaoui <belmouss redhat com>
Date: Wed Jun 1 15:02:37 2022 +0200
core/frame: Guard X11 Frame usage
src/compositor/compositor.c | 2 +-
src/core/bell.h | 1 -
src/core/constraints.c | 8 ++++
src/core/constraints.h | 1 -
src/core/display.c | 6 ++-
src/core/events.c | 5 ++-
src/core/keybindings.c | 7 +++-
src/core/place.h | 1 -
src/core/stack.c | 11 +++--
src/core/window.c | 56 +++++++++++++++++++++-----
src/meson.build | 4 +-
src/wayland/meta-wayland-pointer-constraints.c | 13 +++---
src/x11/events.c | 4 ++
13 files changed, 89 insertions(+), 30 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index d17a047b86..b8ceb50c73 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -59,7 +59,6 @@
#include "compositor/meta-later-private.h"
#include "compositor/meta-window-actor-private.h"
#include "compositor/meta-window-group-private.h"
-#include "core/frame.h"
#include "core/util-private.h"
#include "core/window-private.h"
#include "meta/compositor-mutter.h"
@@ -85,6 +84,7 @@
#include "backends/x11/meta-stage-x11.h"
#include "compositor/meta-window-actor-x11.h"
+#include "core/frame.h"
#include "meta/meta-x11-errors.h"
#include "x11/meta-x11-display-private.h"
diff --git a/src/core/bell.h b/src/core/bell.h
index f86cbb7c2c..29f4044764 100644
--- a/src/core/bell.h
+++ b/src/core/bell.h
@@ -18,7 +18,6 @@
*/
#include "core/display-private.h"
-#include "core/frame.h"
struct _MetaBell
{
diff --git a/src/core/constraints.c b/src/core/constraints.c
index f5729354f0..d54d818494 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -37,6 +37,10 @@
#include "core/workspace-private.h"
#include "meta/prefs.h"
+#ifdef HAVE_X11_CLIENT
+#include "core/frame.h"
+#endif
+
#if 0
// This is the short and sweet version of how to hack on this file; see
// doc/how-constraints-works.txt for the gory details. The basics of
@@ -1794,6 +1798,7 @@ constrain_titlebar_visible (MetaWindow *window,
/* Allow the titlebar to touch the bottom panel; If there is no titlebar,
* require vert_amount to remain on the screen.
*/
+#ifdef HAVE_X11_CLIENT
if (window->frame)
{
MetaFrameBorders borders;
@@ -1803,6 +1808,7 @@ constrain_titlebar_visible (MetaWindow *window,
vert_amount_onscreen = borders.visible.top;
}
else
+#endif
bottom_amount = vert_amount_offscreen;
/* Extend the region, have a helper function handle the constraint,
@@ -1873,6 +1879,7 @@ constrain_partially_onscreen (MetaWindow *window,
/* Allow the titlebar to touch the bottom panel; If there is no titlebar,
* require vert_amount to remain on the screen.
*/
+#ifdef HAVE_X11_CLIENT
if (window->frame)
{
MetaFrameBorders borders;
@@ -1882,6 +1889,7 @@ constrain_partially_onscreen (MetaWindow *window,
vert_amount_onscreen = borders.visible.top;
}
else
+#endif
bottom_amount = vert_amount_offscreen;
/* Extend the region, have a helper function handle the constraint,
diff --git a/src/core/constraints.h b/src/core/constraints.h
index eaa4e45940..f947dfae5a 100644
--- a/src/core/constraints.h
+++ b/src/core/constraints.h
@@ -23,7 +23,6 @@
#ifndef META_CONSTRAINTS_H
#define META_CONSTRAINTS_H
-#include "core/frame.h"
#include "core/window-private.h"
#include "meta/util.h"
diff --git a/src/core/display.c b/src/core/display.c
index 54088183af..7413404513 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -55,7 +55,6 @@
#include "core/boxes-private.h"
#include "core/display-private.h"
#include "core/events.h"
-#include "core/frame.h"
#include "core/keybindings-private.h"
#include "core/meta-clipboard-manager.h"
#include "core/meta-workspace-manager-private.h"
@@ -77,6 +76,8 @@
#include "backends/x11/cm/meta-backend-x11-cm.h"
#include "backends/x11/nested/meta-backend-x11-nested.h"
#include "compositor/meta-compositor-x11.h"
+#include "core/frame.h"
+
#include "meta/meta-x11-errors.h"
#include "x11/meta-startup-notification-x11.h"
#include "x11/meta-x11-display-private.h"
@@ -2147,12 +2148,13 @@ meta_display_queue_retheme_all_windows (MetaDisplay *display)
MetaWindow *window = tmp->data;
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
+#ifdef HAVE_X11_CLIENT
meta_window_frame_size_changed (window);
if (window->frame)
{
meta_frame_queue_draw (window->frame);
}
-
+#endif
tmp = tmp->next;
}
diff --git a/src/core/events.c b/src/core/events.c
index cd583b4153..4c146dfa1e 100644
--- a/src/core/events.c
+++ b/src/core/events.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "core/events.h"
-#include "core/frame.h"
#include "backends/meta-cursor-tracker-private.h"
#include "backends/meta-dnd-private.h"
@@ -37,6 +36,8 @@
#ifdef HAVE_X11_CLIENT
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-input-device-x11.h"
+
+#include "core/frame.h"
#endif
#ifdef HAVE_NATIVE_BACKEND
@@ -482,12 +483,14 @@ meta_display_handle_event (MetaDisplay *display,
* event to Wayland if it was handled by the frame UI.
* See: https://gitlab.gnome.org/GNOME/mutter/issues/88
*/
+#ifdef HAVE_X11_CLIENT
if (meta_frame_handle_event (window->frame, event))
{
bypass_wayland = (event->type == CLUTTER_BUTTON_PRESS ||
event->type == CLUTTER_TOUCH_BEGIN);
}
else
+#endif
{
bypass_wayland = meta_window_has_modals (window);
meta_window_handle_ungrabbed_event (window, event);
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 975e68897a..5045e7c22f 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -37,7 +37,6 @@
#include "backends/x11/meta-input-device-x11.h"
#include "compositor/compositor-private.h"
#include "core/edge-resistance.h"
-#include "core/frame.h"
#include "core/keybindings-private.h"
#include "core/meta-accel-parse.h"
#include "core/meta-workspace-manager-private.h"
@@ -48,6 +47,10 @@
#include "x11/meta-x11-display-private.h"
#include "x11/window-x11.h"
+#ifdef HAVE_X11_CLIENT
+#include "core/frame.h"
+#endif
+
#ifdef HAVE_NATIVE_BACKEND
#include "backends/native/meta-backend-native.h"
#endif
@@ -1622,6 +1625,7 @@ meta_window_grab_keys (MetaWindow *window)
void
meta_window_ungrab_keys (MetaWindow *window)
{
+#ifdef HAVE_X11_CLIENT
if (!meta_is_wayland_compositor () && window->keys_grabbed)
{
MetaDisplay *display = window->display;
@@ -1635,6 +1639,7 @@ meta_window_ungrab_keys (MetaWindow *window)
window->keys_grabbed = FALSE;
}
+#endif
}
static void
diff --git a/src/core/place.h b/src/core/place.h
index 2e2c811413..c73d664cb4 100644
--- a/src/core/place.h
+++ b/src/core/place.h
@@ -22,7 +22,6 @@
#ifndef META_PLACE_H
#define META_PLACE_H
-#include "core/frame.h"
#include "core/window-private.h"
void meta_window_process_placement (MetaWindow *window,
diff --git a/src/core/stack.c b/src/core/stack.c
index 481e722327..efb810914d 100644
--- a/src/core/stack.c
+++ b/src/core/stack.c
@@ -31,7 +31,6 @@
#include "backends/meta-logical-monitor.h"
#include "cogl/cogl.h"
-#include "core/frame.h"
#include "core/meta-workspace-manager-private.h"
#include "core/window-private.h"
#include "core/workspace-private.h"
@@ -40,6 +39,10 @@
#include "meta/workspace.h"
#include "x11/meta-x11-display-private.h"
+#ifdef HAVE_X11_CLIENT
+#include "core/frame.h"
+#endif
+
#define WINDOW_TRANSIENT_FOR_WHOLE_GROUP(w) \
(meta_window_has_transient_type (w) && w->transient_for == NULL)
@@ -101,10 +104,12 @@ on_stack_changed (MetaStack *stack)
meta_topic (META_DEBUG_STACK, " %u:%d - %s ",
w->layer, w->stack_position, w->desc);
+#ifdef HAVE_X11_CLIENT
if (w->frame)
- top_level_window = w->frame->xwindow;
+ top_level_window = w->frame->xwindow;
else
- top_level_window = w->xwindow;
+#endif
+ top_level_window = w->xwindow;
if (w->client_type == META_WINDOW_CLIENT_TYPE_X11)
stack_id = top_level_window;
diff --git a/src/core/window.c b/src/core/window.c
index e1f52e15f7..6bf81e8f23 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -71,7 +71,6 @@
#include "core/boxes-private.h"
#include "core/constraints.h"
#include "core/edge-resistance.h"
-#include "core/frame.h"
#include "core/keybindings-private.h"
#include "core/meta-workspace-manager-private.h"
#include "core/place.h"
@@ -90,6 +89,10 @@
#include "x11/window-x11.h"
#include "x11/xprops.h"
+#ifdef HAVE_X11_CLIENT
+#include "core/frame.h"
+#endif
+
#ifdef HAVE_WAYLAND
#include "wayland/meta-wayland-private.h"
#include "wayland/meta-wayland-surface.h"
@@ -2951,9 +2954,10 @@ meta_window_tile (MetaWindow *window,
META_MOVE_RESIZE_STATE_CHANGED),
META_GRAVITY_NORTH_WEST,
window->unconstrained_rect);
-
+#ifdef HAVE_X11_CLIENT
if (window->frame)
meta_frame_queue_draw (window->frame);
+#endif
}
MetaTileMode
@@ -4165,18 +4169,24 @@ meta_window_get_gravity_position (MetaWindow *window,
if (gravity == META_GRAVITY_STATIC)
{
frame_extents = window->rect;
+#ifdef HAVE_X11_CLIENT
if (window->frame)
{
frame_extents.x = window->frame->rect.x + window->frame->child_x;
frame_extents.y = window->frame->rect.y + window->frame->child_y;
}
+#endif
}
else
{
+#ifdef HAVE_X11_CLIENT
if (window->frame == NULL)
frame_extents = window->rect;
else
frame_extents = window->frame->rect;
+#else
+ frame_extents = window->rect;
+#endif
}
x = frame_extents.x;
@@ -4293,6 +4303,7 @@ meta_window_client_rect_to_frame_rect (MetaWindow *window,
* constraints.c:get_size_limits() and not something that we provide
* in other locations or document.
*/
+#ifdef HAVE_X11_CLIENT
if (window->frame)
{
MetaFrameBorders borders;
@@ -4306,6 +4317,7 @@ meta_window_client_rect_to_frame_rect (MetaWindow *window,
frame_rect->height += borders.visible.top + borders.visible.bottom;
}
else
+#endif
{
const GtkBorder *extents = &window->custom_frame_extents;
frame_rect->x += extents->left;
@@ -4336,6 +4348,7 @@ meta_window_frame_rect_to_client_rect (MetaWindow *window,
*client_rect = *frame_rect;
+#ifdef HAVE_X11_CLIENT
if (window->frame)
{
MetaFrameBorders borders;
@@ -4347,6 +4360,7 @@ meta_window_frame_rect_to_client_rect (MetaWindow *window,
client_rect->height -= borders.visible.top + borders.visible.bottom;
}
else
+#endif
{
const GtkBorder *extents = &window->custom_frame_extents;
client_rect->x -= extents->left;
@@ -4386,18 +4400,26 @@ void
meta_window_get_client_area_rect (const MetaWindow *window,
cairo_rectangle_int_t *rect)
{
+ int top, left, right, bottom;
+#ifdef HAVE_X11_CLIENT
MetaFrameBorders borders;
-
meta_frame_calc_borders (window->frame, &borders);
- rect->x = borders.total.left;
- rect->y = borders.total.top;
+ left = borders.total.left;
+ right = borders.total.right;
+ bottom = borders.total.bottom;
+ top = borders.total.top;
+#else
+ top = left = right = bottom = 0;
+#endif
+ rect->x = left;
+ rect->y = top;
- rect->width = window->buffer_rect.width - borders.total.left - borders.total.right;
+ rect->width = window->buffer_rect.width - left - right;
if (window->shaded)
rect->height = 0;
else
- rect->height = window->buffer_rect.height - borders.total.top - borders.total.bottom;
+ rect->height = window->buffer_rect.height - top - bottom;
}
void
@@ -4410,11 +4432,13 @@ meta_window_get_titlebar_rect (MetaWindow *window,
rect->x = 0;
rect->y = 0;
+#ifdef HAVE_X11_CLIENT
if (window->frame)
{
rect->height = window->frame->child_y;
}
else
+#endif
{
/* Pick an arbitrary height for a titlebar. We might want to
* eventually have CSD windows expose their borders to us. */
@@ -5018,8 +5042,10 @@ meta_window_update_appears_focused (MetaWindow *window)
g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_APPEARS_FOCUSED]);
+#ifdef HAVE_X11_CLIENT
if (window->frame)
meta_frame_queue_draw (window->frame);
+#endif
}
static gboolean
@@ -5139,9 +5165,10 @@ meta_window_set_focused_internal (MetaWindow *window,
window);
}
+#ifdef HAVE_X11_CLIENT
if (window->frame)
meta_frame_queue_draw (window->frame);
-
+#endif
/* Ungrab click to focus button since the sync grab can interfere
* with some things you might do inside the focused window, by
* causing the client to get funky enter/leave events.
@@ -5313,11 +5340,12 @@ meta_window_type_changed (MetaWindow *window)
set_net_wm_state (window);
/* Update frame */
+#ifdef HAVE_X11_CLIENT
if (window->decorated)
meta_window_ensure_frame (window);
else
meta_window_destroy_frame (window);
-
+#endif
/* update stacking constraints */
meta_window_update_layer (window);
@@ -5347,8 +5375,10 @@ meta_window_set_type (MetaWindow *window,
void
meta_window_frame_size_changed (MetaWindow *window)
{
+#ifdef HAVE_X11_CLIENT
if (window->frame)
meta_frame_clear_cached_borders (window->frame);
+#endif
}
static void
@@ -5943,12 +5973,13 @@ update_move (MetaWindow *window,
window->saved_rect.x = work_area.x;
window->saved_rect.y = work_area.y;
+#ifdef HAVE_X11_CLIENT
if (window->frame)
{
window->saved_rect.x += window->frame->child_x;
window->saved_rect.y += window->frame->child_y;
}
-
+#endif
window->unconstrained_rect.x = window->saved_rect.x;
window->unconstrained_rect.y = window->saved_rect.y;
@@ -7598,11 +7629,13 @@ meta_window_get_frame_type (MetaWindow *window)
cairo_region_t *
meta_window_get_frame_bounds (MetaWindow *window)
{
+#ifdef HAVE_X11_CLIENT
if (!window->frame_bounds)
{
if (window->frame)
window->frame_bounds = meta_frame_get_frame_bounds (window->frame);
}
+#endif
return window->frame_bounds;
}
@@ -7814,9 +7847,10 @@ meta_window_set_title (MetaWindow *window,
g_free (window->title);
window->title = g_strdup (title);
+#ifdef HAVE_X11_CLIENT
if (window->frame)
meta_frame_update_title (window->frame);
-
+#endif
meta_window_update_desc (window);
g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_TITLE]);
diff --git a/src/meson.build b/src/meson.build
index 42d7a5a55f..0e7ec155c3 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -308,8 +308,6 @@ mutter_sources = [
'core/edge-resistance.h',
'core/events.c',
'core/events.h',
- 'core/frame.c',
- 'core/frame.h',
'core/keybindings.c',
'core/keybindings-private.h',
'core/meta-accel-parse.c',
@@ -427,6 +425,8 @@ if have_x11_client
'compositor/meta-sync-ring.h',
'compositor/meta-window-actor-x11.c',
'compositor/meta-window-actor-x11.h',
+ 'core/frame.c',
+ 'core/frame.h',
'ui/frames.c',
'ui/frames.h',
'ui/theme.c',
diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c
index 0559de220e..f06ca00eac 100644
--- a/src/wayland/meta-wayland-pointer-constraints.c
+++ b/src/wayland/meta-wayland-pointer-constraints.c
@@ -30,7 +30,6 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-pointer-constraint.h"
-#include "core/frame.h"
#include "core/window-private.h"
#include "meta/meta-backend.h"
#include "wayland/meta-pointer-confinement-wayland.h"
@@ -42,6 +41,10 @@
#include "wayland/meta-wayland-surface.h"
#include "wayland/meta-xwayland.h"
+#ifdef HAVE_X11_CLIENT
+#include "core/frame.h"
+#endif
+
#include "pointer-constraints-unstable-v1-server-protocol.h"
static GQuark quark_pending_constraint_state = 0;
@@ -614,21 +617,19 @@ cairo_region_t *
meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerConstraint *constraint)
{
cairo_region_t *region;
- MetaWindow *window;
region = meta_wayland_surface_calculate_input_region (constraint->surface);
if (constraint->region)
cairo_region_intersect (region, constraint->region);
- window = meta_wayland_surface_get_window (constraint->surface);
+#ifdef HAVE_XWAYLAND
+ MetaWindow *window = meta_wayland_surface_get_window (constraint->surface);
if (window && window->frame)
{
MetaFrame *frame = window->frame;
int actual_width, actual_height;
-#ifdef HAVE_XWAYLAND
g_assert (meta_wayland_surface_is_xwayland (constraint->surface));
-#endif
actual_width = window->buffer_rect.width - (frame->child_x +
frame->right_width);
actual_height = window->buffer_rect.height - (frame->child_y +
@@ -643,7 +644,7 @@ meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerCo
});
}
}
-
+#endif
return region;
}
diff --git a/src/x11/events.c b/src/x11/events.c
index 2c574d5755..8f71cf1ef1 100644
--- a/src/x11/events.c
+++ b/src/x11/events.c
@@ -50,6 +50,10 @@
#include "x11/window-x11.h"
#include "x11/xprops.h"
+#ifdef HAVE_X11_CLIENT
+#include "core/frame.h"
+#endif
+
#ifdef HAVE_WAYLAND
#include "wayland/meta-wayland-private.h"
#include "wayland/meta-xwayland-private.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]