2017-08-26 16:24:46 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/* Mutter X display handler */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 Havoc Pennington
|
|
|
|
* Copyright (C) 2002 Red Hat, Inc.
|
|
|
|
* Copyright (C) 2003 Rob Adams
|
|
|
|
* Copyright (C) 2004-2006 Elijah Newren
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef META_X11_DISPLAY_PRIVATE_H
|
|
|
|
#define META_X11_DISPLAY_PRIVATE_H
|
|
|
|
|
|
|
|
#include <glib.h>
|
2022-05-08 15:50:11 +00:00
|
|
|
#include <gdk/gdk.h>
|
2017-08-26 16:26:30 +00:00
|
|
|
#include <X11/Xlib.h>
|
2017-08-26 16:24:46 +00:00
|
|
|
|
2017-08-26 19:28:04 +00:00
|
|
|
#include "backends/meta-monitor-manager-private.h"
|
2017-08-26 16:24:46 +00:00
|
|
|
#include "core/display-private.h"
|
|
|
|
#include "meta/common.h"
|
2018-11-23 10:48:53 +00:00
|
|
|
#include "meta/meta-selection-source.h"
|
2017-08-26 16:24:46 +00:00
|
|
|
#include "meta/types.h"
|
|
|
|
#include "meta/meta-x11-display.h"
|
2018-08-22 18:57:04 +00:00
|
|
|
#include "meta-startup-notification-x11.h"
|
2019-05-07 10:59:50 +00:00
|
|
|
#include "meta-x11-stack-private.h"
|
2022-09-09 10:45:52 +00:00
|
|
|
#include "x11/meta-sync-counter.h"
|
2017-08-26 16:24:46 +00:00
|
|
|
|
2023-02-01 10:25:59 +00:00
|
|
|
/* This is basically a bogus number, just has to be large enough
|
|
|
|
* to handle the expected case of the alt+tab operation, where
|
|
|
|
* we want to ignore serials from UnmapNotify on the tab popup,
|
|
|
|
* and the LeaveNotify/EnterNotify from the pointer ungrab. It
|
|
|
|
* also has to be big enough to hold ignored serials from the point
|
|
|
|
* where we reshape the stage to the point where we get events back.
|
|
|
|
*/
|
|
|
|
#define N_IGNORED_CROSSING_SERIALS 10
|
|
|
|
|
2017-08-26 16:58:29 +00:00
|
|
|
typedef struct _MetaGroupPropHooks MetaGroupPropHooks;
|
|
|
|
typedef struct _MetaWindowPropHooks MetaWindowPropHooks;
|
|
|
|
|
2017-08-26 16:56:44 +00:00
|
|
|
typedef gboolean (*MetaAlarmFilter) (MetaX11Display *x11_display,
|
|
|
|
XSyncAlarmNotifyEvent *event,
|
|
|
|
gpointer data);
|
|
|
|
|
2022-11-20 19:15:34 +00:00
|
|
|
typedef struct _MetaX11AlarmFilter
|
|
|
|
{
|
|
|
|
MetaAlarmFilter filter;
|
|
|
|
gpointer user_data;
|
|
|
|
} MetaX11AlarmFilter;
|
|
|
|
|
2017-08-26 16:24:46 +00:00
|
|
|
struct _MetaX11Display
|
|
|
|
{
|
|
|
|
GObject parent;
|
|
|
|
|
|
|
|
MetaDisplay *display;
|
2017-08-26 20:52:02 +00:00
|
|
|
GdkDisplay *gdk_display;
|
2017-08-26 16:26:30 +00:00
|
|
|
|
|
|
|
char *name;
|
|
|
|
char *screen_name;
|
|
|
|
|
|
|
|
Display *xdisplay;
|
|
|
|
Window xroot;
|
|
|
|
int default_depth;
|
|
|
|
Visual *default_xvisual;
|
|
|
|
|
2017-08-26 18:51:28 +00:00
|
|
|
guint32 timestamp;
|
|
|
|
|
2017-08-26 16:26:30 +00:00
|
|
|
/* Pull in all the names of atoms as fields; we will intern them when the
|
|
|
|
* class is constructed.
|
|
|
|
*/
|
|
|
|
#define item(x) Atom atom_##x;
|
|
|
|
#include "x11/atomnames.h"
|
|
|
|
#undef item
|
2017-08-26 16:28:53 +00:00
|
|
|
|
2017-08-26 18:51:28 +00:00
|
|
|
Window leader_window;
|
|
|
|
Window timestamp_pinging_window;
|
|
|
|
|
|
|
|
/* The window and serial of the most recent FocusIn event. */
|
|
|
|
Window server_focus_window;
|
|
|
|
gulong server_focus_serial;
|
|
|
|
|
|
|
|
/* For windows we've focused that don't necessarily have an X window,
|
|
|
|
* like the no_focus_window or the stage X window. */
|
|
|
|
Window focus_xwindow;
|
|
|
|
gulong focus_serial;
|
|
|
|
|
|
|
|
/* This window holds the focus when we don't want to focus
|
|
|
|
* any actual clients
|
|
|
|
*/
|
|
|
|
Window no_focus_window;
|
|
|
|
|
2017-08-26 17:03:51 +00:00
|
|
|
/* Instead of unmapping withdrawn windows we can leave them mapped
|
|
|
|
* and restack them below a guard window. When using a compositor
|
|
|
|
* this allows us to provide live previews of unmapped windows */
|
|
|
|
Window guard_window;
|
|
|
|
|
2017-08-26 18:51:28 +00:00
|
|
|
Window wm_sn_selection_window;
|
|
|
|
Atom wm_sn_atom;
|
|
|
|
guint32 wm_sn_timestamp;
|
|
|
|
|
2018-10-31 14:21:40 +00:00
|
|
|
guint display_close_idle;
|
|
|
|
guint32 xselectionclear_timestamp;
|
|
|
|
|
2017-08-26 18:51:28 +00:00
|
|
|
Window wm_cm_selection_window;
|
|
|
|
|
|
|
|
Window composite_overlay_window;
|
|
|
|
|
2017-08-26 16:56:44 +00:00
|
|
|
GHashTable *xids;
|
2022-09-09 10:45:52 +00:00
|
|
|
GHashTable *alarms;
|
2017-08-26 16:56:44 +00:00
|
|
|
|
2022-09-27 19:31:33 +00:00
|
|
|
GList *event_funcs;
|
|
|
|
|
2017-08-26 19:28:04 +00:00
|
|
|
gboolean has_xinerama_indices;
|
|
|
|
|
2017-08-26 16:58:29 +00:00
|
|
|
/* Managed by group.c */
|
|
|
|
GHashTable *groups_by_leader;
|
|
|
|
|
|
|
|
/* Managed by window-props.c */
|
|
|
|
MetaWindowPropHooks *prop_hooks_table;
|
|
|
|
GHashTable *prop_hooks;
|
|
|
|
int n_prop_hooks;
|
|
|
|
|
|
|
|
/* Managed by group-props.c */
|
|
|
|
MetaGroupPropHooks *group_prop_hooks;
|
|
|
|
|
2017-08-26 20:35:18 +00:00
|
|
|
int xkb_base_event_type;
|
|
|
|
guint32 last_bell_time;
|
|
|
|
|
2022-11-20 19:15:34 +00:00
|
|
|
GPtrArray *alarm_filters;
|
2017-08-26 16:56:44 +00:00
|
|
|
|
x11: Integrate frames client into Mutter
Replace the in-process implementation of frames with the external
frames client.
When a client window is created and managed by Mutter, Mutter will
determine whether it is a window that requires decorations and
hint the creation of a frame for it by setting the _MUTTER_NEEDS_FRAME
property on the client window.
After the frames client created a window that has the _MUTTER_FRAME_FOR
property, Mutter will proceed to reparent the client window on the
frame window, and show them as a single unit.
Rendering and event handling on the frame window will be performed by
the external client, Mutter is still responsible for everything else,
namely resizing client and frame window in synchronization, and
managing updates on the MetaWindowActor.
In order to let the frame be managed by the external client, Mutter
needs to change the way some properties are forwarded to the client
and/or frame windows. Some properties are necessary to keep propagating
to the client window only, some others need to happen on the frame
window now, and some others needs to be propagated on both so they
are synchronized about the behavior.
Also, some events that were previously totally unexpected in frame
windows are now susceptible to happen, so must be allowed now.
MetaFrame in src/core/frame.c now acts as the wrapper of foreign
windows created by the frames client, from the Mutter side. Location,
size, and lifetime are still largely in control of Mutter, some
details like visible/invisible borders are obtained from the client
instead (through the _MUTTER_FRAME_EXTENTS and _GTK_FRAME_EXTENTS
properties, respectively).
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-09-08 08:35:47 +00:00
|
|
|
GSubprocess *frames_client;
|
|
|
|
GCancellable *frames_client_cancellable;
|
|
|
|
|
2018-11-18 09:49:36 +00:00
|
|
|
struct {
|
2018-11-19 16:16:37 +00:00
|
|
|
Window xwindow;
|
2020-07-14 17:02:06 +00:00
|
|
|
guint timeout_id;
|
2018-11-19 17:17:25 +00:00
|
|
|
MetaSelectionSource *owners[META_N_SELECTION_TYPES];
|
|
|
|
GCancellable *cancellables[META_N_SELECTION_TYPES];
|
|
|
|
|
2018-11-18 09:49:36 +00:00
|
|
|
GList *input_streams;
|
|
|
|
GList *output_streams;
|
|
|
|
} selection;
|
|
|
|
|
2018-12-30 17:25:08 +00:00
|
|
|
/* If true, server->focus_serial refers to us changing the focus; in
|
|
|
|
* this case, we can ignore focus events that have exactly focus_serial,
|
|
|
|
* since we take care to make another request immediately afterwards.
|
|
|
|
* But if focus is being changed by another client, we have to accept
|
|
|
|
* multiple events with the same serial.
|
|
|
|
*/
|
|
|
|
guint focused_by_us : 1;
|
|
|
|
|
2017-08-26 19:38:59 +00:00
|
|
|
guint keys_grabbed : 1;
|
|
|
|
|
2019-06-14 15:25:10 +00:00
|
|
|
guint closing : 1;
|
|
|
|
|
2023-02-01 10:25:59 +00:00
|
|
|
/* serials of leave/unmap events that may
|
|
|
|
* correspond to an enter event we should
|
|
|
|
* ignore
|
|
|
|
*/
|
|
|
|
unsigned long ignored_crossing_serials[N_IGNORED_CROSSING_SERIALS];
|
|
|
|
|
2018-12-30 11:58:31 +00:00
|
|
|
/* we use property updates as sentinels for certain window focus events
|
|
|
|
* to avoid some race conditions on EnterNotify events
|
|
|
|
*/
|
|
|
|
int sentinel_counter;
|
|
|
|
|
2017-08-26 16:28:53 +00:00
|
|
|
int composite_event_base;
|
|
|
|
int composite_error_base;
|
|
|
|
int composite_major_version;
|
|
|
|
int composite_minor_version;
|
|
|
|
int damage_event_base;
|
|
|
|
int damage_error_base;
|
|
|
|
int xfixes_event_base;
|
|
|
|
int xfixes_error_base;
|
|
|
|
int xinput_error_base;
|
|
|
|
int xinput_event_base;
|
|
|
|
int xinput_opcode;
|
|
|
|
int xsync_event_base;
|
|
|
|
int xsync_error_base;
|
|
|
|
int shape_event_base;
|
|
|
|
int shape_error_base;
|
|
|
|
unsigned int have_xsync : 1;
|
|
|
|
#define META_X11_DISPLAY_HAS_XSYNC(x11_display) ((x11_display)->have_xsync)
|
|
|
|
unsigned int have_shape : 1;
|
|
|
|
#define META_X11_DISPLAY_HAS_SHAPE(x11_display) ((x11_display)->have_shape)
|
|
|
|
unsigned int have_composite : 1;
|
|
|
|
unsigned int have_damage : 1;
|
|
|
|
#define META_X11_DISPLAY_HAS_COMPOSITE(x11_display) ((x11_display)->have_composite)
|
|
|
|
#define META_X11_DISPLAY_HAS_DAMAGE(x11_display) ((x11_display)->have_damage)
|
2018-08-22 18:57:04 +00:00
|
|
|
|
|
|
|
MetaX11StartupNotification *startup_notification;
|
2019-05-07 10:59:50 +00:00
|
|
|
MetaX11Stack *x11_stack;
|
2019-08-16 14:23:08 +00:00
|
|
|
|
|
|
|
XserverRegion empty_region;
|
2017-08-26 16:24:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
MetaX11Display *meta_x11_display_new (MetaDisplay *display, GError **error);
|
|
|
|
|
2019-03-01 11:03:46 +00:00
|
|
|
void meta_x11_display_restore_active_workspace (MetaX11Display *x11_display);
|
|
|
|
|
2017-08-26 16:26:30 +00:00
|
|
|
Window meta_x11_display_create_offscreen_window (MetaX11Display *x11_display,
|
|
|
|
Window parent,
|
|
|
|
long valuemask);
|
|
|
|
|
|
|
|
Cursor meta_x11_display_create_x_cursor (MetaX11Display *x11_display,
|
|
|
|
MetaCursor cursor);
|
|
|
|
|
2017-08-26 16:37:29 +00:00
|
|
|
void meta_x11_display_reload_cursor (MetaX11Display *x11_display);
|
|
|
|
|
2017-08-26 16:56:44 +00:00
|
|
|
MetaWindow *meta_x11_display_lookup_x_window (MetaX11Display *x11_display,
|
|
|
|
Window xwindow);
|
|
|
|
void meta_x11_display_register_x_window (MetaX11Display *x11_display,
|
|
|
|
Window *xwindowp,
|
|
|
|
MetaWindow *window);
|
|
|
|
void meta_x11_display_unregister_x_window (MetaX11Display *x11_display,
|
|
|
|
Window xwindow);
|
|
|
|
|
2022-09-09 10:45:52 +00:00
|
|
|
MetaSyncCounter * meta_x11_display_lookup_sync_alarm (MetaX11Display *x11_display,
|
|
|
|
XSyncAlarm alarm);
|
|
|
|
|
|
|
|
void meta_x11_display_register_sync_alarm (MetaX11Display *x11_display,
|
|
|
|
XSyncAlarm *alarmp,
|
|
|
|
MetaSyncCounter *sync_counter);
|
|
|
|
|
2017-08-26 16:56:44 +00:00
|
|
|
void meta_x11_display_unregister_sync_alarm (MetaX11Display *x11_display,
|
|
|
|
XSyncAlarm alarm);
|
|
|
|
|
2019-01-23 02:25:35 +00:00
|
|
|
META_EXPORT
|
2022-11-20 19:15:34 +00:00
|
|
|
MetaX11AlarmFilter * meta_x11_display_add_alarm_filter (MetaX11Display *x11_display,
|
|
|
|
MetaAlarmFilter filter,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
META_EXPORT
|
|
|
|
void meta_x11_display_remove_alarm_filter (MetaX11Display *x11_display,
|
|
|
|
MetaX11AlarmFilter *alarm_filter);
|
2017-08-26 16:56:44 +00:00
|
|
|
|
2017-08-26 17:03:51 +00:00
|
|
|
void meta_x11_display_create_guard_window (MetaX11Display *x11_display);
|
|
|
|
|
2017-08-26 18:51:28 +00:00
|
|
|
/* make a request to ensure the event serial has changed */
|
|
|
|
void meta_x11_display_increment_event_serial (MetaX11Display *x11_display);
|
|
|
|
|
|
|
|
guint32 meta_x11_display_get_current_time_roundtrip (MetaX11Display *x11_display);
|
|
|
|
|
|
|
|
void meta_x11_display_set_input_focus_xwindow (MetaX11Display *x11_display,
|
|
|
|
Window window,
|
|
|
|
guint32 timestamp);
|
|
|
|
|
2017-08-26 19:28:04 +00:00
|
|
|
int meta_x11_display_logical_monitor_to_xinerama_index (MetaX11Display *x11_display,
|
|
|
|
MetaLogicalMonitor *logical_monitor);
|
|
|
|
|
|
|
|
MetaLogicalMonitor *meta_x11_display_xinerama_index_to_logical_monitor (MetaX11Display *x11_display,
|
|
|
|
int xinerama_index);
|
2017-08-26 18:51:28 +00:00
|
|
|
|
2017-08-26 20:29:10 +00:00
|
|
|
void meta_x11_display_update_workspace_layout (MetaX11Display *x11_display);
|
|
|
|
void meta_x11_display_update_workspace_names (MetaX11Display *x11_display);
|
2017-08-26 19:39:46 +00:00
|
|
|
|
2018-12-30 11:58:31 +00:00
|
|
|
void meta_x11_display_increment_focus_sentinel (MetaX11Display *x11_display);
|
|
|
|
void meta_x11_display_decrement_focus_sentinel (MetaX11Display *x11_display);
|
|
|
|
gboolean meta_x11_display_focus_sentinel_clear (MetaX11Display *x11_display);
|
|
|
|
|
2018-12-30 17:25:08 +00:00
|
|
|
void meta_x11_display_update_focus_window (MetaX11Display *x11_display,
|
|
|
|
Window xwindow,
|
|
|
|
gulong serial,
|
|
|
|
gboolean focused_by_us);
|
2018-12-30 20:23:07 +00:00
|
|
|
void meta_x11_display_set_input_focus (MetaX11Display *x11_display,
|
2019-09-05 11:17:21 +00:00
|
|
|
MetaWindow *window,
|
|
|
|
gboolean focus_frame,
|
|
|
|
uint32_t timestamp);
|
2018-12-30 17:25:08 +00:00
|
|
|
|
2023-02-08 14:25:32 +00:00
|
|
|
void meta_x11_display_sync_input_focus (MetaX11Display *x11_display);
|
|
|
|
|
2019-10-14 09:32:54 +00:00
|
|
|
MetaDisplay * meta_x11_display_get_display (MetaX11Display *x11_display);
|
|
|
|
|
2022-09-27 19:31:33 +00:00
|
|
|
void meta_x11_display_run_event_funcs (MetaX11Display *x11_display,
|
|
|
|
XEvent *xevent);
|
|
|
|
|
2017-08-26 16:24:46 +00:00
|
|
|
#endif /* META_X11_DISPLAY_PRIVATE_H */
|