Updated the erase/paint event logic.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14216 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -111,7 +111,7 @@ public:
|
|||||||
WXDisplay *GetXDisplay() const;
|
WXDisplay *GetXDisplay() const;
|
||||||
|
|
||||||
void SetLastClick(int button, long timestamp)
|
void SetLastClick(int button, long timestamp)
|
||||||
{ m_lastButton = button; m_lastTS = timestamp; }
|
{ m_lastButton = button; m_lastTS = timestamp; }
|
||||||
|
|
||||||
int GetLastClickedButton() const { return m_lastButton; }
|
int GetLastClickedButton() const { return m_lastButton; }
|
||||||
long GetLastClickTime() const { return m_lastTS; }
|
long GetLastClickTime() const { return m_lastTS; }
|
||||||
@@ -126,6 +126,9 @@ public:
|
|||||||
// Clip to paint region?
|
// Clip to paint region?
|
||||||
bool GetClipPaintRegion() { return m_clipPaintRegion; }
|
bool GetClipPaintRegion() { return m_clipPaintRegion; }
|
||||||
|
|
||||||
|
// Return clear region
|
||||||
|
wxRegion &GetClearRegion() { return m_clearRegion; }
|
||||||
|
|
||||||
// sets the fore/background colour for the given widget
|
// sets the fore/background colour for the given widget
|
||||||
static void DoChangeForegroundColour(WXWindow widget, wxColour& foregroundColour);
|
static void DoChangeForegroundColour(WXWindow widget, wxColour& foregroundColour);
|
||||||
static void DoChangeBackgroundColour(WXWindow widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
|
static void DoChangeBackgroundColour(WXWindow widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
|
||||||
|
@@ -144,7 +144,7 @@ void wxApp::CleanUp()
|
|||||||
// wxDebugContext, too.
|
// wxDebugContext, too.
|
||||||
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
||||||
{
|
{
|
||||||
wxLogDebug("There were memory leaks.\n");
|
wxLogDebug("There were memory leaks.");
|
||||||
wxDebugContext::Dump();
|
wxDebugContext::Dump();
|
||||||
wxDebugContext::PrintStatistics();
|
wxDebugContext::PrintStatistics();
|
||||||
}
|
}
|
||||||
@@ -368,6 +368,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
|
wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
|
||||||
wxTranslateKeyEvent(keyEvent, win, window, event);
|
wxTranslateKeyEvent(keyEvent, win, window, event);
|
||||||
|
|
||||||
|
wxLogDebug( "OnKey from %s", win->GetName().c_str() );
|
||||||
|
|
||||||
// We didn't process wxEVT_KEY_DOWN, so send
|
// We didn't process wxEVT_KEY_DOWN, so send
|
||||||
// wxEVT_CHAR
|
// wxEVT_CHAR
|
||||||
@@ -464,9 +466,14 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
if (win)
|
if (win)
|
||||||
{
|
{
|
||||||
// Schedule update for later
|
|
||||||
win->GetUpdateRegion().Union( event->xexpose.x, event->xexpose.y,
|
win->GetUpdateRegion().Union( event->xexpose.x, event->xexpose.y,
|
||||||
event->xexpose.width, event->xexpose.height);
|
event->xexpose.width, event->xexpose.height);
|
||||||
|
|
||||||
|
win->GetClearRegion().Union( event->xexpose.x, event->xexpose.y,
|
||||||
|
event->xexpose.width, event->xexpose.height);
|
||||||
|
|
||||||
|
// if (event->xexpose.count == 0)
|
||||||
|
// win->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -492,6 +499,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
if (win && event->xfocus.detail != NotifyPointer)
|
if (win && event->xfocus.detail != NotifyPointer)
|
||||||
{
|
{
|
||||||
|
wxLogDebug( "FocusIn from %s", win->GetName().c_str() );
|
||||||
|
|
||||||
wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
|
wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
|
||||||
focusEvent.SetEventObject(win);
|
focusEvent.SetEventObject(win);
|
||||||
win->GetEventHandler()->ProcessEvent(focusEvent);
|
win->GetEventHandler()->ProcessEvent(focusEvent);
|
||||||
@@ -502,6 +511,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
if (win && event->xfocus.detail != NotifyPointer)
|
if (win && event->xfocus.detail != NotifyPointer)
|
||||||
{
|
{
|
||||||
|
wxLogDebug( "FocusOut from %s\n", win->GetName().c_str() );
|
||||||
|
|
||||||
wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
|
wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
|
||||||
focusEvent.SetEventObject(win);
|
focusEvent.SetEventObject(win);
|
||||||
win->GetEventHandler()->ProcessEvent(focusEvent);
|
win->GetEventHandler()->ProcessEvent(focusEvent);
|
||||||
|
@@ -77,6 +77,10 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
|
|||||||
m_mainWidget = (WXWindow) xwindow;
|
m_mainWidget = (WXWindow) xwindow;
|
||||||
wxAddWindowToTable( xwindow, (wxWindow*) this );
|
wxAddWindowToTable( xwindow, (wxWindow*) this );
|
||||||
|
|
||||||
|
// Set background to None which will prevent X11 from clearing the
|
||||||
|
// background comletely.
|
||||||
|
XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
|
||||||
|
|
||||||
XSetTransientForHint( xdisplay, xwindow, xparent );
|
XSetTransientForHint( xdisplay, xwindow, xparent );
|
||||||
|
|
||||||
XWMHints wm_hints;
|
XWMHints wm_hints;
|
||||||
|
@@ -135,6 +135,10 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
|
|||||||
|
|
||||||
wxAddWindowToTable( xwindow, (wxWindow*) this );
|
wxAddWindowToTable( xwindow, (wxWindow*) this );
|
||||||
|
|
||||||
|
// Set background to None which will prevent X11 from clearing the
|
||||||
|
// background completely.
|
||||||
|
XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
|
||||||
|
|
||||||
// Messes up window management
|
// Messes up window management
|
||||||
// XSetTransientForHint( xdisplay, xwindow, xparent );
|
// XSetTransientForHint( xdisplay, xwindow, xparent );
|
||||||
|
|
||||||
|
@@ -129,11 +129,9 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
||||||
m_backgroundColour.CalcPixel( (WXColormap) cm );
|
m_backgroundColour.CalcPixel( (WXColormap) cm );
|
||||||
m_hasBgCol = TRUE;
|
|
||||||
|
|
||||||
m_foregroundColour = *wxBLACK;
|
m_foregroundColour = *wxBLACK;
|
||||||
m_foregroundColour.CalcPixel( (WXColormap) cm );
|
m_foregroundColour.CalcPixel( (WXColormap) cm );
|
||||||
|
|
||||||
|
|
||||||
Window parentWindow = (Window) parent->GetMainWindow();
|
Window parentWindow = (Window) parent->GetMainWindow();
|
||||||
|
|
||||||
@@ -149,31 +147,35 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
|
|||||||
if (pos2.y == -1)
|
if (pos2.y == -1)
|
||||||
pos2.y = 100;
|
pos2.y = 100;
|
||||||
|
|
||||||
Window window = XCreateSimpleWindow(
|
Window xwindow = XCreateSimpleWindow(
|
||||||
xdisplay, parentWindow,
|
xdisplay, parentWindow,
|
||||||
pos2.x, pos2.y, size2.x, size2.y, 0,
|
pos2.x, pos2.y, size2.x, size2.y, 0,
|
||||||
m_backgroundColour.GetPixel(),
|
m_backgroundColour.GetPixel(),
|
||||||
m_backgroundColour.GetPixel() );
|
m_backgroundColour.GetPixel() );
|
||||||
|
|
||||||
m_mainWidget = (WXWindow) window;
|
m_mainWidget = (WXWindow) xwindow;
|
||||||
|
|
||||||
// Select event types wanted
|
// Select event types wanted
|
||||||
XSelectInput( wxGlobalDisplay(), window,
|
XSelectInput( xdisplay, xwindow,
|
||||||
ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
|
ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
|
||||||
ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
|
ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
|
||||||
KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
|
KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
|
||||||
PropertyChangeMask);
|
PropertyChangeMask);
|
||||||
|
|
||||||
wxAddWindowToTable(window, (wxWindow*) this);
|
wxAddWindowToTable( xwindow, (wxWindow*) this );
|
||||||
|
|
||||||
// Is a subwindow, so map immediately
|
// Is a subwindow, so map immediately
|
||||||
m_isShown = TRUE;
|
m_isShown = TRUE;
|
||||||
XMapWindow(wxGlobalDisplay(), window);
|
XMapWindow( xdisplay, xwindow );
|
||||||
|
|
||||||
// Without this, the cursor may not be restored properly (e.g. in splitter
|
// Without this, the cursor may not be restored properly (e.g. in splitter
|
||||||
// sample).
|
// sample).
|
||||||
SetCursor(*wxSTANDARD_CURSOR);
|
SetCursor(*wxSTANDARD_CURSOR);
|
||||||
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
||||||
|
|
||||||
|
// Set background to None which will prevent X11 from clearing the
|
||||||
|
// background comletely.
|
||||||
|
XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
|
||||||
|
|
||||||
// Don't call this, it can have nasty repercussions for composite controls,
|
// Don't call this, it can have nasty repercussions for composite controls,
|
||||||
// for example
|
// for example
|
||||||
@@ -226,11 +228,11 @@ void wxWindowX11::SetFocus()
|
|||||||
if (wxWindowIsVisible(xwindow))
|
if (wxWindowIsVisible(xwindow))
|
||||||
{
|
{
|
||||||
XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
|
XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
|
||||||
m_needsInputFocus = FALSE;
|
m_needsInputFocus = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_needsInputFocus = TRUE;
|
m_needsInputFocus = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -994,6 +996,7 @@ void wxWindowX11::Update()
|
|||||||
{
|
{
|
||||||
if (!m_updateRegion.IsEmpty())
|
if (!m_updateRegion.IsEmpty())
|
||||||
{
|
{
|
||||||
|
// Actually send erase and paint events.
|
||||||
X11SendPaintEvents();
|
X11SendPaintEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1010,7 +1013,7 @@ void wxWindowX11::X11SendPaintEvents()
|
|||||||
{
|
{
|
||||||
m_clipPaintRegion = TRUE;
|
m_clipPaintRegion = TRUE;
|
||||||
|
|
||||||
// if (!m_clearRegion.IsEmpty())
|
if (!m_clearRegion.IsEmpty())
|
||||||
{
|
{
|
||||||
wxWindowDC dc( (wxWindow*)this );
|
wxWindowDC dc( (wxWindow*)this );
|
||||||
dc.SetClippingRegion( m_clearRegion );
|
dc.SetClippingRegion( m_clearRegion );
|
||||||
@@ -1020,11 +1023,17 @@ void wxWindowX11::X11SendPaintEvents()
|
|||||||
|
|
||||||
if (!GetEventHandler()->ProcessEvent(erase_event))
|
if (!GetEventHandler()->ProcessEvent(erase_event))
|
||||||
{
|
{
|
||||||
|
printf( "Hallo!\n" );
|
||||||
|
Window xwindow = (Window) GetMainWindow();
|
||||||
|
Display *xdisplay = wxGlobalDisplay();
|
||||||
|
GC xgc = XCreateGC( xdisplay, xwindow, 0, NULL );
|
||||||
|
XSetFillStyle( xdisplay, xgc, FillSolid );
|
||||||
|
XSetForeground( xdisplay, xgc, m_backgroundColour.GetPixel() );
|
||||||
wxRegionIterator upd( m_clearRegion );
|
wxRegionIterator upd( m_clearRegion );
|
||||||
while (upd)
|
while (upd)
|
||||||
{
|
{
|
||||||
XClearArea( wxGlobalDisplay(), (Window) m_mainWidget,
|
XFillRectangle( xdisplay, xwindow, xgc,
|
||||||
upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight(), False );
|
upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() );
|
||||||
upd ++;
|
upd ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1315,16 +1324,16 @@ bool wxWindowX11::SetBackgroundColour(const wxColour& col)
|
|||||||
{
|
{
|
||||||
wxWindowBase::SetBackgroundColour(col);
|
wxWindowBase::SetBackgroundColour(col);
|
||||||
|
|
||||||
if (!GetMainWindow())
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
Display *xdisplay = (Display*) wxGlobalDisplay();
|
Display *xdisplay = (Display*) wxGlobalDisplay();
|
||||||
int xscreen = DefaultScreen( xdisplay );
|
int xscreen = DefaultScreen( xdisplay );
|
||||||
Colormap cm = DefaultColormap( xdisplay, xscreen );
|
Colormap cm = DefaultColormap( xdisplay, xscreen );
|
||||||
|
|
||||||
wxColour colour( col );
|
m_backgroundColour.CalcPixel( (WXColormap) cm );
|
||||||
colour.CalcPixel( (WXColormap) cm );
|
|
||||||
|
|
||||||
|
if (!GetMainWindow())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/*
|
||||||
XSetWindowAttributes attrib;
|
XSetWindowAttributes attrib;
|
||||||
attrib.background_pixel = colour.GetPixel();
|
attrib.background_pixel = colour.GetPixel();
|
||||||
|
|
||||||
@@ -1332,6 +1341,7 @@ bool wxWindowX11::SetBackgroundColour(const wxColour& col)
|
|||||||
(Window) GetMainWindow(),
|
(Window) GetMainWindow(),
|
||||||
CWBackPixel,
|
CWBackPixel,
|
||||||
& attrib);
|
& attrib);
|
||||||
|
*/
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user