Skip to content

Commit 927a33b

Browse files
authored
Merge branch 'master' into idle_inhibit
2 parents 73208fe + af71a8e commit 927a33b

18 files changed

+574
-130
lines changed

config.h.meson

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@
7070

7171
/* Whether Xwayland has -initfd option */
7272
#mesondefine HAVE_XWAYLAND_INITFD
73+
74+
/* Whether the Xwayland supports +/-byteswappedclients */
75+
#mesondefine HAVE_XWAYLAND_BYTE_SWAPPED_CLIENTS

data/org.cinnamon.muffin.wayland.gschema.xml.in

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,30 @@
103103
</description>
104104
</key>
105105

106+
<key name="xwayland-allow-byte-swapped-clients" type="b">
107+
<default>false</default>
108+
<summary>Allow X11 clients with a different endianess to connect to Xwayland</summary>
109+
<description>
110+
Allow connections from clients with an endianess different to that
111+
of Xwayland.
112+
113+
The X server byte-swapping code is a huge attack surface, much of
114+
that code in Xwayland is prone to security issues.
115+
116+
The use-case of byte-swapped clients is very niche, and disabled by
117+
default in Xwayland.
118+
119+
Enable this option to instruct Xwayland to accept connections from
120+
X11 clients with a different endianess.
121+
122+
This option has no effect if Xwayland does not support the command
123+
line option +byteswappedclients/-byteswappedclients to control that
124+
setting.
125+
126+
Xwayland needs to be restarted for this setting to take effect.
127+
</description>
128+
</key>
129+
106130
</schema>
107131

108132
</schemalist>

meson.build

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ gudev_req = '>= 232'
3838

3939
# wayland version requirements
4040
wayland_server_req = '>= 1.20'
41-
wayland_protocols_req = '>= 1.23'
41+
wayland_protocols_req = '>= 1.36'
4242

4343
# native backend version requirements
4444
libinput_req = '>= 1.19.0'
@@ -376,6 +376,7 @@ if cc.has_header_symbol('sys/prctl.h', 'prctl')
376376
endif
377377

378378
have_xwayland_initfd = false
379+
have_xwayland_byte_swapped_clients = false
379380
if have_wayland
380381
xwayland_dep = dependency('xwayland', required: false)
381382

@@ -416,6 +417,16 @@ if have_wayland
416417
if (have_xwayland_initfd)
417418
cdata.set('HAVE_XWAYLAND_INITFD', 1)
418419
endif
420+
421+
# For Xwayland +/-byteswappedclients usage
422+
if xwayland_dep.found()
423+
have_xwayland_byte_swapped_clients = xwayland_dep.get_variable('have_byteswappedclients',
424+
default_value: 'false') == 'true'
425+
endif
426+
427+
if (have_xwayland_byte_swapped_clients)
428+
cdata.set('HAVE_XWAYLAND_BYTE_SWAPPED_CLIENTS', 1)
429+
endif
419430
endif
420431

