After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 638907 - gdk_display_get_window_at_pointer() deprecation comment could be more helpful
gdk_display_get_window_at_pointer() deprecation comment could be more helpful
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Class: GdkDevice
3.0.x
Other All
: Normal normal
: 3.6
Assigned To: gtk-bugs
Carlos Garnacho
Depends on:
Blocks:
 
 
Reported: 2011-01-07 13:30 UTC by Murray Cumming
Modified: 2018-05-02 15:00 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Murray Cumming 2011-01-07 13:30:42 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.)
Comment 1 Benjamin Otte (Company) 2011-01-07 15:34:34 UTC
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?
Comment 2 Javier Jardón (IRC: jjardon) 2011-01-07 16:18:59 UTC
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.
"
Comment 3 Benjamin Otte (Company) 2011-01-07 16:51:31 UTC
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...
Comment 4 Murray Cumming 2011-01-12 14:10:06 UTC
Yes, that sounds like it would be very useful.
Comment 5 Kjell Ahlstedt 2018-01-24 12:20:37 UTC
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.
Comment 6 GNOME Infrastructure Team 2018-05-02 15:00:32 UTC
-- 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.