wxX11:
Corrected TLW positiong. Added experimental code for synthesizing focus events. Minor clean-ups. Added for-now unused code for default/focus widget. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14281 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -67,6 +67,9 @@ public:
|
|||||||
|
|
||||||
// implementation from now on
|
// implementation from now on
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
|
||||||
|
void SetFocusWidget( wxWindow *focus ) { m_focusWidget = focus; }
|
||||||
|
wxWindow *GetFocusWidget() const { return m_focusWidget; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
@@ -83,19 +86,22 @@ protected:
|
|||||||
int sizeFlags = wxSIZE_AUTO);
|
int sizeFlags = wxSIZE_AUTO);
|
||||||
virtual void DoGetPosition( int *x, int *y ) const;
|
virtual void DoGetPosition( int *x, int *y ) const;
|
||||||
|
|
||||||
// is the frame currently iconized?
|
// Is the frame currently iconized?
|
||||||
bool m_iconized;
|
bool m_iconized;
|
||||||
|
|
||||||
// should the frame be maximized when it will be shown? set by Maximize()
|
// Should the frame be maximized when it will be shown? set by Maximize()
|
||||||
// when it is called while the frame is hidden
|
// when it is called while the frame is hidden
|
||||||
bool m_maximizeOnShow;
|
bool m_maximizeOnShow;
|
||||||
|
|
||||||
// Data to save/restore when calling ShowFullScreen
|
// Data to save/restore when calling ShowFullScreen
|
||||||
long m_fsStyle; // Passed to ShowFullScreen
|
long m_fsStyle; // Passed to ShowFullScreen
|
||||||
wxRect m_fsOldSize;
|
wxRect m_fsOldSize;
|
||||||
bool m_fsIsMaximized;
|
bool m_fsIsMaximized;
|
||||||
bool m_fsIsShowing;
|
bool m_fsIsShowing;
|
||||||
wxString m_title;
|
wxString m_title;
|
||||||
|
|
||||||
|
// This widget gets the key input
|
||||||
|
wxWindow* m_focusWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
// list of all frames and modeless dialogs
|
// list of all frames and modeless dialogs
|
||||||
|
@@ -145,6 +145,10 @@ public:
|
|||||||
// For compatibility across platforms (not in event table)
|
// For compatibility across platforms (not in event table)
|
||||||
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
|
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
|
||||||
|
|
||||||
|
// Go up to a toplevel window and query which window has the focus.
|
||||||
|
// May return NULL.
|
||||||
|
wxWindow *GetFocusWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Makes an adjustment to the window position (for example, a frame that has
|
// Makes an adjustment to the window position (for example, a frame that has
|
||||||
// a toolbar that it manages itself).
|
// a toolbar that it manages itself).
|
||||||
|
@@ -1640,7 +1640,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
|
|||||||
g_focusWindowLast =
|
g_focusWindowLast =
|
||||||
g_focusWindow = win;
|
g_focusWindow = win;
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
wxPrintf( "OnSetFocus from " );
|
wxPrintf( "OnSetFocus from " );
|
||||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||||
wxPrintf( win->GetClassInfo()->GetClassName() );
|
wxPrintf( win->GetClassInfo()->GetClassName() );
|
||||||
|
@@ -1640,7 +1640,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
|
|||||||
g_focusWindowLast =
|
g_focusWindowLast =
|
||||||
g_focusWindow = win;
|
g_focusWindow = win;
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
wxPrintf( "OnSetFocus from " );
|
wxPrintf( "OnSetFocus from " );
|
||||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||||
wxPrintf( win->GetClassInfo()->GetClassName() );
|
wxPrintf( win->GetClassInfo()->GetClassName() );
|
||||||
|
@@ -3935,6 +3935,7 @@ bool wxWin32InputHandler::HandleMouse(wxInputConsumer *control,
|
|||||||
if ( event.ButtonDown() )
|
if ( event.ButtonDown() )
|
||||||
{
|
{
|
||||||
wxWindow *win = control->GetInputWindow();
|
wxWindow *win = control->GetInputWindow();
|
||||||
|
|
||||||
if ( wxWindow::FindFocus() != control->GetInputWindow() )
|
if ( wxWindow::FindFocus() != control->GetInputWindow() )
|
||||||
{
|
{
|
||||||
win->SetFocus();
|
win->SetFocus();
|
||||||
|
@@ -251,7 +251,7 @@ int wxEntryStart( int& argc, char *argv[] )
|
|||||||
|
|
||||||
XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask);
|
XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask);
|
||||||
|
|
||||||
// wxSetDetectableAutoRepeat( TRUE );
|
wxSetDetectableAutoRepeat( TRUE );
|
||||||
|
|
||||||
if (!wxApp::Initialize())
|
if (!wxApp::Initialize())
|
||||||
return -1;
|
return -1;
|
||||||
@@ -484,8 +484,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
if (win && !win->IsEnabled())
|
if (win && !win->IsEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True);;
|
Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True);
|
||||||
Atom wm_protocols = XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True);;
|
Atom wm_protocols = XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True);
|
||||||
|
|
||||||
if (event->xclient.message_type == wm_protocols)
|
if (event->xclient.message_type == wm_protocols)
|
||||||
{
|
{
|
||||||
@@ -555,9 +555,9 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
if (win)
|
if (win)
|
||||||
{
|
{
|
||||||
wxLogDebug( "GraphicsExpose from %s", win->GetName().c_str(),
|
// wxLogDebug( "GraphicsExpose from %s", win->GetName().c_str(),
|
||||||
event->xgraphicsexpose.x, event->xgraphicsexpose.y,
|
// event->xgraphicsexpose.x, event->xgraphicsexpose.y,
|
||||||
event->xgraphicsexpose.width, event->xgraphicsexpose.height);
|
// event->xgraphicsexpose.width, event->xgraphicsexpose.height);
|
||||||
|
|
||||||
win->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
|
win->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
|
||||||
event->xgraphicsexpose.width, event->xgraphicsexpose.height);
|
event->xgraphicsexpose.width, event->xgraphicsexpose.height);
|
||||||
@@ -577,15 +577,23 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
{
|
{
|
||||||
if (win && !win->IsEnabled())
|
if (!win)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (win)
|
if (!win->IsEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
if (event->type == ButtonPress)
|
||||||
{
|
{
|
||||||
wxMouseEvent wxevent;
|
if ((win != wxWindow::FindFocus()) && win->AcceptsFocus())
|
||||||
wxTranslateMouseEvent(wxevent, win, window, event);
|
win->SetFocus();
|
||||||
win->GetEventHandler()->ProcessEvent( wxevent );
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxMouseEvent wxevent;
|
||||||
|
wxTranslateMouseEvent(wxevent, win, window, event);
|
||||||
|
win->GetEventHandler()->ProcessEvent( wxevent );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
|
@@ -61,6 +61,8 @@ void wxTopLevelWindowX11::Init()
|
|||||||
m_fsStyle = 0;
|
m_fsStyle = 0;
|
||||||
m_fsIsMaximized = FALSE;
|
m_fsIsMaximized = FALSE;
|
||||||
m_fsIsShowing = FALSE;
|
m_fsIsShowing = FALSE;
|
||||||
|
|
||||||
|
m_focusWidget = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTopLevelWindowX11::Create(wxWindow *parent,
|
bool wxTopLevelWindowX11::Create(wxWindow *parent,
|
||||||
@@ -111,6 +113,7 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
|
|||||||
|
|
||||||
// TODO: if we want no border, caption etc.,
|
// TODO: if we want no border, caption etc.,
|
||||||
// I think we set this to True to remove decorations
|
// I think we set this to True to remove decorations
|
||||||
|
// No. RR.
|
||||||
xattributes.override_redirect = False;
|
xattributes.override_redirect = False;
|
||||||
|
|
||||||
wxSize size2(size);
|
wxSize size2(size);
|
||||||
@@ -144,10 +147,18 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
|
|||||||
// background completely.
|
// background completely.
|
||||||
XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
|
XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
|
||||||
|
|
||||||
// Messes up window management
|
if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
|
||||||
// XSetTransientForHint( xdisplay, xwindow, xparent );
|
{
|
||||||
|
if (GetParent() && GetParent()->GetMainWindow())
|
||||||
|
{
|
||||||
|
Window xparentwindow = (Window) GetParent()->GetMainWindow();
|
||||||
|
XSetTransientForHint( xdisplay, xwindow, xparentwindow );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size_hints.flags = PSize;
|
size_hints.flags = PSize | PPosition;
|
||||||
|
size_hints.x = pos2.x;
|
||||||
|
size_hints.y = pos2.y;
|
||||||
size_hints.width = size2.x;
|
size_hints.width = size2.x;
|
||||||
size_hints.height = size2.y;
|
size_hints.height = size2.y;
|
||||||
XSetWMNormalHints( xdisplay, xwindow, &size_hints);
|
XSetWMNormalHints( xdisplay, xwindow, &size_hints);
|
||||||
@@ -157,10 +168,12 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
|
|||||||
wm_hints.initial_state = NormalState;
|
wm_hints.initial_state = NormalState;
|
||||||
XSetWMHints( xdisplay, xwindow, &wm_hints);
|
XSetWMHints( xdisplay, xwindow, &wm_hints);
|
||||||
|
|
||||||
Atom wm_delete_window = XInternAtom( xdisplay, "WM_DELETE_WINDOW", False);
|
Atom wm_protocols[2];
|
||||||
XSetWMProtocols( xdisplay, xwindow, &wm_delete_window, 1);
|
wm_protocols[0] = XInternAtom( xdisplay, "WM_DELETE_WINDOW", False );
|
||||||
|
wm_protocols[1] = XInternAtom( xdisplay, "WM_TAKE_FOCUS", False );
|
||||||
|
XSetWMProtocols( xdisplay, xwindow, wm_protocols, 2);
|
||||||
|
|
||||||
wxSetWMDecorations((Window) GetMainWindow(), style);
|
wxSetWMDecorations( xwindow, style);
|
||||||
|
|
||||||
SetTitle(title);
|
SetTitle(title);
|
||||||
|
|
||||||
|
@@ -125,6 +125,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
Display *xdisplay = (Display*) wxGlobalDisplay();
|
Display *xdisplay = (Display*) wxGlobalDisplay();
|
||||||
int xscreen = DefaultScreen( xdisplay );
|
int xscreen = DefaultScreen( xdisplay );
|
||||||
|
Visual *xvisual = DefaultVisual( xdisplay, xscreen );
|
||||||
Colormap cm = DefaultColormap( xdisplay, xscreen );
|
Colormap cm = DefaultColormap( xdisplay, xscreen );
|
||||||
|
|
||||||
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
||||||
@@ -133,34 +134,39 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
|
|||||||
m_foregroundColour = *wxBLACK;
|
m_foregroundColour = *wxBLACK;
|
||||||
m_foregroundColour.CalcPixel( (WXColormap) cm );
|
m_foregroundColour.CalcPixel( (WXColormap) cm );
|
||||||
|
|
||||||
Window parentWindow = (Window) parent->GetMainWindow();
|
Window xparent = (Window) parent->GetMainWindow();
|
||||||
|
|
||||||
wxSize size2(size);
|
XSetWindowAttributes xattributes;
|
||||||
if (size2.x == -1)
|
|
||||||
size2.x = 100;
|
|
||||||
if (size2.y == -1)
|
|
||||||
size2.y = 100;
|
|
||||||
|
|
||||||
wxPoint pos2(pos);
|
|
||||||
if (pos2.x == -1)
|
|
||||||
pos2.x = 100;
|
|
||||||
if (pos2.y == -1)
|
|
||||||
pos2.y = 100;
|
|
||||||
|
|
||||||
Window xwindow = XCreateSimpleWindow(
|
long xattributes_mask =
|
||||||
xdisplay, parentWindow,
|
CWEventMask |
|
||||||
pos2.x, pos2.y, size2.x, size2.y, 0,
|
CWBorderPixel | CWBackPixel;
|
||||||
m_backgroundColour.GetPixel(),
|
|
||||||
m_backgroundColour.GetPixel() );
|
|
||||||
|
|
||||||
m_mainWidget = (WXWindow) xwindow;
|
xattributes.background_pixel = m_backgroundColour.GetPixel();
|
||||||
|
xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
|
||||||
// Select event types wanted
|
|
||||||
XSelectInput( xdisplay, xwindow,
|
xattributes.event_mask =
|
||||||
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;
|
||||||
|
|
||||||
|
wxSize size2(size);
|
||||||
|
if (size2.x == -1)
|
||||||
|
size2.x = 20;
|
||||||
|
if (size2.y == -1)
|
||||||
|
size2.y = 20;
|
||||||
|
|
||||||
|
wxPoint pos2(pos);
|
||||||
|
if (pos2.x == -1)
|
||||||
|
pos2.x = 0;
|
||||||
|
if (pos2.y == -1)
|
||||||
|
pos2.y = 0;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
wxAddWindowToTable( xwindow, (wxWindow*) this );
|
wxAddWindowToTable( xwindow, (wxWindow*) this );
|
||||||
|
|
||||||
@@ -193,12 +199,7 @@ wxWindowX11::~wxWindowX11()
|
|||||||
m_isBeingDeleted = TRUE;
|
m_isBeingDeleted = TRUE;
|
||||||
|
|
||||||
// X11-specific actions first
|
// X11-specific actions first
|
||||||
Window main = (Window) m_mainWidget;
|
Window xwindow = (Window) m_mainWidget;
|
||||||
if ( main )
|
|
||||||
{
|
|
||||||
// Removes event handlers
|
|
||||||
//DetachWidget(main);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_parent)
|
if (m_parent)
|
||||||
m_parent->RemoveChild( this );
|
m_parent->RemoveChild( this );
|
||||||
@@ -206,11 +207,11 @@ wxWindowX11::~wxWindowX11()
|
|||||||
DestroyChildren();
|
DestroyChildren();
|
||||||
|
|
||||||
// Destroy the window
|
// Destroy the window
|
||||||
if (main)
|
if (xwindow)
|
||||||
{
|
{
|
||||||
XSelectInput( wxGlobalDisplay(), main, NoEventMask);
|
XSelectInput( wxGlobalDisplay(), xwindow, NoEventMask);
|
||||||
wxDeleteWindowFromTable( main );
|
wxDeleteWindowFromTable( xwindow );
|
||||||
XDestroyWindow( wxGlobalDisplay(), main );
|
XDestroyWindow( wxGlobalDisplay(), xwindow );
|
||||||
m_mainWidget = NULL;
|
m_mainWidget = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,7 +254,6 @@ wxWindow *wxWindowBase::FindFocus()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
wxWindow *wxWindowX11::GetFocusWidget()
|
wxWindow *wxWindowX11::GetFocusWidget()
|
||||||
{
|
{
|
||||||
wxWindow *win = (wxWindow*) this;
|
wxWindow *win = (wxWindow*) this;
|
||||||
@@ -266,7 +266,6 @@ wxWindow *wxWindowX11::GetFocusWidget()
|
|||||||
|
|
||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Enabling/disabling handled by event loop, and not sending events
|
// Enabling/disabling handled by event loop, and not sending events
|
||||||
// if disabled.
|
// if disabled.
|
||||||
@@ -286,17 +285,13 @@ bool wxWindowX11::Show(bool show)
|
|||||||
Display *xdisp = (Display*) GetXDisplay();
|
Display *xdisp = (Display*) GetXDisplay();
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
wxString msg;
|
// wxLogDebug( "Mapping window of type %s", GetName().c_str() );
|
||||||
msg.Printf("Mapping window of type %s", GetClassInfo()->GetClassName());
|
|
||||||
wxLogDebug(msg);
|
|
||||||
XMapWindow(xdisp, xwin);
|
XMapWindow(xdisp, xwin);
|
||||||
XSync(xdisp, False);
|
XSync(xdisp, False);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxString msg;
|
// wxLogDebug( "Unmapping window of type %s", GetName().c_str() );
|
||||||
msg.Printf("Unmapping window of type %s", GetClassInfo()->GetClassName());
|
|
||||||
wxLogDebug(msg);
|
|
||||||
XUnmapWindow(xdisp, xwin);
|
XUnmapWindow(xdisp, xwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user