wxGTK popup menu positioning fix
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12448 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -68,6 +68,10 @@ wxMSW:
|
|||||||
|
|
||||||
- support for the DBCS fonts (CP 932, 936, 949, 950) (Nathan Cook)
|
- support for the DBCS fonts (CP 932, 936, 949, 950) (Nathan Cook)
|
||||||
|
|
||||||
|
wxGTK:
|
||||||
|
|
||||||
|
- fixed popup menu positioning bug
|
||||||
|
|
||||||
wxHTML:
|
wxHTML:
|
||||||
|
|
||||||
- new HTML parser with correct parsing of character entities and fixes
|
- new HTML parser with correct parsing of character entities and fixes
|
||||||
|
@@ -3734,16 +3734,29 @@ static void SetInvokingWindow( wxMenu *menu, wxWindowGTK *win )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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_x = 0;
|
||||||
static gint gs_pop_y = 0;
|
static gint gs_pop_y = 0;
|
||||||
|
|
||||||
static void pop_pos_callback( GtkMenu * WXUNUSED(menu),
|
static void wxPopupMenuPositionCallback( GtkMenu *menu,
|
||||||
gint *x, gint *y,
|
gint *x, gint *y,
|
||||||
wxWindowGTK *win )
|
gpointer * WXUNUSED(user_data) )
|
||||||
{
|
{
|
||||||
win->ClientToScreen( &gs_pop_x, &gs_pop_y );
|
// ensure that the menu appears entirely on screen
|
||||||
*x = gs_pop_x;
|
GtkRequisition req;
|
||||||
*y = gs_pop_y;
|
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 )
|
bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
|
||||||
@@ -3758,6 +3771,7 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
|
|||||||
|
|
||||||
gs_pop_x = x;
|
gs_pop_x = x;
|
||||||
gs_pop_y = y;
|
gs_pop_y = y;
|
||||||
|
ClientToScreen( &gs_pop_x, &gs_pop_y );
|
||||||
|
|
||||||
bool is_waiting = TRUE;
|
bool is_waiting = TRUE;
|
||||||
|
|
||||||
@@ -3766,12 +3780,12 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
|
|||||||
|
|
||||||
gtk_menu_popup(
|
gtk_menu_popup(
|
||||||
GTK_MENU(menu->m_menu),
|
GTK_MENU(menu->m_menu),
|
||||||
(GtkWidget *) NULL, // parent menu shell
|
(GtkWidget *) NULL, // parent menu shell
|
||||||
(GtkWidget *) NULL, // parent menu item
|
(GtkWidget *) NULL, // parent menu item
|
||||||
(GtkMenuPositionFunc) pop_pos_callback,
|
wxPopupMenuPositionCallback, // function to position it
|
||||||
(gpointer) this, // client data
|
NULL, // client data
|
||||||
0, // button used to activate it
|
0, // button used to activate it
|
||||||
gs_timeLastClick // the time of activation
|
gs_timeLastClick // the time of activation
|
||||||
);
|
);
|
||||||
|
|
||||||
while (is_waiting)
|
while (is_waiting)
|
||||||
|
@@ -3734,16 +3734,29 @@ static void SetInvokingWindow( wxMenu *menu, wxWindowGTK *win )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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_x = 0;
|
||||||
static gint gs_pop_y = 0;
|
static gint gs_pop_y = 0;
|
||||||
|
|
||||||
static void pop_pos_callback( GtkMenu * WXUNUSED(menu),
|
static void wxPopupMenuPositionCallback( GtkMenu *menu,
|
||||||
gint *x, gint *y,
|
gint *x, gint *y,
|
||||||
wxWindowGTK *win )
|
gpointer * WXUNUSED(user_data) )
|
||||||
{
|
{
|
||||||
win->ClientToScreen( &gs_pop_x, &gs_pop_y );
|
// ensure that the menu appears entirely on screen
|
||||||
*x = gs_pop_x;
|
GtkRequisition req;
|
||||||
*y = gs_pop_y;
|
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 )
|
bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
|
||||||
@@ -3758,6 +3771,7 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
|
|||||||
|
|
||||||
gs_pop_x = x;
|
gs_pop_x = x;
|
||||||
gs_pop_y = y;
|
gs_pop_y = y;
|
||||||
|
ClientToScreen( &gs_pop_x, &gs_pop_y );
|
||||||
|
|
||||||
bool is_waiting = TRUE;
|
bool is_waiting = TRUE;
|
||||||
|
|
||||||
@@ -3766,12 +3780,12 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
|
|||||||
|
|
||||||
gtk_menu_popup(
|
gtk_menu_popup(
|
||||||
GTK_MENU(menu->m_menu),
|
GTK_MENU(menu->m_menu),
|
||||||
(GtkWidget *) NULL, // parent menu shell
|
(GtkWidget *) NULL, // parent menu shell
|
||||||
(GtkWidget *) NULL, // parent menu item
|
(GtkWidget *) NULL, // parent menu item
|
||||||
(GtkMenuPositionFunc) pop_pos_callback,
|
wxPopupMenuPositionCallback, // function to position it
|
||||||
(gpointer) this, // client data
|
NULL, // client data
|
||||||
0, // button used to activate it
|
0, // button used to activate it
|
||||||
gs_timeLastClick // the time of activation
|
gs_timeLastClick // the time of activation
|
||||||
);
|
);
|
||||||
|
|
||||||
while (is_waiting)
|
while (is_waiting)
|
||||||
|
Reference in New Issue
Block a user