sway icon indicating copy to clipboard operation
sway copied to clipboard

Wrong monitor positions reported on latest GTK3 release

Open JakeStanger opened this issue 1 year ago • 2 comments

Sway Version: Git (dcdb727) Wlroots Version: Git (325d84381)

Description:

The latest GTK 3.24 release (3.24.42) includes a fix described as "Fix monitor sizes".

https://gitlab.gnome.org/GNOME/gtk/-/commit/51b04c5007f89142ed5a1ab240c03d5800b86b3d

This seems to have inadvertently caused some issues on wlroots-based compositors, whereby the gdk_monitor_get_geometry function now returns 0, 0 for the position of every monitor.

This issue did not occur prior to the GTK update.

I have tested it on the following:

  • Gnome 46.1
  • KDE Plasma 6.0.4
  • Sway (latest Git)
  • Hyprland 0.40.0

On Gnome/KDE the positions are reported correctly, however the bug occurs on both Sway and Hyprland. I suspect this therefore may be wlroots related, but have opened the issue here first as per the wlroots repo instructions.

A basic reproduction can be seen with the following Python 3 script:

import gi
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk


display = Gdk.Display.get_default()

def print_geometry(num):
    mon = display.get_monitor(num).get_geometry()
    print(mon.x, mon.y, mon.width, mon.height)

# add/remove entries according to the number of monitors (I have 3)
print_geometry(0)
print_geometry(1)
print_geometry(2)

Results in:

# incorrect
λ python gtk-test.py
0 0 2560 1440
0 0 1920 1080
0 0 2560 1440

In my case I have 3 horizontally aligned monitors, so I would expect the X positions to be offset by their widths according to their alignment:

# correct
λ python gtk-test.py
1080 0 2560 1440
0 0 1920 1080
2520 0 2560 1440

The effect of this is that the gdk_display_get_monitor_at_point function now returns the 1st monitor always.

If you need any more info, let me know.

JakeStanger avatar May 17 '24 23:05 JakeStanger

wlroots sends 0,0 as the position via wl_output, because regular applications shouldn't care about the output layout and and wl_output doesn't expose enough information anyways. wlroots does send the correct position via xdg_output though. I suspect GTK doesn't wait for the done event when the monitor geometry is queried, and falls back to the wl_output partial data as a result?

Sounds like a GTK bug.

Can you run your demo with WAYLAND_DEBUG=client and post the logs?

emersion avatar May 21 '24 07:05 emersion

I suspect GTK doesn't wait for the done event when the monitor geometry is queried, and falls back to the wl_output partial data as a result?

The weird thing is the GTK commit seems to suggest the opposite?

The logs do seem to back up your theory though, I think. You can see zxdg_output_v1 is reporting the correct positions while wl_output just returns 0,0.