421432
#xwayland_grab_default_access_rules = get_option('xwayland_grab_default_access_rules')
@@ -465,19 +476,20 @@ output = [
465476
'',
466477
' Options:',
467478
'',
468-
' Wayland.................. ' + have_wayland.to_string(),
469-
' Wayland EGLStream........ ' + have_wayland_eglstream.to_string(),
470-
' Native Backend........... ' + have_native_backend.to_string(),
471-
' EGL Device............... ' + have_egl_device.to_string(),
472-
' Default driver........... ' + default_driver,
473-
' Remote desktop........... ' + have_remote_desktop.to_string(),
474-
' gudev.................... ' + have_libgudev.to_string(),
475-
' Wacom.................... ' + have_libwacom.to_string(),
476-
' SM....................... ' + have_sm.to_string(),
477-
' Startup notification..... ' + have_startup_notification.to_string(),
478-
' Introspection............ ' + have_introspection.to_string(),
479-
' Profiler................. ' + have_profiler.to_string(),
480-
' Xwayland initfd.......... ' + have_xwayland_initfd.to_string(),
479+
' Wayland.......................... ' + have_wayland.to_string(),
480+
' Wayland EGLStream................ ' + have_wayland_eglstream.to_string(),
481+
' Native Backend................... ' + have_native_backend.to_string(),
482+
' EGL Device....................... ' + have_egl_device.to_string(),
483+
' Default driver................... ' + default_driver,
484+
' Remote desktop................... ' + have_remote_desktop.to_string(),
485+
' gudev............................ ' + have_libgudev.to_string(),
486+
' Wacom............................ ' + have_libwacom.to_string(),
487+
' SM............................... ' + have_sm.to_string(),
488+
' Startup notification............. ' + have_startup_notification.to_string(),
489+
' Introspection.................... ' + have_introspection.to_string(),
490+
' Profiler......................... ' + have_profiler.to_string(),
491+
' Xwayland initfd.................. ' + have_xwayland_initfd.to_string(),
492+
' Xwayland byte-swapped clients.... ' + have_xwayland_byte_swapped_clients.to_string(),
481493
'',
482494
' Tests:',
483495
'',

src/backends/meta-settings-private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ void meta_settings_get_xwayland_grab_patterns (MetaSettings *settings,
7979

8080
gboolean meta_settings_are_xwayland_grabs_allowed (MetaSettings *settings);
8181

82+
gboolean meta_settings_are_xwayland_byte_swapped_clients_allowed (MetaSettings *settings);
83+
8284
MetaX11ScaleMode meta_settings_get_x11_scale_mode (MetaSettings *settings);
8385

8486
void meta_settings_enable_x11_fractional_scaling (MetaSettings *settings,

src/backends/meta-settings.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ struct _MetaSettings
7272
GPtrArray *xwayland_grab_blacklist_patterns;
7373

7474
MetaX11ScaleMode x11_scale_mode;
75+
76+
/* Whether Xwayland should allow X11 clients from different endianess */
77+
gboolean xwayland_allow_byte_swapped_clients;
7578
};
7679

7780
G_DEFINE_TYPE (MetaSettings, meta_settings, G_TYPE_OBJECT)
@@ -498,6 +501,15 @@ update_xwayland_allow_grabs (MetaSettings *settings)
498501
"xwayland-allow-grabs");
499502
}
500503

504+
static void
505+
update_xwayland_allow_byte_swapped_clients (MetaSettings *settings)
506+
{
507+
508+
settings->xwayland_allow_byte_swapped_clients =
509+
g_settings_get_flags (settings->wayland_settings,
510+
"xwayland-allow-byte-swapped-clients");
511+
}
512+
501513
static void
502514
wayland_settings_changed (GSettings *wayland_settings,
503515
gchar *key,
@@ -512,6 +524,10 @@ wayland_settings_changed (GSettings *wayland_settings,
512524
{
513525
update_xwayland_grab_access_rules (settings);
514526
}
527+
else if (g_str_equal (key, "xwayland-allow-byte-swapped-clients"))
528+
{
529+
update_xwayland_allow_byte_swapped_clients (settings);
530+
}
515531
}
516532

517533
static void
@@ -541,6 +557,12 @@ meta_settings_are_xwayland_grabs_allowed (MetaSettings *settings)
541557
return (settings->xwayland_allow_grabs);
542558
}
543559

