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

Windows dont move correctly with "non standard" screen scales. #57

Open
MichaelSchloesser opened this issue Jan 12, 2024 · 3 comments
Open
Labels
Acknowledged We are aware of this issue and will respond soon

Comments

@MichaelSchloesser
Copy link

MichaelSchloesser commented Jan 12, 2024

Windows 10 (and other OS as well) allows the user to set a scale parameter, that changes the size of text, apps and some other things. This is useful when using a device with high resolution but small display (in this case a microsoft surface). However when i create a window using Mousetrap, and try to drag it somewhere, this scale parameter does not seem to be taken into account. Suppose i use a scale of 200% and want to drag the window to a position (x, y) then it ends up at (2x, 2y) instead.

I was not able to reproduce this on any other Windows machine.

Device specifications:
Device name: Microsoft-Surface
Processor: Intel(R) Core(TM) i5-1035G4 CPU @ 1.10GHz 1.50 GHz
Installed RAM: 8,00 GB (7,60 GB usable)
System type: 64-bit operating system, x64-based processor
Pen and touch: Pen and touch support with 10 touch points

Windows specifications:
Edition: Windows 10 Home
Version: 22H2
Installed on: ‎ 20/‎01/‎2023
OS build: 19045.3930
Experience: Windows Feature Experience Pack 1000.19053.1000.0

@Clemapfel Clemapfel added the Acknowledged We are aware of this issue and will respond soon label Jan 12, 2024
@Clemapfel
Copy link
Owner

Clemapfel commented Jan 12, 2024

Hi, I think this is fixable but I need to research how to make the back-end aware of the monitor scale. I'll ask my GNOME contacts, which may take a few days, and get back to you.

Until then, could you run

begin
    using Mousetrap
    gtk4 = Mousetrap.detail.GTK4_jll.libgtk4
    gio = Mousetrap.detail.Glib_jll.libgio

    widget = Separator()
    widget_ptr = Mousetrap.as_gobject_pointer(widget)
    gtk_display = @ccall gtk4.gtk_widget_get_display(widget_ptr::Ptr{Cvoid})::Ptr{Cvoid}
    gtk_monitor_list = @ccall gtk4.gdk_display_get_monitors(gtk_display::Ptr{Cvoid})::Ptr{Cvoid}
    gtk_monitor = @ccall gio.g_list_model_get_item(gtk_monitor_list::Ptr{Cvoid}, 0::Int)::Ptr{Cvoid}
    println("Monitor Scale: ", @ccall gtk4.gdk_monitor_get_scale_factor(gtk_monitor::Ptr{Cvoid})::Int)
end

in the REPL and tell me what it prints?

@MichaelSchloesser
Copy link
Author

MichaelSchloesser commented Jan 12, 2024

Hi, thanks for your quick answer.

running your code get the following error (on both my surface and my desktop computer):

ERROR: UndefVarError: as_gobject_pointer not defined
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base .\Base.jl:31
 [2] top-level scope
   @ .\REPL[2]:7

@Clemapfel
Copy link
Owner

Sorry for the period of inactivity, I found out this was an issue fixed with GTK4.12: https://gitlab.gnome.org/GNOME/gtk/-/issues/5877, so it was a bug. This will be fixed when the binary builder jll package mousetrap depends on is updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Acknowledged We are aware of this issue and will respond soon
Projects
None yet
Development

No branches or pull requests

2 participants