Added X11 window manager resize handling 50/287250/2
authorDavid Steele <david.steele@samsung.com>
Wed, 25 Jan 2023 17:52:21 +0000 (17:52 +0000)
committerDavid Steele <david.steele@samsung.com>
Fri, 27 Jan 2023 11:32:31 +0000 (11:32 +0000)
For Ecore/Raw X, added listeners to the ConfigureNotify
event to find when the Window Manager has modified the
window size.

Sending the UpdatePositionSize signal is enough to
update the GL surface.

Change-Id: I8fd3cf1a9fbac694ea32e5d5cddd710c33a7cdf4
Signed-off-by: David Steele <david.steele@samsung.com>
dali/internal/window-system/common/window-system.h
dali/internal/window-system/ubuntu-x11/window-base-ecore-x.cpp
dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h
dali/internal/window-system/x11/window-base-x.cpp
dali/internal/window-system/x11/window-base-x.h
dali/internal/window-system/x11/window-system-x.cpp
dali/internal/window-system/x11/window-system-x.h

index d669791..9fa8b5f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOW_SYSTEM_COMMON_WINDOW_SYSTEM_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -88,7 +88,8 @@ public:
     KEY_DOWN,
     KEY_UP,
     SELECTION_CLEAR,
-    SELECTION_NOTIFY
+    SELECTION_NOTIFY,
+    CONFIGURE_NOTIFY,
   };
 
   /**
index 0104a36..e13f26e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -52,6 +52,17 @@ Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false
 // Window Callbacks
 /////////////////////////////////////////////////////////////////////////////////////////////////
 
+static Eina_Bool EcoreEventWindowConfigure(void* data, int type, void* event)
+{
+  WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+  if(windowBase)
+  {
+    windowBase->OnWindowConfigure(event);
+  }
+
+  return ECORE_CALLBACK_PASS_ON;
+}
+
 static Eina_Bool EcoreEventWindowPropertyChanged(void* data, int type, void* event)
 {
   WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
@@ -313,6 +324,7 @@ void WindowBaseEcoreX::Initialize(PositionSize positionSize, Any surface, bool i
   // Enable Drag & Drop
   ecore_x_dnd_aware_set(mEcoreWindow, EINA_TRUE);
 
+  mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE, EcoreEventWindowConfigure, this));
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, EcoreEventWindowPropertyChanged, this));
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, EcoreEventWindowDeleteRequest, this));
 
@@ -341,6 +353,20 @@ void WindowBaseEcoreX::Initialize(PositionSize positionSize, Any surface, bool i
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, EcoreEventSelectionNotify, this));
 }
 
+void WindowBaseEcoreX::OnWindowConfigure(void* event)
+{
+  auto configure = static_cast<Ecore_X_Event_Window_Configure*>(event);
+  if(configure->win == mEcoreWindow)
+  {
+    Dali::PositionSize positionSize;
+    positionSize.x      = configure->x;
+    positionSize.y      = configure->y;
+    positionSize.width  = configure->w;
+    positionSize.height = configure->h;
+    mUpdatePositionSizeSignal.Emit(positionSize);
+  }
+}
+
 Eina_Bool WindowBaseEcoreX::OnWindowPropertyChanged(void* data, int type, void* event)
 {
   Ecore_X_Event_Window_Property* propertyChangedEvent = static_cast<Ecore_X_Event_Window_Property*>(event);
index d0b069d..054aa9c 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_ECOREX_WINDOW_BASE_ECORE_X_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,6 +49,11 @@ public:
 
 public:
   /**
+   * @brief Called when the window configuration is changed.
+   */
+  void OnWindowConfigure(void* event);
+
+  /**
    * @brief Called when the window property is changed.
    */
   Eina_Bool OnWindowPropertyChanged(void* data, int type, void* event);
index c07f0e8..9dd0b5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,6 +53,17 @@ Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false
 // Window Callbacks
 /////////////////////////////////////////////////////////////////////////////////////////////////
 
