X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8ac7c5092401be067f7c727ad8e2bf7274c05866..cb7acf9cc78c309026bed1038631f2663cd90bda:/src/x11/window.cpp diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 744cdd6b1d..ed580bbb2e 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -125,6 +125,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, Display *xdisplay = (Display*) wxGlobalDisplay(); int xscreen = DefaultScreen( xdisplay ); + Visual *xvisual = DefaultVisual( xdisplay, xscreen ); Colormap cm = DefaultColormap( xdisplay, xscreen ); m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); @@ -133,35 +134,40 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, m_foregroundColour = *wxBLACK; m_foregroundColour.CalcPixel( (WXColormap) cm ); - Window parentWindow = (Window) parent->GetMainWindow(); + Window xparent = (Window) parent->GetMainWindow(); + XSetWindowAttributes xattributes; + + long xattributes_mask = + CWEventMask | + CWBorderPixel | CWBackPixel; + + xattributes.background_pixel = m_backgroundColour.GetPixel(); + xattributes.border_pixel = BlackPixel( xdisplay, xscreen ); + + xattributes.event_mask = + ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | + KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | + PropertyChangeMask; + wxSize size2(size); if (size2.x == -1) - size2.x = 100; + size2.x = 20; if (size2.y == -1) - size2.y = 100; + size2.y = 20; wxPoint pos2(pos); if (pos2.x == -1) - pos2.x = 100; + pos2.x = 0; if (pos2.y == -1) - pos2.y = 100; + pos2.y = 0; - Window xwindow = XCreateSimpleWindow( - xdisplay, parentWindow, - pos2.x, pos2.y, size2.x, size2.y, 0, - m_backgroundColour.GetPixel(), - m_backgroundColour.GetPixel() ); + Window xwindow = XCreateWindow( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, + 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); m_mainWidget = (WXWindow) xwindow; - // Select event types wanted - XSelectInput( xdisplay, xwindow, - ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | - KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | - PropertyChangeMask); - wxAddWindowToTable( xwindow, (wxWindow*) this ); // Is a subwindow, so map immediately @@ -193,12 +199,7 @@ wxWindowX11::~wxWindowX11() m_isBeingDeleted = TRUE; // X11-specific actions first - Window main = (Window) m_mainWidget; - if ( main ) - { - // Removes event handlers - //DetachWidget(main); - } + Window xwindow = (Window) m_mainWidget; if (m_parent) m_parent->RemoveChild( this ); @@ -206,11 +207,11 @@ wxWindowX11::~wxWindowX11() DestroyChildren(); // Destroy the window - if (main) + if (xwindow) { - XSelectInput( wxGlobalDisplay(), main, NoEventMask); - wxDeleteWindowFromTable( main ); - XDestroyWindow( wxGlobalDisplay(), main ); + XSelectInput( wxGlobalDisplay(), xwindow, NoEventMask); + wxDeleteWindowFromTable( xwindow ); + XDestroyWindow( wxGlobalDisplay(), xwindow ); m_mainWidget = NULL; } } @@ -253,6 +254,19 @@ wxWindow *wxWindowBase::FindFocus() return NULL; } +wxWindow *wxWindowX11::GetFocusWidget() +{ + wxWindow *win = (wxWindow*) this; + while (!win->IsTopLevel()) + { + win = win->GetParent(); + if (!win) + return (wxWindow*) NULL; + } + + return win; +} + // Enabling/disabling handled by event loop, and not sending events // if disabled. bool wxWindowX11::Enable(bool enable) @@ -271,17 +285,13 @@ bool wxWindowX11::Show(bool show) Display *xdisp = (Display*) GetXDisplay(); if (show) { - wxString msg; - msg.Printf("Mapping window of type %s", GetClassInfo()->GetClassName()); - wxLogDebug(msg); + // wxLogDebug( "Mapping window of type %s", GetName().c_str() ); XMapWindow(xdisp, xwin); XSync(xdisp, False); } else { - wxString msg; - msg.Printf("Unmapping window of type %s", GetClassInfo()->GetClassName()); - wxLogDebug(msg); + // wxLogDebug( "Unmapping window of type %s", GetName().c_str() ); XUnmapWindow(xdisp, xwin); } @@ -460,6 +470,29 @@ void wxWindowX11::WarpPointer (int x, int y) // Does a physical scroll void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect) { + // No scrolling requested. + if ((dx == 0) && (dy == 0)) return; + + if (!m_updateRegion.IsEmpty()) + { + m_updateRegion.Offset( dx, dy ); + + int cw = 0; + int ch = 0; + GetSize( &cw, &ch ); // GetClientSize() ?? + m_updateRegion.Intersect( 0, 0, cw, ch ); + } + + if (!m_clearRegion.IsEmpty()) + { + m_clearRegion.Offset( dx, dy ); + + int cw = 0; + int ch = 0; + GetSize( &cw, &ch ); // GetClientSize() ?? + m_clearRegion.Intersect( 0, 0, cw, ch ); + } + Window xwindow = (Window) GetMainWindow(); wxCHECK_RET( xwindow, wxT("invalid window") ); @@ -575,6 +608,7 @@ void wxWindowX11::DoGetSize(int *x, int *y) const wxCHECK_RET( xwindow, wxT("invalid window") ); XSync(wxGlobalDisplay(), False); + XWindowAttributes attr; Status status = XGetWindowAttributes( wxGlobalDisplay(), xwindow, &attr ); wxASSERT(status);