Procházet zdrojové kódy

WindowServer: Tell WSWindows who their CObject parent is

Instead of using a weird "internal owner" pointer, just set the owning
object as the CObject::parent of WSWindow.
Andreas Kling před 6 roky
rodič
revize
9d57e7ed68

+ 8 - 5
Servers/WindowServer/WSWindow.cpp

@@ -18,8 +18,8 @@ static GraphicsBitmap& default_window_icon()
     return *s_icon;
 }
 
-WSWindow::WSWindow(CObject& internal_owner, WSWindowType type)
-    : m_internal_owner(&internal_owner)
+WSWindow::WSWindow(CObject& parent, WSWindowType type)
+    : CObject(&parent)
     , m_type(type)
     , m_icon(default_window_icon())
     , m_frame(*this)
@@ -28,7 +28,8 @@ WSWindow::WSWindow(CObject& internal_owner, WSWindowType type)
 }
 
 WSWindow::WSWindow(WSClientConnection& client, WSWindowType window_type, int window_id, bool modal, bool resizable, bool fullscreen)
-    : m_client(&client)
+    : CObject(&client)
+    , m_client(&client)
     , m_type(window_type)
     , m_modal(modal)
     , m_resizable(resizable)
@@ -174,8 +175,10 @@ void WSWindow::set_maximized(bool maximized)
 
 void WSWindow::event(CEvent& event)
 {
-    if (m_internal_owner)
-        return m_internal_owner->event(event);
+    if (!m_client) {
+        ASSERT(parent());
+        return parent()->event(event);
+    }
 
     if (is_blocked_by_modal_window())
         return;

+ 0 - 1
Servers/WindowServer/WSWindow.h

@@ -153,7 +153,6 @@ private:
     void handle_mouse_event(const WSMouseEvent&);
 
     WSClientConnection* m_client { nullptr };
-    CObject* m_internal_owner { nullptr };
     String m_title;
     Rect m_rect;
     WSWindowType m_type { WSWindowType::Normal };