[gtk/wip/otte/gleanup: 26/73] x11: Move code where it belongs




commit 93074754d7822d47546f38f0c474646662092a9d
Author: Benjamin Otte <otte redhat com>
Date:   Thu Jun 3 04:42:23 2021 +0200

    x11: Move code where it belongs
    
    Instead of the display telling the screen to tell the visuals to tell
    the display to initialize itself, just init the display directly.
    
    What a concept.

 gdk/x11/gdkdisplay-x11.c | 40 ++++++++++++++++++++++------------------
 gdk/x11/gdkprivate-x11.h |  5 -----
 gdk/x11/gdkscreen-x11.c  |  5 ++---
 gdk/x11/gdkscreen-x11.h  |  6 ++----
 gdk/x11/gdkvisual-x11.c  | 30 +-----------------------------
 5 files changed, 27 insertions(+), 59 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 67ffa7b09c..ae112e1d72 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -1339,22 +1339,6 @@ set_sm_client_id (GdkDisplay  *display,
                      gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID"));
 }
 
-void
-gdk_display_setup_window_visual (GdkDisplay *display,
-                                 int         depth,
-                                 Visual     *visual,
-                                 Colormap    colormap,
-                                 gboolean    rgba)
-{
-  GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
-
-  display_x11->window_depth = depth;
-  display_x11->window_visual = visual;
-  display_x11->window_colormap = colormap;
-
-  gdk_display_set_rgba (display, rgba);
-}
-
 /**
  * gdk_x11_display_open:
  * @display_name: (nullable): name of the X display.
@@ -1420,7 +1404,27 @@ gdk_x11_display_open (const char *display_name)
 #endif
 
   /* initialize the display's screens */ 
