GNOME Bugzilla – Bug 547920
Deprecate non-multihead API in Gdk and Gtk
Last modified: 2012-05-04 01:16:29 UTC
As per the description on the Gtk 3.0 tasks page in the wiki: Gdk and Gtk contain some backwards compatibility API from before it was multihead safe. Deprecating this for 2.16 wil enable us to get rid of it for 3.x. I'm working on this.
Created attachment 116680 [details] [review] Initial attempt at the Gtk parts This is an initial attempt at deprecating the non multihead safe functions in the Gtk layer. Particularly the few places where unsafe functions are used inside Gtk are worth looking at when reviewing.
Keep in mind that even gdk_screen_get_resolution() shouldn't be considered multi-head safe - resolution/font-options is really per-monitor. FWIW, the RI patchset fixes this; see bug 546711 comment 7 http://people.freedesktop.org/~david/gtk-ri-patches/gdk/GdkScreen.html#gdk-screen-get-resolution-for-monitor http://people.freedesktop.org/~david/gtk-ri-patches/gtk/gtk-Themeable-Stock-Images.html#gtk-icon-size-lookup-for-settings-for-monitor http://gitweb.freedesktop.org/?p=users/david/gtk%2B.git;a=commit;h=7c42b63bcd90242f59f06d38ddee5a2096a89e22 [1] [1] : URL might change when I rebase the tree from time to time; http://gitweb.freedesktop.org/?p=users/david/gtk%2B.git;a=shortlog;h=resolution-independence and this patch
Created attachment 117064 [details] [review] Deprecate non-multihead safe gdk events code This patch deprecates the following: gdk_add_client_message_filter gdk_setting_get
Created attachment 117065 [details] [review] Deprecate non-multihead safe gdk pixbuf code This patch deprecates gdk_pixbuf_render_pixmap_and_mask
Created attachment 117066 [details] [review] Deprecate non-multihead safe gdk property code This patch deprecates the following functions: gdk_string_to_compound_text gdk_text_property_to_text_list gdk_text_property_to_utf8_list gdk_utf8_to_compound_text
Created attachment 117067 [details] [review] Deprecate non-multihead safe gdk rgb code This patch deprecates the following functions: gdk_screen_get_rgb_colormap gdk_screen_get_rgb_visual gdk_rgb_get_colormap gdk_rgb_get_visual gdk_rgb_colormap_ditherable gdk_rgb_ditherable All these functions are actually deprecated with the note "The functionality is obsolete." because the current documentation already explains that they are not useful anymore.
Created attachment 117068 [details] [review] Deprecate non-multihead safe gdk screen code This patch deprecates the following functions: gdk_beep gdk_keyboard_ungrab gdk_pointer_is_grabbed gdk_pointer_ungrab gdk_set_double_click_time gdk_screen_width gdk_screen_width_mm gdk_screen_height gdk_screen_height_mm
Created attachment 117069 [details] [review] Deprecate non-multihead safe gdk selection code This patch deprecates the following functions: gdk_selection_owner_set gdk_selection_owner_get
Created attachment 117072 [details] [review] Deprecate non-multihead safe gdk key code This patch deprecates gdk_keymap_get_default
Created attachment 117075 [details] [review] Deprecate non-multihead safe gdk pixmap code This patch deprecates the following functions: gdk_pixmap_foreign_new gdk_pixmap_lookup
Created attachment 117076 [details] [review] Deprecate non-multihead safe gdk cursor code This patch deprecates gdk_cursor_new.
I see little virtue in this. Most apps don't open multiple displays. Why force app authors to replace gdk_pointer_ungrab() with gdk_display_pointer_ungrab(gdk_display_get_default()) ? Though admitttedly this change does reduce the number entry points in GDK, which has some inherent value in making the API understandable, so I'm not 101% opposed.
App writers should say gdk_pointer_ungrab(gtk_widget_get_display(widget)), not gdk_pointer_ungrab(gdk_display_get_default()). I would say there is little doubt that the latter is useless nonsense while the former is what works on both multi-display and normal apps, so the former should be the preferred one in any case. It's just a matter of documenting so people see what do use when they get the warning about gdk_pointer_ungrab() being unknown.
Created attachment 117144 [details] [review] Deprecate non-multihead safe gdk pango code This patch deprecates the function gdk_pango_context_get.
Created attachment 117204 [details] [review] Deprecate non-multihead safe gdk x11 code This patch deprecates the following functions: gdk_net_wm_supports gdk_x11_atom_to_xatom gdk_x11_get_xatom_by_name gdk_x11_get_xatom_name gdk_x11_xatom_to_atom gdk_x11_get_default_root_xwindow gdk_x11_get_default_screen gdk_x11_get_default_xdisplay gdk_x11_grab_server gdk_x11_ungrab_server gdk_xid_table_lookup Plus, the following global variable is deprecated: extern Display *gdk_display;
Created attachment 117206 [details] [review] Deprecate non-multihead safe gdk drag code This patch deprecates the following functions: gdk_drag_find_window gdk_drag_get_protocol
Created attachment 117222 [details] [review] Deprecate non-multihead safe gdk colour code This patch deprecates the function gdk_colormap_get_system.
Created attachment 117223 [details] [review] Deprecate non-multihead safe gdk visual code This patch deprecates the following functions: gdk_list_visuals gdk_visual_get_system gdk_query_depths gdk_query_visual_types gdk_visual_get_best gdk_visual_get_best_depth gdk_visual_get_best_type gdk_visual_get_best_with_both gdk_visual_get_best_with_depth gdk_visual_get_best_with_type Most of these functions are actually pure convenience, apart from not being able to work on a non-default screen.
Created attachment 117229 [details] [review] Deprecate non-multihead safe gdk window code This patch deprecates the following functions: gdk_window_foreign_new gdk_window_lookup gdk_set_pointer_hooks gdk_window_get_toplevels
Comment on attachment 116680 [details] [review] Initial attempt at the Gtk parts @@ -404,12 +404,7 @@ gtk_style_init (GtkStyle *style) { gint i; - GtkSettings *settings = gtk_settings_get_default (); - - if (settings) - _gtk_style_init_for_settings (style, settings); - else - style->font_desc = pango_font_description_from_string ("Sans 10"); + style->font_desc = pango_font_description_from_string ("Sans 10"); style->attach_count = 0; style->colormap = NULL; If we do this, we'll need to call _gtk_style_init_settings later when attaching it to a widget, no ?
(In reply to comment #20) > (From update of attachment 116680 [details] [review] [edit]) > @@ -404,12 +404,7 @@ gtk_style_init (GtkStyle *style) > { > gint i; > > - GtkSettings *settings = gtk_settings_get_default (); > - > - if (settings) > - _gtk_style_init_for_settings (style, settings); > - else > - style->font_desc = pango_font_description_from_string ("Sans 10"); > + style->font_desc = pango_font_description_from_string ("Sans 10"); > > style->attach_count = 0; > style->colormap = NULL; > > > If we do this, we'll need to call _gtk_style_init_settings later when attaching > it to a widget, no ? I don't think so. _gtk_style_init_settings is called as soon as we have a screen. That is what the comment above the function says and I actually inserted debug lines to gtk_style_init and _gtk_style_init_settings to verify that. I see an equal number of lines for each function here. The only purpose of trying to retrieve the font of the default screen might be to have something better than the default font - is that useful? I guess I can restore the old behaviour if you think it makes any sense.
What's the status of this right now?
The status is, that we need an agreement. The patches are there, and work as far as I can say. I wouldn't mind somebody going through them and saying yes, no or please-improve-this :)
I must say I'm somewhat torn on this. The 'multihead'-ness that we are fortifying our api against here is a dying breed.
2.22 has been released. Change target milestore to 2.24
I don't think this makes sense; multiple screens are an obsolescent X concept, we shouldn't complicate our api for it at this point