// implementation from now on
// --------------------------
+
+ void SetFocusWidget( wxWindow *focus ) { m_focusWidget = focus; }
+ wxWindow *GetFocusWidget() const { return m_focusWidget; }
protected:
// common part of all ctors
int sizeFlags = wxSIZE_AUTO);
virtual void DoGetPosition( int *x, int *y ) const;
- // is the frame currently iconized?
+ // Is the frame currently 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
bool m_maximizeOnShow;
// Data to save/restore when calling ShowFullScreen
- long m_fsStyle; // Passed to ShowFullScreen
+ long m_fsStyle; // Passed to ShowFullScreen
wxRect m_fsOldSize;
bool m_fsIsMaximized;
bool m_fsIsShowing;
wxString m_title;
+
+ // This widget gets the key input
+ wxWindow* m_focusWidget;
};
// list of all frames and modeless dialogs
// For compatibility across platforms (not in event table)
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
+ // Go up to a toplevel window and query which window has the focus.
+ // May return NULL.
+ wxWindow *GetFocusWidget();
+
protected:
// Makes an adjustment to the window position (for example, a frame that has
// a toolbar that it manages itself).
g_focusWindowLast =
g_focusWindow = win;
-#if 0
+#if 1
wxPrintf( "OnSetFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
wxPrintf( win->GetClassInfo()->GetClassName() );
g_focusWindowLast =
g_focusWindow = win;
-#if 0
+#if 1
wxPrintf( "OnSetFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
wxPrintf( win->GetClassInfo()->GetClassName() );
if ( event.ButtonDown() )
{
wxWindow *win = control->GetInputWindow();
+
if ( wxWindow::FindFocus() != control->GetInputWindow() )
{
win->SetFocus();
XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask);
-// wxSetDetectableAutoRepeat( TRUE );
+ wxSetDetectableAutoRepeat( TRUE );
if (!wxApp::Initialize())
return -1;
if (win && !win->IsEnabled())
return;
- Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True);;
- Atom wm_protocols = XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True);;
+ Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True);
+ Atom wm_protocols = XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True);
if (event->xclient.message_type == wm_protocols)
{
{
if (win)
{
- wxLogDebug( "GraphicsExpose from %s", win->GetName().c_str(),
- event->xgraphicsexpose.x, event->xgraphicsexpose.y,
- event->xgraphicsexpose.width, event->xgraphicsexpose.height);
+ // wxLogDebug( "GraphicsExpose from %s", win->GetName().c_str(),
+ // event->xgraphicsexpose.x, event->xgraphicsexpose.y,
+ // event->xgraphicsexpose.width, event->xgraphicsexpose.height);
win->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
event->xgraphicsexpose.width, event->xgraphicsexpose.height);
case ButtonRelease:
case MotionNotify:
{
- if (win && !win->IsEnabled())
+ if (!win)
return;
-
- if (win)
+
+ if (!win->IsEnabled())
+ return;
+
+#if 1
+ if (event->type == ButtonPress)
{
- wxMouseEvent wxevent;
- wxTranslateMouseEvent(wxevent, win, window, event);
- win->GetEventHandler()->ProcessEvent( wxevent );
+ if ((win != wxWindow::FindFocus()) && win->AcceptsFocus())
+ win->SetFocus();
}
+#endif
+
+ wxMouseEvent wxevent;
+ wxTranslateMouseEvent(wxevent, win, window, event);
+ win->GetEventHandler()->ProcessEvent( wxevent );
return;
}
case FocusIn:
m_fsStyle = 0;
m_fsIsMaximized = FALSE;
m_fsIsShowing = FALSE;
+
+ m_focusWidget = NULL;
}
bool wxTopLevelWindowX11::Create(wxWindow *parent,
// TODO: if we want no border, caption etc.,
// I think we set this to True to remove decorations
+ // No. RR.
xattributes.override_redirect = False;
wxSize size2(size);
// background completely.
XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
- // Messes up window management
- // XSetTransientForHint( xdisplay, xwindow, xparent );
+ if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
+ {
+ 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.height = size2.y;
XSetWMNormalHints( xdisplay, xwindow, &size_hints);
wm_hints.initial_state = NormalState;
XSetWMHints( xdisplay, xwindow, &wm_hints);
- Atom wm_delete_window = XInternAtom( xdisplay, "WM_DELETE_WINDOW", False);
- XSetWMProtocols( xdisplay, xwindow, &wm_delete_window, 1);
+ Atom wm_protocols[2];
+ 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);
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);
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
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 );
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;
}
}
return NULL;
}
-#if 0
wxWindow *wxWindowX11::GetFocusWidget()
{
wxWindow *win = (wxWindow*) this;
return win;
}
-#endif
// Enabling/disabling handled by event loop, and not sending events
// if disabled.
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);
}