-  display_x11->screen = _gdk_x11_screen_new (display, DefaultScreen (display_x11->xdisplay), TRUE);
+  display_x11->screen = _gdk_x11_screen_new (display, DefaultScreen (display_x11->xdisplay));
+
+  if (display_x11->screen->rgba_visual)
+    {
+      Visual *xvisual = GDK_X11_VISUAL (display_x11->screen->rgba_visual)->xvisual;
+
+      display_x11->window_depth = display_x11->screen->rgba_visual->depth;
+      display_x11->window_visual = xvisual;
+      display_x11->window_colormap = XCreateColormap (xdisplay,
+                                                      DefaultRootWindow (xdisplay),
+                                                      xvisual,
+                                                      AllocNone);
+      gdk_display_set_rgba (display, TRUE);
+    }
+  else
+    {
+      display_x11->window_depth = DefaultDepth (xdisplay, DefaultScreen (xdisplay)),
+      display_x11->window_visual = DefaultVisual (xdisplay, DefaultScreen (xdisplay));
+      display_x11->window_colormap = DefaultColormap (xdisplay, DefaultScreen (xdisplay));
+      gdk_display_set_rgba (display, FALSE);
+    }
 
   /* We need to initialize events after we have the screen
    * structures in places
@@ -2032,7 +2036,7 @@ _gdk_x11_display_screen_for_xrootwin (GdkDisplay *display,
   if (gdk_x11_display_error_trap_pop (display) || !result)
     return NULL;
 
-  screen = _gdk_x11_screen_new (display, XScreenNumberOfScreen (attrs.screen), FALSE);
+  screen = _gdk_x11_screen_new (display, XScreenNumberOfScreen (attrs.screen));
 
   display_x11->screens = g_list_prepend (display_x11->screens, screen);
 
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 97155106a5..5a0f565f55 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -55,11 +55,6 @@ typedef GdkFilterReturn (*GdkFilterFunc) (const XEvent *xevent,
 void _gdk_x11_error_handler_push (void);
 void _gdk_x11_error_handler_pop  (void);
 
-void          gdk_display_setup_window_visual            (GdkDisplay     *display,
-                                                          int             depth,
-                                                          Visual         *visual,
-                                                          Colormap        colormap,
-                                                          gboolean        rgba);
 int           gdk_x11_display_get_window_depth           (GdkX11Display  *display);
 Visual *      gdk_x11_display_get_window_visual          (GdkX11Display  *display);
 Colormap      gdk_x11_display_get_window_colormap        (GdkX11Display  *display);
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index 9ab16f6db9..d06ecfb05c 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -866,8 +866,7 @@ init_multihead (GdkX11Screen *screen)
 
 GdkX11Screen *
 _gdk_x11_screen_new (GdkDisplay *display,
-                    int         screen_number,
-                     gboolean    setup_display)
+                    int         screen_number)
 {
   GdkX11Screen *x11_screen;
   GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
@@ -898,7 +897,7 @@ _gdk_x11_screen_new (GdkDisplay *display,
   init_randr_support (x11_screen);
   init_multihead (x11_screen);
 
-  _gdk_x11_screen_init_visuals (x11_screen, setup_display);
+  _gdk_x11_screen_init_visuals (x11_screen);
 
   return x11_screen;
 }
diff --git a/gdk/x11/gdkscreen-x11.h b/gdk/x11/gdkscreen-x11.h
index cba79af75d..2965385d2f 100644
--- a/gdk/x11/gdkscreen-x11.h
+++ b/gdk/x11/gdkscreen-x11.h
@@ -94,8 +94,7 @@ struct _GdkX11ScreenClass
 
 GType       _gdk_x11_screen_get_type (void);
 GdkX11Screen *_gdk_x11_screen_new           (GdkDisplay   *display,
-                                             int           screen_number,
-                                             gboolean      setup_display);
+                                             int           screen_number);
 
 void _gdk_x11_screen_window_manager_changed (GdkX11Screen *screen);
 void _gdk_x11_screen_size_changed           (GdkX11Screen *screen,
@@ -120,8 +119,7 @@ _gdk_x11_screen_get_xft_setting             (GdkX11Screen *screen,
                                              const char   *name,
                                              GValue       *value);
 
-void _gdk_x11_screen_init_visuals           (GdkX11Screen *screen,
-                                             gboolean      setup_display);
+void _gdk_x11_screen_init_visuals           (GdkX11Screen *screen);
 
 G_END_DECLS
 
diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c
index 1e48e477a7..0a6ec4adda 100644
--- a/gdk/x11/gdkvisual-x11.c
+++ b/gdk/x11/gdkvisual-x11.c
@@ -50,8 +50,7 @@ gdk_x11_visual_class_init (GdkX11VisualClass *class)
 }
 
 void
-_gdk_x11_screen_init_visuals (GdkX11Screen *x11_screen,
-                              gboolean      setup_display)
+_gdk_x11_screen_init_visuals (GdkX11Screen *x11_screen)
 {
   static const int possible_depths[8] = { 32, 30, 24, 16, 15, 8, 4, 1 };
   static const GdkVisualType possible_types[6] =
@@ -254,33 +253,6 @@ _gdk_x11_screen_init_visuals (GdkX11Screen *x11_screen,
    * stereo and double buffering
    */
   gdk_x11_screen_update_visuals_for_glx (x11_screen);
-
-  if (setup_display)
-    {
-      if (x11_screen->rgba_visual)
-        {
-          Visual *xvisual = GDK_X11_VISUAL (x11_screen->rgba_visual)->xvisual;
-          Colormap colormap;
-          
-          colormap = XCreateColormap (x11_screen->xdisplay,
-                                      RootWindow (x11_screen->xdisplay, x11_screen->screen_num),
-                                      xvisual,
-                                      AllocNone);
-          gdk_display_setup_window_visual (GDK_SCREEN_DISPLAY (x11_screen),
-                                           x11_screen->rgba_visual->depth,
-                                           GDK_X11_VISUAL (x11_screen->rgba_visual)->xvisual,
-                                           colormap,
-                                           TRUE);
-        }
-      else
-        {
-          gdk_display_setup_window_visual (GDK_SCREEN_DISPLAY (x11_screen),
-                                           DefaultDepth (x11_screen->xdisplay, x11_screen->screen_num),
-                                           DefaultVisual (x11_screen->xdisplay, x11_screen->screen_num),
-                                           DefaultColormap (x11_screen->xdisplay, x11_screen->screen_num),
-                                           FALSE);
-        }
-    }
 }
 
 /*< private >


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]