return FALSE;
}
+// ============================================================================
+// the mouse events
+// ============================================================================
+
+// init wxMouseEvent with the info from gdk_event
+#define InitMouseEvent(win, event, gdk_event) \
+ { \
+ event.SetTimestamp( gdk_event->time ); \
+ event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); \
+ event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); \
+ event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); \
+ event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); \
+ event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK); \
+ event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK); \
+ event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK); \
+\
+ wxPoint pt = win->GetClientAreaOrigin(); \
+ event.m_x = (wxCoord)gdk_event->x - pt.x; \
+ event.m_y = (wxCoord)gdk_event->y - pt.y; \
+ }
+
// ----------------------------------------------------------------------------
// mouse event processing helper
// ----------------------------------------------------------------------------
}
wxMouseEvent event( event_type );
- event.SetTimestamp( gdk_event->time );
- event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
- event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
- event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
- event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
- event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
- event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
- event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
-
- event.m_x = (wxCoord)gdk_event->x;
- event.m_y = (wxCoord)gdk_event->y;
+ InitMouseEvent( win, event, gdk_event );
AdjustEventButtonState(event);
+
+ // wxListBox actually get mouse events from the item
+
+ if (win->m_isListBox)
+ {
+ event.m_x += widget->allocation.x;
+ event.m_y += widget->allocation.y;
+ }
// Some control don't have their own X window and thus cannot get
// any events.
}
wxMouseEvent event( event_type );
- event.SetTimestamp( gdk_event->time );
- event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
- event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
- event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
- event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
- event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
- event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
- event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
- event.m_x = (wxCoord)gdk_event->x;
- event.m_y = (wxCoord)gdk_event->y;
+ InitMouseEvent( win, event, gdk_event );
AdjustEventButtonState(event);
+ // wxListBox actually get mouse events from the item
+
+ if (win->m_isListBox)
+ {
+ event.m_x += widget->allocation.x;
+ event.m_y += widget->allocation.y;
+ }
+
// Some control don't have their own X window and thus cannot get
// any events.
return FALSE;
}
-// ============================================================================
-// the mouse events
-// ============================================================================
-
-// init wxMouseEvent with the info from gdk_event
-#define InitMouseEvent(event, gdk_event) \
- event.SetTimestamp( gdk_event->time ); \
- event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); \
- event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); \
- event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); \
- event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); \
- event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK); \
- event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK); \
- event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK); \
-\
- event.m_x = (wxCoord)gdk_event->x; \
- event.m_y = (wxCoord)gdk_event->y \
-
//-----------------------------------------------------------------------------
// "motion_notify_event"
//-----------------------------------------------------------------------------
*/
wxMouseEvent event( wxEVT_MOTION );
- InitMouseEvent(event, gdk_event);
+ InitMouseEvent(win, event, gdk_event);
if ( g_captureWindow )
{
wxMouseEvent event(g_captureWindowHasMouse ? wxEVT_ENTER_WINDOW
: wxEVT_LEAVE_WINDOW);
- InitMouseEvent(event, gdk_event);
+ InitMouseEvent(win, event, gdk_event);
event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event);
}
if ( !g_activeFrameLostFocus && g_activeFrame )
{
- wxASSERT_MSG( wxGetTopLevelParent(win) == g_activeFrame, wxT("unfocusing window that haven't gained focus properly") )
+ // VZ: commenting this out because it does happen (although not easy
+ // to reproduce, I only see it when using wxMiniFrame and not
+ // always) and makes using Mahogany quite annoying
+#if 0
+ wxASSERT_MSG( wxGetTopLevelParent(win) == g_activeFrame,
+ wxT("unfocusing window that hasn't gained focus properly") )
+#endif // 0
+
g_activeFrameLostFocus = TRUE;
}
gdk_window_get_pointer( widget->window, &x, &y, &state );
- InitMouseEvent(event, gdk_event);
-
- event.m_x = x;
- event.m_y = y;
+ InitMouseEvent(win, event, gdk_event);
+ wxPoint pt = win->GetClientAreaOrigin();
+ event.m_x = x + pt.x;
+ event.m_y = y + pt.y;
if (win->GetEventHandler()->ProcessEvent( event ))
{
event.m_middleDown = (state & GDK_BUTTON2_MASK);
event.m_rightDown = (state & GDK_BUTTON3_MASK);
- event.m_x = x;
- event.m_y = y;
+ wxPoint pt = win->GetClientAreaOrigin();
+ event.m_x = x + pt.x;
+ event.m_y = y + pt.y;
if (win->GetEventHandler()->ProcessEvent( event ))
{
m_isStaticBox = FALSE;
m_isRadioButton = FALSE;
+ m_isListBox = FALSE;
m_isFrame = FALSE;
m_acceptsFocus = FALSE;
{
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
+#if 0
+ wxPrintf( "SetFocus from " );
+ if (GetClassInfo() && GetClassInfo()->GetClassName())
+ wxPrintf( GetClassInfo()->GetClassName() );
+ wxPrintf( ".\n" );
+#endif
+
if (m_wxwindow)
{
if (!GTK_WIDGET_HAS_FOCUS (m_wxwindow))
// ?
}
}
+
+#if 0
+ wxPrintf( "SetFocus finished in " );
+ if (GetClassInfo() && GetClassInfo()->GetClassName())
+ wxPrintf( GetClassInfo()->GetClassName() );
+ wxPrintf( ".\n" );
+#endif
+
}
bool wxWindowGTK::AcceptsFocus() const
}
}
+// used to pass the coordinates from wxWindowGTK::DoPopupMenu() to
+// wxPopupMenuPositionCallback()
+//
+// should be safe even in the MT case as the user can hardly popup 2 menus
+// simultaneously, can he?
static gint gs_pop_x = 0;
static gint gs_pop_y = 0;
-static void pop_pos_callback( GtkMenu * WXUNUSED(menu),
- gint *x, gint *y,
- wxWindowGTK *win )
+static void wxPopupMenuPositionCallback( GtkMenu *menu,
+ gint *x, gint *y,
+ gpointer WXUNUSED(user_data) )
{
- win->ClientToScreen( &gs_pop_x, &gs_pop_y );
- *x = gs_pop_x;
- *y = gs_pop_y;
+ // ensure that the menu appears entirely on screen
+ GtkRequisition req;
+ gtk_widget_get_child_requisition(GTK_WIDGET(menu), &req);
+
+ wxSize sizeScreen = wxGetDisplaySize();
+
+ gint xmax = sizeScreen.x - req.width,
+ ymax = sizeScreen.y - req.height;
+
+ *x = gs_pop_x < xmax ? gs_pop_x : xmax;
+ *y = gs_pop_y < ymax ? gs_pop_y : ymax;
}
bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
gs_pop_x = x;
gs_pop_y = y;
+ ClientToScreen( &gs_pop_x, &gs_pop_y );
bool is_waiting = TRUE;
gtk_menu_popup(
GTK_MENU(menu->m_menu),
- (GtkWidget *) NULL, // parent menu shell
- (GtkWidget *) NULL, // parent menu item
- (GtkMenuPositionFunc) pop_pos_callback,
- (gpointer) this, // client data
- 0, // button used to activate it
- gs_timeLastClick // the time of activation
+ (GtkWidget *) NULL, // parent menu shell
+ (GtkWidget *) NULL, // parent menu item
+ wxPopupMenuPositionCallback, // function to position it
+ NULL, // client data
+ 0, // button used to activate it
+ gs_timeLastClick // the time of activation
);
while (is_waiting)