+static bool EventWindowConfigureNotify(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
+{
+  WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
+  if(windowBase)
+  {
+    windowBase->OnConfigure(event);
+  }
+
+  return false;
+}
+
 static bool EventWindowPropertyChanged(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
 {
   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
@@ -326,6 +337,7 @@ void WindowBaseX::EnableDragAndDrop()
 void WindowBaseX::SetupEvents()
 {
   auto& windowSystem = WindowSystem::GetImplementation();
+  windowSystem.AddEventHandler(WindowSystemBase::Event::CONFIGURE_NOTIFY, EventWindowConfigureNotify, this);
   windowSystem.AddEventHandler(WindowSystemBase::Event::PROPERTY_NOTIFY, EventWindowPropertyChanged, this);
   windowSystem.AddEventHandler(WindowSystemBase::Event::DELETE_REQUEST, EventWindowDeleteRequest, this);
   windowSystem.AddEventHandler(WindowSystemBase::Event::FOCUS_IN, EventWindowFocusIn, this);
@@ -389,6 +401,22 @@ bool WindowBaseX::OnWindowPropertyChanged(void* data, WindowSystemBase::Event ty
   return handled;
 }
 
+void WindowBaseX::OnConfigure(WindowSystemBase::EventBase* event)
+{
+  auto configureEvent = static_cast<WindowSystemX::X11ConfigureNotifyEvent*>(event);
+  if(configureEvent->window == mWindow)
+  {
+    DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window::OnConfigureNotify\n");
+    Dali::PositionSize positionSize;
+    positionSize.x      = configureEvent->x;
+    positionSize.y      = configureEvent->y;
+    positionSize.width  = configureEvent->width;
+    positionSize.height = configureEvent->height;
+    /// @note Can also get the window below this one if raise/lower was called.
+    mUpdatePositionSizeSignal.Emit(positionSize);
+  }
+}
+
 void WindowBaseX::OnDeleteRequest()
 {
   mDeleteRequestSignal.Emit();
index bcd46be..a3bd1f1 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOW_SYSTEM_X11_WINDOW_BASE_X_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,6 +48,11 @@ public:
 
 public:
   /**
+   * @brief Called when the window has been moved/resized
+   */
+  void OnConfigure(WindowSystemBase::EventBase* event);
+
+  /**
    * @brief Called when the window property is changed.
    */
   bool OnWindowPropertyChanged(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event);
index d439812..616c6f2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -202,6 +202,20 @@ struct DeleteWindowRequest
   ::Window* window;
 };
 
+void ConfigureNotifyEventHandler(const XEvent* xevent)
+{
+  WindowSystemX::X11ConfigureNotifyEvent configureNotify;
+  configureNotify.window = xevent->xconfigure.window;
+  configureNotify.event  = xevent;
+
+  configureNotify.x      = xevent->xconfigure.x;
+  configureNotify.y      = xevent->xconfigure.y;
+  configureNotify.width  = xevent->xconfigure.width;
+  configureNotify.height = xevent->xconfigure.height;
+
+  GetImplementation().TriggerEventHandler(WindowSystemBase::Event::CONFIGURE_NOTIFY, configureNotify);
+}
+
 void PropertyNotifyEventHandler(const XEvent* xevent)
 {
   WindowSystemX::X11PropertyNotifyEvent propertyNotifyEvent;
@@ -513,6 +527,7 @@ struct WindowSystemX::Impl
     mXEventHandlers[KeyRelease]      = &KeyReleaseEventHandler;
     mXEventHandlers[SelectionClear]  = &SelectionClearEventHandler;
     mXEventHandlers[SelectionNotify] = &SelectionNotifyEventHandler;
+    mXEventHandlers[ConfigureNotify] = &ConfigureNotifyEventHandler;
   }
 
   void InitializeInput()
@@ -718,6 +733,7 @@ void WindowSystemX::DeleteEventHandler(WindowSystemBase::EventHandler* eventHand
                            EnterWindowMask |
                            LeaveWindowMask |
                            PointerMotionMask |
+                           StructureNotifyMask |
                            ExposureMask |
                            VisibilityChangeMask |
                            StructureNotifyMask |
index 11e1022..67b41d9 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOW_SYSTEM_X11_WINDOW_SYSTEM_H
 
 /*
- * COPYRIGHT (c) 2022 Samsung Electronics Co., Ltd.
+ * COPYRIGHT (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -92,6 +92,18 @@ public:
   };
 
   /**
+   * Event struct that is sent when a window is moved/resized/lowered/raised
+   */
+  struct X11ConfigureNotifyEvent : public X11Event
+  {
+    int      x; // Relative to parent window's origin.
+    int      y;
+    int      width;
+    int      height;
+    ::Window above; // The window that this is now above.
+  };
+
+  /**
    * Event struct that is sent when a window property is changed.
    */
   struct X11PropertyNotifyEvent : public X11Event