X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6a44bffd1ac68163e4c1cfe8aa8fe4f7f98a02e7..5a750e5a171692168485d44e168a870904e06659:/src/x11/window.cpp diff --git a/src/x11/window.cpp b/src/x11/window.cpp index d20a6b9190..72833485e9 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -121,11 +121,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, CreateBase(parent, id, pos, size, style, wxDefaultValidator, name); - if (parent) - parent->AddChild(this); - - m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); - m_foregroundColour = *wxBLACK; + parent->AddChild(this); int w = size.GetWidth(); int h = size.GetHeight(); @@ -136,18 +132,27 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, if (x == -1) x = 0; if (y == -1) y = 0; - int screen = DefaultScreen(wxGlobalDisplay()); + Display *xdisplay = (Display*) wxGlobalDisplay(); + int xscreen = DefaultScreen( xdisplay ); + Colormap cm = DefaultColormap( xdisplay, xscreen ); - Window parentWindow; - if (parent) - parentWindow = (Window) parent->GetMainWindow(); - else - parentWindow = RootWindow(wxGlobalDisplay(), screen); + m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); + m_backgroundColour.CalcPixel( (WXColormap) cm ); + m_hasBgCol = TRUE; + + m_foregroundColour = *wxBLACK; + m_foregroundColour.CalcPixel( (WXColormap) cm ); + - Window window = XCreateSimpleWindow(wxGlobalDisplay(), parentWindow, - x, y, w, h, 0, - m_backgroundColour.AllocColour(wxGlobalDisplay()), - m_foregroundColour.AllocColour(wxGlobalDisplay())); + Window parentWindow = (Window) parent->GetMainWindow(); + + Window window = XCreateSimpleWindow( + xdisplay, parentWindow, + x, y, w, h, 0, + m_backgroundColour.GetPixel(), + m_backgroundColour.GetPixel() ); + + m_mainWidget = (WXWindow) window; // Select event types wanted XSelectInput(wxGlobalDisplay(), window, @@ -254,17 +259,23 @@ bool wxWindowX11::Enable(bool enable) bool wxWindowX11::Show(bool show) { - if ( !wxWindowBase::Show(show) ) - return FALSE; + wxWindowBase::Show(show); Window xwin = (Window) GetXWindow(); Display *xdisp = (Display*) GetXDisplay(); if (show) { + wxString msg; + msg.Printf("Mapping window of type %s", GetClassInfo()->GetClassName()); + wxLogDebug(msg); XMapWindow(xdisp, xwin); + XSync(xdisp, False); } else { + wxString msg; + msg.Printf("Unmapping window of type %s", GetClassInfo()->GetClassName()); + wxLogDebug(msg); XUnmapWindow(xdisp, xwin); } @@ -287,10 +298,21 @@ void wxWindowX11::Lower() void wxWindowX11::DoCaptureMouse() { - g_captureWindow = (wxWindow*) this; + if ((g_captureWindow != NULL) && (g_captureWindow != this)) + { + wxASSERT_MSG(FALSE, "Trying to capture before mouse released."); + + // Core dump now + int *tmp = NULL; + (*tmp) = 1; + return; + } + if ( m_winCaptured ) return; + g_captureWindow = (wxWindow*) this; + if (GetMainWindow()) { int res = XGrabPointer(wxGlobalDisplay(), (Window) GetMainWindow(), @@ -304,10 +326,19 @@ void wxWindowX11::DoCaptureMouse() if (res != GrabSuccess) { - wxLogDebug("Failed to grab pointer."); + wxString msg; + msg.Printf("Failed to grab pointer for window %s", this->GetClassInfo()->GetClassName()); + wxLogDebug(msg); + if (res == GrabNotViewable) + { + wxLogDebug("This is not a viewable window - perhaps not shown yet?"); + } + g_captureWindow = NULL; return; } + wxLogDebug("Grabbed pointer"); +#if 0 res = XGrabButton(wxGlobalDisplay(), AnyButton, AnyModifier, (Window) GetMainWindow(), FALSE, @@ -316,16 +347,22 @@ void wxWindowX11::DoCaptureMouse() GrabModeAsync, None, None); - + if (res != GrabSuccess) { wxLogDebug("Failed to grab mouse buttons."); XUngrabPointer(wxGlobalDisplay(), CurrentTime); return; } +#endif +#if 0 res = XGrabKeyboard(wxGlobalDisplay(), (Window) GetMainWindow(), +#if 0 + ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask, +#else FALSE, +#endif GrabModeAsync, GrabModeAsync, CurrentTime); @@ -334,11 +371,14 @@ void wxWindowX11::DoCaptureMouse() { wxLogDebug("Failed to grab keyboard."); XUngrabPointer(wxGlobalDisplay(), CurrentTime); +#if 0 XUngrabButton(wxGlobalDisplay(), AnyButton, AnyModifier, (Window) GetMainWindow()); +#endif return; } - +#endif + m_winCaptured = TRUE; } } @@ -354,10 +394,13 @@ void wxWindowX11::DoReleaseMouse() if ( wMain ) { XUngrabPointer(wxGlobalDisplay(), wMain); +#if 0 XUngrabButton(wxGlobalDisplay(), AnyButton, AnyModifier, wMain); XUngrabKeyboard(wxGlobalDisplay(), CurrentTime); +#endif } + wxLogDebug("Ungrabbed pointer"); m_winCaptured = FALSE; } @@ -406,6 +449,7 @@ void wxWindowX11::WarpPointer (int x, int y) // Does a physical scroll void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect) { +#if 0 int x, y, w, h; if (rect) { @@ -568,10 +612,7 @@ void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect) delete rect; node = node->Next(); } - - // TODO - - // XmUpdateDisplay((Widget) GetMainWidget()); +#endif } // --------------------------------------------------------------------------- @@ -692,7 +733,7 @@ void wxWindowX11::DoGetClientSize(int *x, int *y) const if (window) { XWindowAttributes attr; - Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr); + Status status = XGetWindowAttributes( wxGlobalDisplay(), window, &attr ); wxASSERT(status); if (status) @@ -713,11 +754,15 @@ void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags) if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { + int yy = 0; + AdjustForParentClientOrigin( x, yy, sizeFlags); windowChanges.x = x; valueMask |= CWX; } if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { + int xx = 0; + AdjustForParentClientOrigin( xx, y, sizeFlags); windowChanges.y = y; valueMask |= CWY; } @@ -731,7 +776,6 @@ void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags) windowChanges.height = height /* -m_borderSize*2*/; valueMask |= CWHeight; } - AdjustForParentClientOrigin( x, y, sizeFlags); XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(), valueMask, & windowChanges); @@ -947,7 +991,7 @@ void wxWindowX11::X11SendPaintEvents() { m_clipPaintRegion = TRUE; - if (!m_clearRegion.IsEmpty()) + // if (!m_clearRegion.IsEmpty()) { wxWindowDC dc( (wxWindow*)this ); dc.SetClippingRegion( m_clearRegion ); @@ -960,7 +1004,8 @@ void wxWindowX11::X11SendPaintEvents() wxRegionIterator upd( m_clearRegion ); while (upd) { - // XClearArea( ... , upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() ); + XClearArea( wxGlobalDisplay(), (Window) m_mainWidget, + upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight(), False ); upd ++; } } @@ -1303,14 +1348,20 @@ int wxComputeColours (Display *display, wxColour * back, wxColour * fore) bool wxWindowX11::SetBackgroundColour(const wxColour& col) { - if ( !wxWindowBase::SetBackgroundColour(col) ) - return FALSE; + wxWindowBase::SetBackgroundColour(col); if (!GetMainWindow()) return FALSE; + Display *xdisplay = (Display*) wxGlobalDisplay(); + int xscreen = DefaultScreen( xdisplay ); + Colormap cm = DefaultColormap( xdisplay, xscreen ); + + wxColour colour( col ); + colour.CalcPixel( (WXColormap) cm ); + XSetWindowAttributes attrib; - attrib.background_pixel = ((wxColour&)col).AllocColour(wxGlobalDisplay()); + attrib.background_pixel = colour.GetPixel(); XChangeWindowAttributes(wxGlobalDisplay(), (Window) GetMainWindow(),