Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong monitor positions reported on latest GTK3 release #8164

Open
JakeStanger opened this issue May 17, 2024 · 2 comments
Open

Wrong monitor positions reported on latest GTK3 release #8164

JakeStanger opened this issue May 17, 2024 · 2 comments
Labels
bug Not working as intended

Comments

@JakeStanger
Copy link

JakeStanger commented May 17, 2024

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 JakeStanger added the bug Not working as intended label May 17, 2024
JakeStanger added a commit to JakeStanger/ironbar that referenced this issue May 18, 2024
This is a nasty hack, which will hopefully only be temporary.

See swaywm/sway#8164 for details
JakeStanger added a commit to JakeStanger/ironbar that referenced this issue May 18, 2024
This is a nasty hack, which will hopefully only be temporary.

See swaywm/sway#8164 for details
@emersion
Copy link
Member

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?

@JakeStanger
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Development

No branches or pull requests

2 participants