✦ λ WAYLAND_DEBUG=client python gtk-test.py 
[1891687.525]  -> [email protected]_registry(new id wl_registry@2)
[1891687.538]  -> [email protected](new id wl_callback@3)
[1891687.614] [email protected]_id(3)
[1891687.621] [email protected](1, "wp_tearing_control_manager_v1", 1)
[1891687.627] [email protected](2, "wp_fractional_scale_manager_v1", 1)
[1891687.634] [email protected](3, "zxdg_output_manager_v1", 3)
[1891687.637]  -> [email protected](3, "zxdg_output_manager_v1", 3, new id [unknown]@4)
[1891687.641]  -> [email protected](new id wl_callback@5)
[1891687.645] [email protected](4, "wp_cursor_shape_manager_v1", 1)
[1891687.648] [email protected](5, "zwp_idle_inhibit_manager_v1", 1)
[1891687.652] [email protected](6, "zwp_relative_pointer_manager_v1", 1)
[1891687.657] [email protected](7, "zxdg_decoration_manager_v1", 1)
[1891687.661] [email protected](8, "wp_alpha_modifier_v1", 1)
[1891687.665] [email protected](9, "zwlr_gamma_control_manager_v1", 1)
[1891687.668] [email protected](10, "ext_foreign_toplevel_list_v1", 1)
[1891687.671] [email protected](11, "zwp_pointer_gestures_v1", 3)
[1891687.675]  -> [email protected](11, "zwp_pointer_gestures_v1", 1, new id [unknown]@6)
[1891687.678] [email protected](12, "zwlr_foreign_toplevel_manager_v1", 3)
[1891687.682] [email protected](13, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[1891687.686]  -> [email protected](13, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1, new id [unknown]@7)
[1891687.690] [email protected](14, "zwp_text_input_manager_v3", 1)
[1891687.694] [email protected](15, "zwp_pointer_constraints_v1", 1)
[1891687.698] [email protected](16, "zwlr_output_power_manager_v1", 1)
[1891687.703] [email protected](17, "xdg_activation_v1", 1)
[1891687.706]  -> [email protected](17, "xdg_activation_v1", 1, new id [unknown]@8)
[1891687.710] [email protected](18, "ext_idle_notifier_v1", 1)
[1891687.714] [email protected](19, "ext_session_lock_manager_v1", 1)
[1891687.718] [email protected](20, "zwp_input_method_manager_v2", 1)
[1891687.721] [email protected](21, "zwp_virtual_keyboard_manager_v1", 1)
[1891687.725] [email protected](22, "zwlr_virtual_pointer_manager_v1", 2)
[1891687.729] [email protected](23, "zwlr_output_manager_v1", 4)
[1891687.732] [email protected](24, "hyprland_toplevel_export_manager_v1", 2)
[1891687.736] [email protected](25, "zwp_text_input_manager_v1", 1)
[1891687.740] [email protected](26, "hyprland_global_shortcuts_manager_v1", 1)
[1891687.744] [email protected](27, "zwlr_screencopy_manager_v1", 3)
[1891687.748] [email protected](28, "wl_shm", 1)
[1891687.751]  -> [email protected](28, "wl_shm", 1, new id [unknown]@9)
[1891687.755] [email protected](29, "wl_drm", 2)
[1891687.758] [email protected](30, "zwp_linux_dmabuf_v1", 4)
[1891687.763] [email protected](31, "wl_compositor", 6)
[1891687.766]  -> [email protected](31, "wl_compositor", 3, new id [unknown]@10)
[1891687.771] [email protected](32, "wl_subcompositor", 1)
[1891687.774]  -> [email protected](32, "wl_subcompositor", 1, new id [unknown]@11)
[1891687.777] [email protected](33, "wl_data_device_manager", 3)
[1891687.780]  -> [email protected](33, "wl_data_device_manager", 3, new id [unknown]@12)
[1891687.783] [email protected](34, "zwlr_export_dmabuf_manager_v1", 1)
[1891687.787] [email protected](35, "zwlr_data_control_manager_v1", 2)
[1891687.792] [email protected](36, "zwp_primary_selection_device_manager_v1", 1)
[1891687.796]  -> [email protected](36, "zwp_primary_selection_device_manager_v1", 1, new id [unknown]@13)
[1891687.800] [email protected](37, "wp_viewporter", 1)
[1891687.804] [email protected](38, "xdg_wm_base", 6)
[1891687.806] [email protected](39, "wl_seat", 9)
[1891687.809] [email protected](40, "wp_presentation", 1)
[1891687.812] [email protected](41, "zwlr_layer_shell_v1", 4)
[1891687.815] [email protected](42, "org_kde_kwin_server_decoration_manager", 1)
[1891687.818]  -> [email protected](42, "org_kde_kwin_server_decoration_manager", 1, new id [unknown]@14)
[1891687.827] [email protected](43, "wp_drm_lease_device_v1", 1)
[1891687.831] [email protected](44, "zwp_tablet_manager_v2", 1)
[1891687.834]  -> [email protected](44, "zwp_tablet_manager_v2", 1, new id [unknown]@15)
[1891687.837] [email protected](45, "zxdg_exporter_v1", 1)
[1891687.841]  -> [email protected](45, "zxdg_exporter_v1", 1, new id [unknown]@16)
[1891687.844] [email protected](46, "zxdg_importer_v1", 1)
[1891687.848]  -> [email protected](46, "zxdg_importer_v1", 1, new id [unknown]@17)
[1891687.852] [email protected](47, "zxdg_exporter_v2", 1)
[1891687.856] [email protected](48, "zxdg_importer_v2", 1)
[1891687.860] [email protected](49, "wp_single_pixel_buffer_manager_v1", 1)
[1891687.863] [email protected](50, "xwayland_shell_v1", 1)
[1891687.866] [email protected](51, "wl_output", 4)
[1891687.871]  -> [email protected](51, "wl_output", 2, new id [unknown]@18)
[1891687.897]  -> [email protected]_xdg_output(new id zxdg_output_v1@19, wl_output@18)
[1891687.901]  -> [email protected](new id wl_callback@20)
[1891687.905] [email protected](52, "wl_output", 4)
[1891687.908]  -> [email protected](52, "wl_output", 2, new id [unknown]@21)
[1891687.913]  -> [email protected]_xdg_output(new id zxdg_output_v1@22, wl_output@21)
[1891687.917]  -> [email protected](new id wl_callback@23)
[1891687.921] [email protected](53, "wl_output", 4)
[1891687.924]  -> [email protected](53, "wl_output", 2, new id [unknown]@24)
[1891687.929]  -> [email protected]_xdg_output(new id zxdg_output_v1@25, wl_output@24)
[1891687.933]  -> [email protected](new id wl_callback@26)
[1891687.937] [email protected](486)
[1891687.971]  -> [email protected]_pool(new id wl_shm_pool@3, fd 10, 2304)
[1891688.102]  -> [email protected](6912)
[1891688.156]  -> [email protected](16128)
[1891688.235]  -> [email protected](34560)
[1891688.369]  -> [email protected](71424)
[1891688.630]  -> [email protected](145152)
[1891689.298]  -> [email protected](292608)
[1891690.131]  -> [email protected](587520)
[1891692.996]  -> [email protected](39, "wl_seat", 5, new id [unknown]@27)
[1891694.971]  -> [email protected]_surface(new id wl_surface@28)
[1891694.982]  -> [email protected]_device(new id zwp_primary_selection_device_v1@29, wl_seat@27)
[1891694.987]  -> [email protected]_data_device(new id wl_data_device@30, wl_seat@27)
[1891695.030]  -> [email protected]_surface(new id wl_surface@31)
[1891695.034]  -> [email protected]_tablet_seat(new id zwp_tablet_seat_v2@32, wl_seat@27)
[1891695.040]  -> [email protected](new id wl_callback@33)
[1891695.164] [email protected]_id(5)
[1891695.168] [email protected]_id(20)
[1891695.171] [email protected]_id(23)
[1891695.174] [email protected]_id(26)
[1891695.176] [email protected]_id(33)
[1891695.179] [email protected](486)
[1891695.182] [email protected](0)
[1891695.185] [email protected](1)
[1891695.187] [email protected](875709016)
[1891695.190] [email protected](875708993)
[1891695.193] [email protected](875710274)
[1891695.196] [email protected](842094674)
[1891695.199] [email protected](842088786)
[1891695.202] [email protected](892426322)
[1891695.205] [email protected](892420434)
[1891695.207] [email protected](909199186)
[1891695.210] [email protected](1211384408)
[1891695.213] [email protected](1211384385)
[1891695.216] [email protected](942948952)
[1891695.218] [email protected](942948929)
[1891695.221] [email protected]_mode(2)
[1891695.225] [email protected](0, 0, 600, 340, 0, "ASUSTek COMPUTER INC", "PA278QV", 0)
[1891695.232] [email protected](1, 2560, 1440, 74924)
[1891695.235] [email protected](1)
[1891695.238] [email protected]()
[1891695.250] [email protected]("DP-1")
[1891695.253] [email protected]("ASUSTek COMPUTER INC PA278QV M4LMQS060475 (DP-1)")
[1891695.256] [email protected]_position(1920, 0)
[1891695.260] [email protected]_size(2560, 1440)
[1891695.263] [email protected]()
[1891695.267] [email protected](486)
[1891695.270] [email protected](0, 0, 600, 340, 0, "AOC", "27V2G5", 0)
[1891695.276] [email protected](1, 1920, 1080, 74973)
[1891695.279] [email protected](1)
[1891695.282] [email protected]()
[1891695.287] [email protected]("DP-2")
[1891695.290] [email protected]("AOC 27V2G5 0x00000E39 (DP-2)")
[1891695.293] [email protected]_position(0, 360)
[1891695.296] [email protected]_size(1920, 1080)
[1891695.299] [email protected]()
[1891695.303] [email protected](486)
[1891695.306] [email protected](0, 0, 600, 340, 0, "AOC", "Q27P2W", 0)
[1891695.311] [email protected](1, 2560, 1440, 74968)
[1891695.315] [email protected](1)
[1891695.318] [email protected]()
[1891695.322] [email protected]("DP-3")
[1891695.325] [email protected]("AOC Q27P2W ASEP69A000495 (DP-3)")
[1891695.328] [email protected]_position(4480, 0)
[1891695.332] [email protected]_size(2560, 1440)
[1891695.335] [email protected]()
[1891695.339] [email protected](486)
[1891695.342] [email protected]("seat0")
[1891695.345] [email protected](3)
[1891695.349]  -> [email protected]_pointer(new id wl_pointer@26)
[1891695.356]  -> [email protected]_swipe_gesture(new id zwp_pointer_gesture_swipe_v1@23, wl_pointer@26)
[1891695.359]  -> [email protected]_pinch_gesture(new id zwp_pointer_gesture_pinch_v1@20, wl_pointer@26)
[1891695.363]  -> [email protected]_keyboard(new id wl_keyboard@5)
[1891695.368] [email protected](486)
[1891695.371]  -> [email protected](38, "xdg_wm_base", 6, new id [unknown]@33)
0 0 2560 1440
0 0 1920 1080
0 0 2560 1440

JakeStanger avatar May 21 '24 17:05 JakeStanger

FYI I have opened an issue on the GTK tracker: https://gitlab.gnome.org/GNOME/gtk/-/issues/6939

JakeStanger avatar Aug 17 '24 11:08 JakeStanger

A working fix has now been merged into GTK, so I'll close this issue.

Building GTK with 1cf05204 (merged into gtk-3-24 branch) will resolve, or waiting for the 3.24.44 release.

https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7626

JakeStanger avatar Aug 18 '24 21:08 JakeStanger