]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/reparent.cpp
Fix recursion problems when loading pages from a virtual file system using the WebKit...
[wxWidgets.git] / src / x11 / reparent.cpp
index 7e76d2334d040a052f4eb4aa3c4ee2bd4a63f447..ff976cd946f0d79abe936bf9854a6e9fec89e5a5 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        reparent.cpp
+// Name:        src/x11/reparent.cpp
 // Purpose:     wxWindow
 // Author:      Julian Smart
 // Modified by:
 // Purpose:     wxWindow
 // Author:      Julian Smart
 // Modified by:
@@ -9,6 +9,13 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#if defined(__BORLANDC__)
+#pragma hdrstop
+#endif
+
 // ============================================================================
 // declarations
 // ============================================================================
 // ============================================================================
 // declarations
 // ============================================================================
 // headers
 // ----------------------------------------------------------------------------
 
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "reparent.h"
-#endif
-
-#include "wx/setup.h"
-
 #if !wxUSE_NANOX
 
 #include "wx/x11/reparent.h"
 #if !wxUSE_NANOX
 
 #include "wx/x11/reparent.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/log.h"
+    #include "wx/app.h"
+    #include "wx/timer.h"
+#endif
+
 #include "wx/evtloop.h"
 #include "wx/evtloop.h"
-#include "wx/log.h"
-#include "wx/app.h"
-#include "wx/timer.h"
 
 #include "wx/x11/private.h"
 #include "X11/Xatom.h"
 
 
 #include "wx/x11/private.h"
 #include "X11/Xatom.h"
 
+#include "wx/generic/private/timer.h"
+
 /*
  * wxAdoptedWindow
  */
 /*
  * wxAdoptedWindow
  */
@@ -57,13 +64,13 @@ wxAdoptedWindow::~wxAdoptedWindow()
 
 static bool Xerror;
 static Atom WM_STATE = 0;
 
 static bool Xerror;
 static Atom WM_STATE = 0;
-bool wxReparenter::sm_done = FALSE;
+bool wxReparenter::sm_done = false;
 wxAdoptedWindow* wxReparenter::sm_toReparent = NULL;
 wxWindow* wxReparenter::sm_newParent = NULL;
 wxString wxReparenter::sm_name;
 wxAdoptedWindow* wxReparenter::sm_toReparent = NULL;
 wxWindow* wxReparenter::sm_newParent = NULL;
 wxString wxReparenter::sm_name;
-bool wxReparenter::sm_exactMatch = FALSE;
+bool wxReparenter::sm_exactMatch = false;
 
 
-static int ErrorHandler(Display* dpy, XErrorEvent* event)
+static int ErrorHandler(Display* WXUNUSED(dpy), XErrorEvent* WXUNUSED(event))
 {
     Xerror = True;
     return False;
 {
     Xerror = True;
     return False;
@@ -82,17 +89,17 @@ bool wxReparenter::Reparent(wxWindow* newParent, wxAdoptedWindow* toReparent)
 
     old = XSetErrorHandler(ErrorHandler);
     XReparentWindow( wxGlobalDisplay(),
 
     old = XSetErrorHandler(ErrorHandler);
     XReparentWindow( wxGlobalDisplay(),
-                     (Window) toReparent->GetMainWindow(),
-                     (Window) newParent->GetMainWindow(),
+                     (Window) toReparent->X11GetMainWindow(),
+                     (Window) newParent->X11GetMainWindow(),
                      0, 0);
 
     if (!XQueryTree( wxGlobalDisplay(),
                      0, 0);
 
     if (!XQueryTree( wxGlobalDisplay(),
-                     (Window) toReparent->GetMainWindow(),
+                     (Window) toReparent->X11GetMainWindow(),
                      &returnroot, &returnparent,
                      &children, &numchildren) || Xerror)
     {
         XSetErrorHandler(old);
                      &returnroot, &returnparent,
                      &children, &numchildren) || Xerror)
     {
         XSetErrorHandler(old);
-        return TRUE;
+        return true;
     }
 
     if (numchildren > 0)
     }
 
     if (numchildren > 0)
@@ -116,17 +123,17 @@ bool wxReparenter::Reparent(wxWindow* newParent, wxAdoptedWindow* toReparent)
               "Reparenting child at offset %d and position %d, %d.\n",
                parentOffset, parentOffset+xwa.x, parentOffset+xwa.y);
             XReparentWindow( wxGlobalDisplay(),
               "Reparenting child at offset %d and position %d, %d.\n",
                parentOffset, parentOffset+xwa.x, parentOffset+xwa.y);
             XReparentWindow( wxGlobalDisplay(),
-                             children[each], (Window) newParent->GetMainWindow(),
+                             children[each], (Window) newParent->X11GetMainWindow(),
                              xwa.x, xwa.y);
         }
     }
 
     XSetErrorHandler(old);
                              xwa.x, xwa.y);
         }
     }
 
     XSetErrorHandler(old);
