send wxActivateEvents

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4593 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-11-16 16:44:23 +00:00
parent ebf2689b4d
commit 148cd9b6ec
2 changed files with 186 additions and 106 deletions

View File

@@ -185,7 +185,13 @@ extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL;
wxWindow *g_focusWindow = (wxWindow*) NULL;
static wxWindow *g_focusWindow = (wxWindow*) NULL;
// if we detect that the app has got/lost the focus, we set this variable to
// either TRUE or FALSE and an activate event will be sent during the next
// OnIdle() call and it is reset to -1: this value means that we shouldn't
// send any activate events at all
static int g_sendActivateEvent = -1;
/* hack: we need something to pass to gtk_menu_popup, so we store the time of
the last click here */
@@ -1274,6 +1280,20 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
switch ( g_sendActivateEvent )
{
case -1:
// we've got focus from outside, synthtize wxActivateEvent
g_sendActivateEvent = 1;
break;
case 0:
// another our window just lost focus, it was already ours before
// - don't send any wxActivateEvent
g_sendActivateEvent = -1;
break;
}
g_focusWindow = win;
/*
@@ -1315,6 +1335,13 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
// if the focus goes out of our app alltogether, OnIdle() will send
// wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset
// g_sendActivateEvent to -1
g_sendActivateEvent = 0;
g_focusWindow = (wxWindow *)NULL;
/*
printf( "OnKillFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -2086,6 +2113,19 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
void wxWindow::OnInternalIdle()
{
if ( g_sendActivateEvent != -1 )
{
bool activate = g_sendActivateEvent != 0;
// do it only once
g_sendActivateEvent = -1;
wxActivateEvent event(wxEVT_ACTIVATE, activate, GetId());
event.SetEventObject(this);
(void)GetEventHandler()->ProcessEvent(event);
}
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;

View File

@@ -185,7 +185,13 @@ extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL;
wxWindow *g_focusWindow = (wxWindow*) NULL;
static wxWindow *g_focusWindow = (wxWindow*) NULL;
// if we detect that the app has got/lost the focus, we set this variable to
// either TRUE or FALSE and an activate event will be sent during the next
// OnIdle() call and it is reset to -1: this value means that we shouldn't
// send any activate events at all
static int g_sendActivateEvent = -1;
/* hack: we need something to pass to gtk_menu_popup, so we store the time of
the last click here */
@@ -1274,6 +1280,20 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
switch ( g_sendActivateEvent )
{
case -1:
// we've got focus from outside, synthtize wxActivateEvent
g_sendActivateEvent = 1;
break;
case 0:
// another our window just lost focus, it was already ours before
// - don't send any wxActivateEvent
g_sendActivateEvent = -1;
break;
}
g_focusWindow = win;
/*
@@ -1315,6 +1335,13 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
// if the focus goes out of our app alltogether, OnIdle() will send
// wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset
// g_sendActivateEvent to -1
g_sendActivateEvent = 0;
g_focusWindow = (wxWindow *)NULL;
/*
printf( "OnKillFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -2086,6 +2113,19 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
void wxWindow::OnInternalIdle()
{
if ( g_sendActivateEvent != -1 )
{
bool activate = g_sendActivateEvent != 0;
// do it only once
g_sendActivateEvent = -1;
wxActivateEvent event(wxEVT_ACTIVATE, activate, GetId());
event.SetEventObject(this);
(void)GetEventHandler()->ProcessEvent(event);
}
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;