560+
gboolean
561+
meta_settings_are_xwayland_byte_swapped_clients_allowed (MetaSettings *settings)
562+
{
563+
return settings->xwayland_allow_byte_swapped_clients;
564+
}
565+
544566
MetaX11ScaleMode
545567
meta_settings_get_x11_scale_mode (MetaSettings *settings)
546568
{

src/core/window-private.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,4 +908,8 @@ gboolean meta_window_shortcuts_inhibited (MetaWindow *window,
908908
ClutterInputDevice *source);
909909
gboolean meta_window_is_stackable (MetaWindow *window);
910910
gboolean meta_window_is_focus_async (MetaWindow *window);
911+
912+
gboolean meta_window_calculate_bounds (MetaWindow *window,
913+
int *bounds_width,
914+
int *bounds_height);
911915
#endif

src/core/window.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,7 @@ _meta_window_shared_new (MetaDisplay *display,
10471047
MetaCompEffect effect,
10481048
XWindowAttributes *attrs)
10491049
{
1050+
MetaBackend *backend = meta_get_backend ();
10501051
MetaWorkspaceManager *workspace_manager = display->workspace_manager;
10511052
MetaWindow *window;
10521053

@@ -1241,7 +1242,11 @@ _meta_window_shared_new (MetaDisplay *display,
12411242

12421243
window->compositor_private = NULL;
12431244

1244-
window->monitor = meta_window_calculate_main_logical_monitor (window);
1245+
if (window->rect.width > 0 && window->rect.height > 0)
1246+
window->monitor = meta_window_calculate_main_logical_monitor (window);
1247+
else
1248+
window->monitor = meta_backend_get_current_logical_monitor (backend);
1249+
12451250
if (window->monitor)
12461251
window->preferred_output_winsys_id = window->monitor->winsys_id;
12471252
else
@@ -9495,3 +9500,29 @@ meta_window_get_icon_name (MetaWindow *window)
94959500

94969501
return window->theme_icon_name;
94979502
}
9503+
9504+
gboolean
9505+
meta_window_calculate_bounds (MetaWindow *window,
9506+
int *bounds_width,
9507+
int *bounds_height)
9508+
{
9509+
MetaLogicalMonitor *main_monitor;
9510+
9511+
main_monitor = meta_window_get_main_logical_monitor (window);
9512+
if (main_monitor)
9513+
{
9514+
MetaRectangle work_area;
9515+
9516+
meta_window_get_work_area_for_logical_monitor (window,
9517+
main_monitor,
9518+
&work_area);
9519+
9520+
*bounds_width = work_area.width;
9521+
*bounds_height = work_area.height;
9522+
return TRUE;
9523+
}
9524+
else
9525+
{
9526+
return FALSE;
9527+
}
9528+
}

src/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ if have_wayland
587587
'wayland/meta-wayland-xdg-foreign-private.h',
588588
'wayland/meta-wayland-xdg-shell.c',
589589
'wayland/meta-wayland-xdg-shell.h',
590+
'wayland/meta-wayland-xdg-dialog.c',
591+
'wayland/meta-wayland-xdg-dialog.h',
590592
'wayland/meta-window-wayland.c',
591593
'wayland/meta-window-wayland.h',
592594
'wayland/meta-window-xwayland.c',
@@ -807,6 +809,7 @@ if have_wayland
807809
['tablet', 'unstable', 'v2', ],
808810
['text-input', 'unstable', 'v3', ],
809811
['viewporter', 'stable', ],
812+
['xdg-dialog', 'staging', 'v1', ],
810813
['xdg-foreign', 'unstable', 'v1', ],
811814
['xdg-foreign', 'unstable', 'v2', ],
812815
['xdg-output', 'unstable', 'v1', ],
@@ -834,6 +837,10 @@ if have_wayland
834837
'@0@/@1@/@[email protected]'.format(protocol_type,
835838
protocol_name,
836839
output_base))
840+
elif protocol_type == 'staging'
841+
protocol_version = p.get(2)
842+
output_base = '@0@-@1@'.format(protocol_name, protocol_version)
843+
input = protocols_dir / protocol_type / protocol_name / '@[email protected]'.format(output_base)
837844
elif protocol_type == 'private'
838845
output_base = protocol_name
839846
input = 'wayland/protocol/@[email protected]'.format(protocol_name)

src/wayland/meta-wayland-subsurface.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ meta_wayland_subsurface_union_geometry (MetaWaylandSubsurface *subsurface,
147147
.height = meta_wayland_surface_get_height (surface),
148148
};
149149

150-
meta_rectangle_union (out_geometry, &geometry, out_geometry);
150+
if (surface->buffer_ref.buffer)
151+
meta_rectangle_union (out_geometry, &geometry, out_geometry);
151152

152153
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface)
153154
{

src/wayland/meta-wayland-versions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
/* Global/master objects (version exported by wl_registry and negotiated through bind) */
3838
#define META_WL_COMPOSITOR_VERSION 5
3939
#define META_WL_DATA_DEVICE_MANAGER_VERSION 3
40-
#define META_XDG_WM_BASE_VERSION 3
40+
#define META_XDG_WM_BASE_VERSION 4
4141
#define META_WL_SEAT_VERSION 5
4242
#define META_WL_OUTPUT_VERSION 4
4343
#define META_XSERVER_VERSION 1
@@ -55,6 +55,7 @@
5555
#define META_ZWP_XWAYLAND_KEYBOARD_GRAB_V1_VERSION 1
5656
#define META_ZWP_TEXT_INPUT_V3_VERSION 1
5757
#define META_WP_VIEWPORTER_VERSION 1
58+
#define META_XDG_DIALOG_VERSION 1
5859
#define META_ZWP_PRIMARY_SELECTION_V1_VERSION 1
5960

6061
#endif

0 commit comments

Comments
 (0)