Re: GdkScreen size-changed and gdk_monitor_get_workarea problem
Hi Florian, On 8/11/18 1:41 pm, Florian Müllner wrote: > On Thu, Nov 8, 2018 at 12:35 PM Sebastian Geiger (Lanoxx) > wrote: >> >> I was able to resolve the issue yesterday, and found that it was not >> directly a Problem of GTK+. > > To some extent it is, I don't think its API currently allows what you > are trying to do. > > On X11, the WM is a client like your app as far as screen changes are > concerned. It will update the _NET_WORKAREA property in response to > the size change, but I don't see how it would be possible to ensure > that the property is written before the server notifies other clients > about the size change. But let's assume that this was possible and > fixed. It would still be possible for your app to get the wrong work > area, because the area can change without a change in screen size (for > example a dock or panel that is shown or removed). > > So if this is something GTK+ wants to support, then I think the best > option would be to emit change notifications for GdkMonitor:workarea. You are right. I was ignoring the fact that the workarea needs to be computed by the window manager after the monitor geometry has changed and of course that cannot happen in the same event cycle as the event for the monitor change itself. I am not sure how much overhead it would cause in Gtk to emit change events for GdkMonitor:workarea and if that is something Gtk wants to monitor, but if such a notification was added that would certainly be useful for me. Thanks for your the explanation. > > Cheers, > Florian > ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GdkScreen size-changed and gdk_monitor_get_workarea problem
On Thu, Nov 8, 2018 at 12:35 PM Sebastian Geiger (Lanoxx) wrote: > > I was able to resolve the issue yesterday, and found that it was not > directly a Problem of GTK+. To some extent it is, I don't think its API currently allows what you are trying to do. On X11, the WM is a client like your app as far as screen changes are concerned. It will update the _NET_WORKAREA property in response to the size change, but I don't see how it would be possible to ensure that the property is written before the server notifies other clients about the size change. But let's assume that this was possible and fixed. It would still be possible for your app to get the wrong work area, because the area can change without a change in screen size (for example a dock or panel that is shown or removed). So if this is something GTK+ wants to support, then I think the best option would be to emit change notifications for GdkMonitor:workarea. Cheers, Florian ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GdkScreen size-changed and gdk_monitor_get_workarea problem
On Thu, 2018-11-08 at 12:34 +0100, Sebastian Geiger (Lanoxx) wrote: > Dear Bastien, > > thanks for the reply. I will attach a sample next time. > > My App runs with the X11 backend. > > I was able to resolve the issue yesterday, and found that it was not > directly a Problem of GTK+. > > The problem is, that the window manager computes the workarea > asynchronosly, presumably its handled in a g_add_idle callback. > When I tried to use get_geometry instead of get_workarea I was > always > getting the correct values, but I specifically needed the workarea > so > that was not helping. > > My solution was then to register a filter function with > gdk_window_add_filter which listens for _NET_WORKAREA property > changes > and then queue a g_add_idle callback which handles the change. > > I tested the behavior with mutter and metacity and both had the same > problem. > > I am not sure if this is by design, or a bug. However, I would like > to > suggest that we add a small note to the documentation of the > monitor-changed signal and the size-change signal, stating that > values reported by gdk_monitor_get_workarea might arrive delayed. > Alternatively, fixing mutter and metacity would be my preferred > solution > but would probably be more work and I have not the necessary > knowledge > about mutter code to fix this myself. I'd start with filing a bug against mutter (I'm not sure metacity is still maintained), and see whether the GDK API documentation should be amended after discussing it there. Unless you're writing a panel of sorts, I don't think end-user applications should use this API in any case, with the window manager taking care of the window layout. Cheers ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GdkScreen size-changed and gdk_monitor_get_workarea problem
Dear Bastien, thanks for the reply. I will attach a sample next time. My App runs with the X11 backend. I was able to resolve the issue yesterday, and found that it was not directly a Problem of GTK+. The problem is, that the window manager computes the workarea asynchronosly, presumably its handled in a g_add_idle callback. When I tried to use get_geometry instead of get_workarea I was always getting the correct values, but I specifically needed the workarea so that was not helping. My solution was then to register a filter function with gdk_window_add_filter which listens for _NET_WORKAREA property changes and then queue a g_add_idle callback which handles the change. I tested the behavior with mutter and metacity and both had the same problem. I am not sure if this is by design, or a bug. However, I would like to suggest that we add a small note to the documentation of the monitor-changed signal and the size-change signal, stating that values reported by gdk_monitor_get_workarea might arrive delayed. Alternatively, fixing mutter and metacity would be my preferred solution but would probably be more work and I have not the necessary knowledge about mutter code to fix this myself. Best Regards Sebastian On 07/11/18 20:08, Bastien Nocera wrote: On Tue, 2018-11-06 at 21:35 +0100, Sebastian Geiger (Lanoxx) wrote: Hi Gtk developers, I am experiencing a wired issue and I am wondering if I am using the API in a wrong way of if there is a problem with Gtk. On Wayland or X11? gdk_display_get_monitor_at_point and then gdk_monitor_get_workarea. IIRC, the latter function isn't implemented in Wayland. In the future, it would also probably be best if you could attach or copy/paste a minimal test case, so folks on the mailing-list can try your code, and see either if there are errors in the code, or those are really bugs (or missing functionality). Cheers ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GdkScreen size-changed and gdk_monitor_get_workarea problem
On Tue, 2018-11-06 at 21:35 +0100, Sebastian Geiger (Lanoxx) wrote: > Hi Gtk developers, > > I am experiencing a wired issue and I am wondering if I am using the > API > in a wrong way of if there is a problem with Gtk. On Wayland or X11? > gdk_display_get_monitor_at_point and then gdk_monitor_get_workarea. IIRC, the latter function isn't implemented in Wayland. In the future, it would also probably be best if you could attach or copy/paste a minimal test case, so folks on the mailing-list can try your code, and see either if there are errors in the code, or those are really bugs (or missing functionality). Cheers ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list
GdkScreen size-changed and gdk_monitor_get_workarea problem
Hi Gtk developers, I am experiencing a wired issue and I am wondering if I am using the API in a wrong way of if there is a problem with Gtk. I have registered a callback to the "size-changed" signal like so: g_signal_connect (screen, "size-changed", G_CALLBACK(monitor_changed_cb), data); In the monitor_changed_cb function I am first calling: gdk_display_get_monitor_at_point and then gdk_monitor_get_workarea. My implementation seemed to work when the monitor size changes to a smaller size, but not when changing to a bigger size. I am testing this in VM. To test my implementation I changed the monitor resolution a couple of time via Gnome Settings. I start my app with a resolution of 1400x1050. First I change to 1024x786 and my signal handler correctly reports the new monitor size minus panel area. Then I change back to 1400x1050 and my signal handler instead reports 1024x720 (previous size minus panel area). Now I change to 1920x1080 and my signal handler reports 1400x1002 (previous size minus panel area). I guess its more likely that I am doing something wrong, rather than that there is a bug in Gtk. So, is there something I should do in my signal handler before I call gdk_monitor_get_workarea to get the correct values? Best Regards Sebastian ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list