GNOME Bugzilla – Bug 638907
gdk_display_get_window_at_pointer() deprecation comment could be more helpful
Last modified: 2018-05-02 15:00:32 UTC
gdk_display_get_window_at_pointer() is deprecated in GTK+ 3 with a simple suggestion to just use gdk_device_get_window_at_position() instead: http://library.gnome.org/devel/gdk/unstable/GdkDisplay.html#gdk-display-get-window-at-pointer (It is not yet deprecated in gtk+ 2.4.) But it doesn't suggest how we might get a device so we can call that function. I'm trying to port the change_display part of the gtkmm demo, but the relevant part of the GTK+ demo has not been ported yet: http://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/changedisplay.c (I really think that the build of the demos should disable deprecated GDK and GTK+ API, to force people to port that code when changing API.)
Oh, the code does disable deprecated API. I just explicitly disabled it for this test because nobody bothered to update this test even after repeated begging for me. I just didn't feel like adding more sarcasm by adding a comment to the demo for why I added the disabling... And the reason why there is no explicit mention of how to get a device is because there's so many different ways to get one - either from the current event or the default one or the associated or master device of another device. There's also limitations in our current APIs where we don't give the users devices to work with. In particular GtkButton::clicked and GtkToggleButton::toggled should really pass information about the device used to initiate that event. But I guess that's a different bug?
How about something like this: " To get the device you can use gtk_get_current_event_device() or gdk_event_get_device() if It is in reaction to an event. Also, you can use gdk_device_manager_get_client_pointer() but only in code that isn't triggered by a GdkEvent and there aren't other means to get a meaningful GdkDevice to operate on. "
I'm a bit scared of advertising gtk_get_current_event_device() so widely because I think it's a crack API - some magic global function that hands you a device. Or not. Ideally, I'd have a section in the GdkDevice docs that explains where devices come from and a link to that section from all the deprecated functions that are replaced by functions that suddenly require a device. (grabs etc come to mind, too.) Otherwise you'd need to repeat that section everywhere...
Yes, that sounds like it would be very useful.
Can this bug be closed? gdk_display_get_window_at_pointer() has been removed in gtk+-4. The Change Display demo has been updated in gtk+-3, gtk+-4, gtkmm-3 and gtkmm-4.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/347.