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:
Robert Roebling
2002-02-17 21:09:04 +00:00
parent e941874b17
commit 7e4501ee3c
8 changed files with 90 additions and 63 deletions

View File

@@ -68,6 +68,9 @@ public:
// implementation from now on
// --------------------------
void SetFocusWidget( wxWindow *focus ) { m_focusWidget = focus; }
wxWindow *GetFocusWidget() const { return m_focusWidget; }
protected:
// common part of all ctors
void Init();
@@ -83,10 +86,10 @@ protected:
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;
@@ -96,6 +99,9 @@ protected:
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

View File

@@ -145,6 +145,10 @@ public:
// 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).

View File

@@ -1640,7 +1640,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
g_focusWindowLast =
g_focusWindow = win;
#if 0
#if 1
wxPrintf( "OnSetFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
wxPrintf( win->GetClassInfo()->GetClassName() );

View File

@@ -1640,7 +1640,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
g_focusWindowLast =
g_focusWindow = win;
#if 0
#if 1
wxPrintf( "OnSetFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
wxPrintf( win->GetClassInfo()->GetClassName() );

View File

@@ -3935,6 +3935,7 @@ bool wxWin32InputHandler::HandleMouse(wxInputConsumer *control,
if ( event.ButtonDown() )
{
wxWindow *win = control->GetInputWindow();
if ( wxWindow::FindFocus() != control->GetInputWindow() )
{
win->SetFocus();

View File

@@ -251,7 +251,7 @@ int wxEntryStart( int& argc, char *argv[] )
XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask);
// wxSetDetectableAutoRepeat( TRUE );
wxSetDetectableAutoRepeat( TRUE );
if (!wxApp::Initialize())
return -1;
@@ -484,8 +484,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
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)
{
@@ -555,9 +555,9 @@ void wxApp::ProcessXEvent(WXEvent* _event)
{
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);
@@ -577,15 +577,23 @@ void wxApp::ProcessXEvent(WXEvent* _event)
case ButtonRelease:
case MotionNotify:
{
if (win && !win->IsEnabled())
if (!win)
return;
if (win)
if (!win->IsEnabled())
return;
#if 1
if (event->type == ButtonPress)
{
if ((win != wxWindow::FindFocus()) && win->AcceptsFocus())
win->SetFocus();
}
#endif
wxMouseEvent wxevent;
wxTranslateMouseEvent(wxevent, win, window, event);
win->GetEventHandler()->ProcessEvent( wxevent );
}
return;
}
case FocusIn:

View File

@@ -61,6 +61,8 @@ void wxTopLevelWindowX11::Init()
m_fsStyle = 0;
m_fsIsMaximized = FALSE;
m_fsIsShowing = FALSE;
m_focusWidget = NULL;
}
bool wxTopLevelWindowX11::Create(wxWindow *parent,
@@ -111,6 +113,7 @@ 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);
@@ -144,10 +147,18 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
// 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);
@@ -157,10 +168,12 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
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);

View File

@@ -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,34 +134,39 @@ 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();
wxSize size2(size);
if (size2.x == -1)
size2.x = 100;
if (size2.y == -1)
size2.y = 100;
XSetWindowAttributes xattributes;
wxPoint pos2(pos);
if (pos2.x == -1)
pos2.x = 100;
if (pos2.y == -1)
pos2.y = 100;
long xattributes_mask =
CWEventMask |
CWBorderPixel | CWBackPixel;
Window xwindow = XCreateSimpleWindow(
xdisplay, parentWindow,
pos2.x, pos2.y, size2.x, size2.y, 0,
m_backgroundColour.GetPixel(),
m_backgroundColour.GetPixel() );
xattributes.background_pixel = m_backgroundColour.GetPixel();
xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
m_mainWidget = (WXWindow) xwindow;
// Select event types wanted
XSelectInput( xdisplay, xwindow,
xattributes.event_mask =
ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
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 );
@@ -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,7 +254,6 @@ wxWindow *wxWindowBase::FindFocus()
return NULL;
}
#if 0
wxWindow *wxWindowX11::GetFocusWidget()
{
wxWindow *win = (wxWindow*) this;
@@ -266,7 +266,6 @@ wxWindow *wxWindowX11::GetFocusWidget()
return win;
}
#endif
// Enabling/disabling handled by event loop, and not sending events
// if disabled.
@@ -286,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);
}