2241 |
create_and_show_popup_menu below. */ |
create_and_show_popup_menu below. */ |
2242 |
struct next_popup_x_y |
struct next_popup_x_y |
2243 |
{ |
{ |
2244 |
|
FRAME_PTR f; |
2245 |
int x; |
int x; |
2246 |
int y; |
int y; |
2247 |
}; |
}; |
2253 |
PUSH_IN is not documented in the GTK manual. |
PUSH_IN is not documented in the GTK manual. |
2254 |
USER_DATA is any data passed in when calling gtk_menu_popup. |
USER_DATA is any data passed in when calling gtk_menu_popup. |
2255 |
Here it points to a struct next_popup_x_y where the coordinates |
Here it points to a struct next_popup_x_y where the coordinates |
2256 |
to store in *X and *Y are. |
to store in *X and *Y are as well as the frame for the popup. |
2257 |
|
|
2258 |
Here only X and Y are used. */ |
Here only X and Y are used. */ |
2259 |
static void |
static void |
2264 |
gboolean *push_in; |
gboolean *push_in; |
2265 |
gpointer user_data; |
gpointer user_data; |
2266 |
{ |
{ |
2267 |
*x = ((struct next_popup_x_y*)user_data)->x; |
struct next_popup_x_y* data = (struct next_popup_x_y*)user_data; |
2268 |
*y = ((struct next_popup_x_y*)user_data)->y; |
GtkRequisition req; |
2269 |
|
int disp_width = FRAME_X_DISPLAY_INFO (data->f)->width; |
2270 |
|
int disp_height = FRAME_X_DISPLAY_INFO (data->f)->height; |
2271 |
|
|
2272 |
|
*x = data->x; |
2273 |
|
*y = data->y; |
2274 |
|
|
2275 |
|
/* Check if there is room for the menu. If not, adjust x/y so that |
2276 |
|
the menu is fully visible. */ |
2277 |
|
gtk_widget_size_request (GTK_WIDGET (menu), &req); |
2278 |
|
if (data->x + req.width > disp_width) |
2279 |
|
*x -= data->x + req.width - disp_width; |
2280 |
|
if (data->y + req.height > disp_height) |
2281 |
|
*y -= data->y + req.height - disp_height; |
2282 |
} |
} |
2283 |
|
|
2284 |
static void |
static void |
2330 |
|
|
2331 |
popup_x_y.x = x; |
popup_x_y.x = x; |
2332 |
popup_x_y.y = y; |
popup_x_y.y = y; |
2333 |
|
popup_x_y.f = f; |
2334 |
} |
} |
2335 |
|
|
2336 |
/* Display the menu. */ |
/* Display the menu. */ |