comparison gtk4/dw.c @ 2336:dd1b2cc95c91

GTK4: Don't unref the PangoContext returned from gtk_widget_get_pango_context(). Only go native if necessary in dw_window_get_pos_size(), plus refactor so we only get the surface on X11 where we can query the position.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 02 Mar 2021 10:30:10 +0000
parents 1d413d869fa2
children ef078d219bfc
comparison
equal deleted inserted replaced
2335:1d413d869fa2 2336:dd1b2cc95c91
6878 DW_FUNCTION_NO_RETURN(dw_font_text_extents_get) 6878 DW_FUNCTION_NO_RETURN(dw_font_text_extents_get)
6879 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pixmap, HPIXMAP, text, const char *, width, int *, height, int *) 6879 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pixmap, HPIXMAP, text, const char *, width, int *, height, int *)
6880 { 6880 {
6881 PangoFontDescription *font; 6881 PangoFontDescription *font;
6882 char *fontname = NULL; 6882 char *fontname = NULL;
6883 int free_fontname = 0; 6883 int free_fontname = FALSE;
6884 6884
6885 if(text) 6885 if(text)
6886 { 6886 {
6887 if(handle) 6887 if(handle)
6888 { 6888 {
6889 fontname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname"); 6889 fontname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname");
6890 if ( fontname == NULL ) 6890 if(fontname == NULL)
6891 { 6891 {
6892 fontname = dw_window_get_font(handle); 6892 fontname = dw_window_get_font(handle);
6893 free_fontname = 1; 6893 free_fontname = TRUE;
6894 } 6894 }
6895 } 6895 }
6896 else if(pixmap) 6896 else if(pixmap)
6897 { 6897 {
6898 if(pixmap->font) 6898 if(pixmap->font)
6923 if(height) 6923 if(height)
6924 *height = rect.height; 6924 *height = rect.height;
6925 6925
6926 g_object_unref(layout); 6926 g_object_unref(layout);
6927 } 6927 }
6928 g_object_unref(context);
6929 } 6928 }
6930 pango_font_description_free(font); 6929 pango_font_description_free(font);
6931 } 6930 }
6932 if(free_fontname) 6931 if(free_fontname)
6933 free(fontname); 6932 free(fontname);
8746 if(!*height) 8745 if(!*height)
8747 *height = (ULONG)size.height; 8746 *height = (ULONG)size.height;
8748 } 8747 }
8749 8748
8750 #ifdef GDK_WINDOWING_X11 8749 #ifdef GDK_WINDOWING_X11
8751 { 8750 if(x || y)
8752 GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(handle)); 8751 {
8753 GdkDisplay *display = gdk_display_get_default(); 8752 GdkDisplay *display = gdk_display_get_default();
8753 GdkSurface *surface;
8754 8754
8755 if(surface && display && GDK_IS_X11_DISPLAY(display)) 8755 if(display && GDK_IS_X11_DISPLAY(display) && (surface = gtk_native_get_surface(GTK_NATIVE(handle))))
8756 { 8756 {
8757 XWindowAttributes xwa; 8757 XWindowAttributes xwa;
8758 int ix = 0, iy = 0; 8758 int ix = 0, iy = 0;
8759 Window child, xrootwin = gdk_x11_display_get_xrootwindow(display); 8759 Window child, xrootwin = gdk_x11_display_get_xrootwindow(display);
8760 8760