[gtk/wip.win32.fixes: 5/5] gdk/win32: Fix initial display of windows




commit d40da04fc0a6600207fb9277883e043cb8906799
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Thu Dec 31 16:36:41 2020 +0800

    gdk/win32: Fix initial display of windows
    
    Have a bare-bones implementation of ->request_layout() and
    ->compute_size() for the Win32 surface backend so that we can properly
    display and move the windows, as we request from the Win32 APIs.
    
    Resizing is yet to be implemented and fixed...

 gdk/win32/gdksurface-win32.c | 36 ++++++++++++++++++++++++++++++++++++
 gdk/win32/gdksurface-win32.h |  5 +++++
 2 files changed, 41 insertions(+)
---
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index b581c2a4ca..47e4031108 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -1090,6 +1090,8 @@ gdk_win32_surface_resize (GdkSurface *window,
                            outer_rect.bottom - outer_rect.top,
                            SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER));
   window->resize_count += 1;
+
+  gdk_surface_request_layout (window);
 }
 
 static void
@@ -4448,6 +4450,38 @@ gdk_win32_surface_set_input_region (GdkSurface     *window,
    */
 }
 
+static void
+_gdk_win32_surface_request_layout (GdkSurface *surface)
+{
+  GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
+  RECT rect;
+  int scale = impl->surface_scale;
+
+  _gdk_win32_get_window_rect (surface, &rect);
+
+  impl->unscaled_width = rect.right - rect.left;
+  impl->unscaled_height = rect.bottom - rect.top;
+
+  impl->next_layout.configured_width = (impl->unscaled_width + scale - 1) / scale;
+  impl->next_layout.configured_height = (impl->unscaled_height + scale - 1) / scale;
+
+  surface->x = rect.left / scale;
+  surface->y = rect.top / scale;
+}
+
+static gboolean
+_gdk_win32_surface_compute_size (GdkSurface *surface)
+{
+  GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
+
+  surface->width = impl->next_layout.configured_width;
+  surface->height = impl->next_layout.configured_height;
+
+  _gdk_surface_update_size (surface);
+
+  return FALSE;
+}
+
 static void
 gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass)
 {
@@ -4474,6 +4508,8 @@ gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass)
   impl_class->create_gl_context = _gdk_win32_surface_create_gl_context;
   impl_class->get_scale_factor = _gdk_win32_surface_get_scale_factor;
   impl_class->get_unscaled_size = _gdk_win32_surface_get_unscaled_size;
+  impl_class->request_layout = _gdk_win32_surface_request_layout;
+  impl_class->compute_size = _gdk_win32_surface_compute_size;
 }
 
 HGDIOBJ
diff --git a/gdk/win32/gdksurface-win32.h b/gdk/win32/gdksurface-win32.h
index a8def428e0..d29e3a1cd4 100644
--- a/gdk/win32/gdksurface-win32.h
+++ b/gdk/win32/gdksurface-win32.h
@@ -338,6 +338,11 @@ struct _GdkWin32Surface
   int unscaled_width;
   int unscaled_height;
 
+  struct {
+    int configured_width;
+    int configured_height;
+  } next_layout;
+
 #ifdef GDK_WIN32_ENABLE_EGL
   EGLSurface egl_surface;
   EGLSurface egl_dummy_surface;


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