aboutsummaryrefslogtreecommitdiff
path: root/contrib/wx-patches/toplevel.cpp.diff
blob: 359abf28d44f28cb945ab90296108e81bf997d03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
--- /wxWidgets/trunk/src/gtk/toplevel.cpp (revision 67326)
+++ /wxWidgets/trunk/src/gtk/toplevel.cpp (revision 67496)
@@ -72,4 +72,8 @@
 // send any activate events at all
 static int g_sendActivateEvent = -1;
+
+// Whether _NET_REQUEST_FRAME_EXTENTS support is working
+//   0 == not tested yet, 1 == working, 2 == broken
+static int gs_requestFrameExtentsStatus;
 
 //-----------------------------------------------------------------------------
@@ -432,4 +436,12 @@
     if (event->state == GDK_PROPERTY_NEW_VALUE && event->atom == property)
     {
+        if (win->m_netFrameExtentsTimerId)
+        {
+            // WM support for _NET_REQUEST_FRAME_EXTENTS is working
+            gs_requestFrameExtentsStatus = 1;
+            g_source_remove(win->m_netFrameExtentsTimerId);
+            win->m_netFrameExtentsTimerId = 0;
+        }
+
         wxSize decorSize = win->m_decorSize;
         int left, right, top, bottom;
@@ -439,4 +451,22 @@
         win->GTKUpdateDecorSize(decorSize);
     }
+    return false;
+}
+}
+
+extern "C" {
+static gboolean request_frame_extents_timeout(void* data)
+{
+    // WM support for _NET_REQUEST_FRAME_EXTENTS is broken
+    gs_requestFrameExtentsStatus = 2;
+    gdk_threads_enter();
+    wxTopLevelWindowGTK* win = static_cast<wxTopLevelWindowGTK*>(data);
+    win->m_netFrameExtentsTimerId = 0;
+    wxSize decorSize = win->m_decorSize;
+    int left, right, top, bottom;
+    if (wxGetFrameExtents(gtk_widget_get_window(win->m_widget), &left, &right, &top, &bottom))
+        decorSize.Set(left + right, top + bottom);
+    win->GTKUpdateDecorSize(decorSize);
+    gdk_threads_leave();
     return false;
 }
@@ -459,4 +489,5 @@
     m_deferShowAllowed = true;
     m_updateDecorSize = true;
+    m_netFrameExtentsTimerId = 0;
 
     m_urgency_hint = -2;
@@ -811,5 +842,6 @@
     if (deferShow)
     {
-        deferShow = m_deferShowAllowed && !GTK_WIDGET_REALIZED(m_widget);
+        deferShow = gs_requestFrameExtentsStatus != 2 &&
+            m_deferShowAllowed && !gtk_widget_get_realized(m_widget);
         if (deferShow)
         {
@@ -829,11 +861,4 @@
             // GetSize()/SetSize() because it makes window bigger between each
             // restore and save.
-            m_updateDecorSize = deferShow;
-        }
-        if (deferShow)
-        {
-            // Fluxbox support for _NET_REQUEST_FRAME_EXTENTS is broken
-            const char* name = gdk_x11_screen_get_window_manager_name(screen);
-            deferShow = strcmp(name, "Fluxbox") != 0;
             m_updateDecorSize = deferShow;
         }
@@ -875,4 +900,12 @@
             (XEvent*)&xevent);
 
+        if (gs_requestFrameExtentsStatus == 0)
+        {
+            // if WM does not respond to request within 1 second,
+            // we assume support for _NET_REQUEST_FRAME_EXTENTS is not working
+            m_netFrameExtentsTimerId =
+                g_timeout_add(1000, request_frame_extents_timeout, this);
+        }
+
         // defer calling gtk_widget_show()
         m_isShown = true;