-    return TRUE;
+    return true;
 }
 
 // Wait for an appropriate window to be created.
 }
 
 // Wait for an appropriate window to be created.
-// If exactMatch is FALSE, a substring match is OK.
+// If exactMatch is false, a substring match is OK.
 // If windowName is empty, then wait for the next overrideRedirect window.
 bool wxReparenter::WaitAndReparent(wxWindow* newParent, wxAdoptedWindow* toReparent,
                                    const wxString& windowName,
 // If windowName is empty, then wait for the next overrideRedirect window.
 bool wxReparenter::WaitAndReparent(wxWindow* newParent, wxAdoptedWindow* toReparent,
                                    const wxString& windowName,
@@ -136,7 +143,7 @@ bool wxReparenter::WaitAndReparent(wxWindow* newParent, wxAdoptedWindow* toRepar
     sm_toReparent = toReparent;
     sm_exactMatch = exactMatch;
     sm_name = windowName;
     sm_toReparent = toReparent;
     sm_exactMatch = exactMatch;
     sm_name = windowName;
-    
+
     Display* display = wxGlobalDisplay();
     XSelectInput(display,
         RootWindowOfScreen(DefaultScreenOfDisplay(display)),
     Display* display = wxGlobalDisplay();
     XSelectInput(display,
         RootWindowOfScreen(DefaultScreenOfDisplay(display)),
@@ -145,12 +152,7 @@ bool wxReparenter::WaitAndReparent(wxWindow* newParent, wxAdoptedWindow* toRepar
     if (!WM_STATE)
         WM_STATE = XInternAtom(display, "WM_STATE", False);
 
     if (!WM_STATE)
         WM_STATE = XInternAtom(display, "WM_STATE", False);
 
-#ifdef __WXDEBUG__
-    if (!windowName.IsEmpty())
-        wxLogDebug(_T("Waiting for window %s"), windowName.c_str());
-#endif
-    
-    sm_done = FALSE;
+    sm_done = false;
 
     wxEventLoop eventLoop;
     while (!sm_done)
 
     wxEventLoop eventLoop;
     while (!sm_done)
@@ -168,12 +170,12 @@ bool wxReparenter::WaitAndReparent(wxWindow* newParent, wxAdoptedWindow* toRepar
         else
         {
 #if wxUSE_TIMER
         else
         {
 #if wxUSE_TIMER
-            wxTimer::NotifyTimers();
+            wxGenericTimerImpl::NotifyTimers();
             wxTheApp->ProcessIdle();
 #endif
         }
     }
             wxTheApp->ProcessIdle();
 #endif
         }
     }
-    return TRUE;
+    return true;
 }
 
 bool wxReparenter::ProcessXEvent(WXEvent* event)
 }
 
 bool wxReparenter::ProcessXEvent(WXEvent* event)
@@ -185,15 +187,15 @@ bool wxReparenter::ProcessXEvent(WXEvent* event)
     {
         if (xevent->type == MapNotify)
         {
     {
         if (xevent->type == MapNotify)
         {
-            wxLogDebug(_T("Window was mapped"));
+            wxLogDebug(wxT("Window was mapped"));
         }
         }
-        
+
         if (xevent->type == MapNotify && !xevent->xmap.override_redirect &&
             (client = (Window) FindAClientWindow((WXWindow) xevent->xmap.window, sm_name)))
         {
         if (xevent->type == MapNotify && !xevent->xmap.override_redirect &&
             (client = (Window) FindAClientWindow((WXWindow) xevent->xmap.window, sm_name)))
         {
-            wxLogDebug(_T("Found a client window, about to reparent"));
+            wxLogDebug(wxT("Found a client window, about to reparent"));
             wxASSERT(sm_toReparent->GetParent() == NULL);
             wxASSERT(sm_toReparent->GetParent() == NULL);
-            
+
             sm_toReparent->SetHandle((WXWindow) client);
             sm_newParent->AddChild(sm_toReparent);
             sm_done = Reparent(sm_newParent, sm_toReparent);
             sm_toReparent->SetHandle((WXWindow) client);
             sm_newParent->AddChild(sm_toReparent);
             sm_done = Reparent(sm_newParent, sm_toReparent);
@@ -202,16 +204,16 @@ bool wxReparenter::ProcessXEvent(WXEvent* event)
                    xevent->xmap.override_redirect &&
                    xevent->xmap.window)
         {
                    xevent->xmap.override_redirect &&
                    xevent->xmap.window)
         {
-            wxLogDebug(_T("Found an override redirect window, about to reparent"));
+            wxLogDebug(wxT("Found an override redirect window, about to reparent"));
             sm_toReparent->SetHandle((WXWindow) xevent->xmap.window);
             sm_newParent->AddChild(sm_toReparent);
             wxASSERT(sm_toReparent->GetParent() == NULL);
             sm_toReparent->SetHandle((WXWindow) xevent->xmap.window);
             sm_newParent->AddChild(sm_toReparent);
             wxASSERT(sm_toReparent->GetParent() == NULL);
-            
+
             sm_done = Reparent(sm_newParent, sm_toReparent);
             return sm_done;
         }
     }
             sm_done = Reparent(sm_newParent, sm_toReparent);
             return sm_done;
         }
     }
-    return FALSE;
+    return false;
 }
 
 WXWindow wxReparenter::FindAClientWindow(WXWindow window, const wxString& name)
 }
 
 WXWindow wxReparenter::FindAClientWindow(WXWindow window, const wxString& name)
@@ -227,7 +229,7 @@ WXWindow wxReparenter::FindAClientWindow(WXWindow window, const wxString& name)
     Window result = 0;
     XErrorHandler old;
     char *clientName;
     Window result = 0;
     XErrorHandler old;
     char *clientName;
-    
+
     Xerror = False;
     old = XSetErrorHandler(ErrorHandler);
     rvalue = XGetWindowProperty((Display*) wxGetDisplay(),
     Xerror = False;
     old = XSetErrorHandler(ErrorHandler);
     rvalue = XGetWindowProperty((Display*) wxGetDisplay(),
@@ -245,26 +247,26 @@ WXWindow wxReparenter::FindAClientWindow(WXWindow window, const wxString& name)
             XFree((char *) propreturn);
         }
         XFetchName((Display*) wxGetDisplay(), (Window) window, &clientName);
             XFree((char *) propreturn);
         }
         XFetchName((Display*) wxGetDisplay(), (Window) window, &clientName);
-        
+
         wxString str1(name);
         wxString str2 = wxString::FromAscii(clientName);
         str1.Lower();
         str2.Lower();
         wxString str1(name);
         wxString str2 = wxString::FromAscii(clientName);
         str1.Lower();
         str2.Lower();
-        
+
         bool matches;
         if (sm_exactMatch)
             matches = (name == wxString::FromAscii(clientName));
         else
             matches = (str1.Contains(str2) || str2.Contains(str1));
         bool matches;
         if (sm_exactMatch)
             matches = (name == wxString::FromAscii(clientName));
         else
             matches = (str1.Contains(str2) || str2.Contains(str1));
-        
+
         XFree(clientName);
         XFree(clientName);
-        
+
         if (matches)
             return (WXWindow) window;
         else
             return NULL;
     }
         if (matches)
             return (WXWindow) window;
         else
             return NULL;
     }
-    
+
     old = XSetErrorHandler(ErrorHandler);
     if (!XQueryTree((Display*) wxGetDisplay(), (Window) window, &returnroot, &returnparent,
         &children, &numchildren) || Xerror)
     old = XSetErrorHandler(ErrorHandler);
     if (!XQueryTree((Display*) wxGetDisplay(), (Window) window, &returnroot, &returnparent,
         &children, &numchildren) || Xerror)
@@ -273,7 +275,7 @@ WXWindow wxReparenter::FindAClientWindow(WXWindow window, const wxString& name)
         return NULL;
     }
     XSetErrorHandler(old);
         return NULL;
     }
     XSetErrorHandler(old);
-    
+
     result = 0;
     for (i=0; i<(int)numchildren && !result ;i++) {
         result = (Window) FindAClientWindow((WXWindow) children[i], name);
     result = 0;
     for (i=0; i<(int)numchildren && !result ;i++) {
         result = (Window) FindAClientWindow((WXWindow) children[i], name);
@@ -283,4 +285,4 @@ WXWindow wxReparenter::FindAClientWindow(WXWindow window, const wxString& name)
     } return (WXWindow) result;
 }
 
     } return (WXWindow) result;
 }
 
-#endif
+#endif // !wxUSE_NANOX