Mercurial > emacs
comparison src/xmenu.c @ 49651:05ebf4266798
xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
xmenu.c (menu_position_func): Adjust menu popup position so that
the menu is fully visible.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Sat, 08 Feb 2003 11:18:32 +0000 |
parents | 23a1cea22d13 |
children | 140fa7af01db d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
49650:31ba10b86927 | 49651:05ebf4266798 |
---|---|
2239 | 2239 |
2240 /* Used when position a popup menu. See menu_position_func and | 2240 /* Used when position a popup menu. See menu_position_func and |
2241 create_and_show_popup_menu below. */ | 2241 create_and_show_popup_menu below. */ |
2242 struct next_popup_x_y | 2242 struct next_popup_x_y |
2243 { | 2243 { |
2244 FRAME_PTR f; | |
2244 int x; | 2245 int x; |
2245 int y; | 2246 int y; |
2246 }; | 2247 }; |
2247 | 2248 |
2248 /* The menu position function to use if we are not putting a popup | 2249 /* The menu position function to use if we are not putting a popup |
2250 MENU is the menu to pop up. | 2251 MENU is the menu to pop up. |
2251 X and Y shall on exit contain x/y where the menu shall pop up. | 2252 X and Y shall on exit contain x/y where the menu shall pop up. |
2252 PUSH_IN is not documented in the GTK manual. | 2253 PUSH_IN is not documented in the GTK manual. |
2253 USER_DATA is any data passed in when calling gtk_menu_popup. | 2254 USER_DATA is any data passed in when calling gtk_menu_popup. |
2254 Here it points to a struct next_popup_x_y where the coordinates | 2255 Here it points to a struct next_popup_x_y where the coordinates |
2255 to store in *X and *Y are. | 2256 to store in *X and *Y are as well as the frame for the popup. |
2256 | 2257 |
2257 Here only X and Y are used. */ | 2258 Here only X and Y are used. */ |
2258 static void | 2259 static void |
2259 menu_position_func (menu, x, y, push_in, user_data) | 2260 menu_position_func (menu, x, y, push_in, user_data) |
2260 GtkMenu *menu; | 2261 GtkMenu *menu; |
2261 gint *x; | 2262 gint *x; |
2262 gint *y; | 2263 gint *y; |
2263 gboolean *push_in; | 2264 gboolean *push_in; |
2264 gpointer user_data; | 2265 gpointer user_data; |
2265 { | 2266 { |
2266 *x = ((struct next_popup_x_y*)user_data)->x; | 2267 struct next_popup_x_y* data = (struct next_popup_x_y*)user_data; |
2267 *y = ((struct next_popup_x_y*)user_data)->y; | 2268 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; | |
2268 } | 2282 } |
2269 | 2283 |
2270 static void | 2284 static void |
2271 popup_selection_callback (widget, client_data) | 2285 popup_selection_callback (widget, client_data) |
2272 GtkWidget *widget; | 2286 GtkWidget *widget; |
2314 x += f->output_data.x->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); | 2328 x += f->output_data.x->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); |
2315 y += f->output_data.x->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); | 2329 y += f->output_data.x->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); |
2316 | 2330 |
2317 popup_x_y.x = x; | 2331 popup_x_y.x = x; |
2318 popup_x_y.y = y; | 2332 popup_x_y.y = y; |
2333 popup_x_y.f = f; | |
2319 } | 2334 } |
2320 | 2335 |
2321 /* Display the menu. */ | 2336 /* Display the menu. */ |
2322 gtk_widget_show_all (menu); | 2337 gtk_widget_show_all (menu); |
2323 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0); | 2338 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0); |