diff options
| author | Dmitry Antipov | 2013-09-13 10:00:20 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-09-13 10:00:20 +0400 |
| commit | 9a650e62c8bd9ab1040db70e22683bc94e918cc8 (patch) | |
| tree | 92952048ef06acbadfc571cb1cb7b13cbe8e3069 | |
| parent | 9dc7e8e1a4b04fe5ae98ca5df95f3a2bb1dfe0cf (diff) | |
| download | emacs-9a650e62c8bd9ab1040db70e22683bc94e918cc8.tar.gz emacs-9a650e62c8bd9ab1040db70e22683bc94e918cc8.zip | |
* xterm.h (x_window_to_frame, x_any_window_to_frame)
(x_menubar_window_to_frame): Remove prototypes.
* xfns.c (x_window_to_frame, x_any_window_to_frame)
(x_menubar_window_to_frame, x_top_window_to_frame):
Move from here...
* xterm.c (x_window_to_frame, x_any_window_to_frame)
(x_menubar_window_to_frame, x_top_window_to_frame):
...to here and convert all but the last to static.
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/xfns.c | 181 | ||||
| -rw-r--r-- | src/xterm.c | 175 | ||||
| -rw-r--r-- | src/xterm.h | 16 |
4 files changed, 187 insertions, 196 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f08395ae24f..960165a22f9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2013-09-13 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * xterm.h (x_window_to_frame, x_any_window_to_frame) | ||
| 4 | (x_menubar_window_to_frame): Remove prototypes. | ||
| 5 | * xfns.c (x_window_to_frame, x_any_window_to_frame) | ||
| 6 | (x_menubar_window_to_frame, x_top_window_to_frame): | ||
| 7 | Move from here... | ||
| 8 | * xterm.c (x_window_to_frame, x_any_window_to_frame) | ||
| 9 | (x_menubar_window_to_frame, x_top_window_to_frame): | ||
| 10 | ...to here and convert all but the last to static. | ||
| 11 | |||
| 1 | 2013-09-12 Eli Zaretskii <eliz@gnu.org> | 12 | 2013-09-12 Eli Zaretskii <eliz@gnu.org> |
| 2 | 13 | ||
| 3 | * lisp.mk (lisp): Add w32-common-fns.elc. | 14 | * lisp.mk (lisp): Add w32-common-fns.elc. |
diff --git a/src/xfns.c b/src/xfns.c index 74bc7a8b1d0..fa83b6faf1a 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -179,187 +179,6 @@ check_x_display_info (Lisp_Object object) | |||
| 179 | return dpyinfo; | 179 | return dpyinfo; |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | |||
| 183 | /* Return the Emacs frame-object corresponding to an X window. | ||
| 184 | It could be the frame's main window or an icon window. */ | ||
| 185 | |||
| 186 | /* This function can be called during GC, so use GC_xxx type test macros. */ | ||
| 187 | |||
| 188 | struct frame * | ||
| 189 | x_window_to_frame (struct x_display_info *dpyinfo, int wdesc) | ||
| 190 | { | ||
| 191 | Lisp_Object tail, frame; | ||
| 192 | struct frame *f; | ||
| 193 | |||
| 194 | if (wdesc == None) | ||
| 195 | return NULL; | ||
| 196 | |||
| 197 | FOR_EACH_FRAME (tail, frame) | ||
| 198 | { | ||
| 199 | f = XFRAME (frame); | ||
| 200 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) | ||
| 201 | continue; | ||
| 202 | if (f->output_data.x->hourglass_window == wdesc) | ||
| 203 | return f; | ||
| 204 | #ifdef USE_X_TOOLKIT | ||
| 205 | if ((f->output_data.x->edit_widget | ||
| 206 | && XtWindow (f->output_data.x->edit_widget) == wdesc) | ||
| 207 | /* A tooltip frame? */ | ||
| 208 | || (!f->output_data.x->edit_widget | ||
| 209 | && FRAME_X_WINDOW (f) == wdesc) | ||
| 210 | || f->output_data.x->icon_desc == wdesc) | ||
| 211 | return f; | ||
| 212 | #else /* not USE_X_TOOLKIT */ | ||
| 213 | #ifdef USE_GTK | ||
| 214 | if (f->output_data.x->edit_widget) | ||
| 215 | { | ||
| 216 | GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); | ||
| 217 | struct x_output *x = f->output_data.x; | ||
| 218 | if (gwdesc != 0 && gwdesc == x->edit_widget) | ||
| 219 | return f; | ||
| 220 | } | ||
| 221 | #endif /* USE_GTK */ | ||
| 222 | if (FRAME_X_WINDOW (f) == wdesc | ||
| 223 | || f->output_data.x->icon_desc == wdesc) | ||
| 224 | return f; | ||
| 225 | #endif /* not USE_X_TOOLKIT */ | ||
| 226 | } | ||
| 227 | return 0; | ||
| 228 | } | ||
| 229 | |||
| 230 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) | ||
| 231 | /* Like x_window_to_frame but also compares the window with the widget's | ||
| 232 | windows. */ | ||
| 233 | |||
| 234 | struct frame * | ||
| 235 | x_any_window_to_frame (struct x_display_info *dpyinfo, int wdesc) | ||
| 236 | { | ||
| 237 | Lisp_Object tail, frame; | ||
| 238 | struct frame *f, *found = NULL; | ||
| 239 | struct x_output *x; | ||
| 240 | |||
| 241 | if (wdesc == None) | ||
| 242 | return NULL; | ||
| 243 | |||
| 244 | FOR_EACH_FRAME (tail, frame) | ||
| 245 | { | ||
| 246 | if (found) | ||
| 247 | break; | ||
| 248 | f = XFRAME (frame); | ||
| 249 | if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo) | ||
| 250 | { | ||
| 251 | /* This frame matches if the window is any of its widgets. */ | ||
| 252 | x = f->output_data.x; | ||
| 253 | if (x->hourglass_window == wdesc) | ||
| 254 | found = f; | ||
| 255 | else if (x->widget) | ||
| 256 | { | ||
| 257 | #ifdef USE_GTK | ||
| 258 | GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); | ||
| 259 | if (gwdesc != 0 | ||
| 260 | && gtk_widget_get_toplevel (gwdesc) == x->widget) | ||
| 261 | found = f; | ||
| 262 | #else | ||
| 263 | if (wdesc == XtWindow (x->widget) | ||
| 264 | || wdesc == XtWindow (x->column_widget) | ||
| 265 | || wdesc == XtWindow (x->edit_widget)) | ||
| 266 | found = f; | ||
| 267 | /* Match if the window is this frame's menubar. */ | ||
| 268 | else if (lw_window_is_in_menubar (wdesc, x->menubar_widget)) | ||
| 269 | found = f; | ||
| 270 | #endif | ||
| 271 | } | ||
| 272 | else if (FRAME_X_WINDOW (f) == wdesc) | ||
| 273 | /* A tooltip frame. */ | ||
| 274 | found = f; | ||
| 275 | } | ||
| 276 | } | ||
| 277 | |||
| 278 | return found; | ||
| 279 | } | ||
| 280 | |||
| 281 | /* Likewise, but consider only the menu bar widget. */ | ||
| 282 | |||
| 283 | struct frame * | ||
| 284 | x_menubar_window_to_frame (struct x_display_info *dpyinfo, XEvent *event) | ||
| 285 | { | ||
| 286 | Window wdesc = event->xany.window; | ||
| 287 | Lisp_Object tail, frame; | ||
| 288 | struct frame *f; | ||
| 289 | struct x_output *x; | ||
| 290 | |||
| 291 | if (wdesc == None) | ||
| 292 | return NULL; | ||
| 293 | |||
| 294 | FOR_EACH_FRAME (tail, frame) | ||
| 295 | { | ||
| 296 | f = XFRAME (frame); | ||
| 297 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) | ||
| 298 | continue; | ||
| 299 | x = f->output_data.x; | ||
| 300 | #ifdef USE_GTK | ||
| 301 | if (x->menubar_widget && xg_event_is_for_menubar (f, event)) | ||
| 302 | return f; | ||
| 303 | #else | ||
| 304 | /* Match if the window is this frame's menubar. */ | ||
| 305 | if (x->menubar_widget | ||
| 306 | && lw_window_is_in_menubar (wdesc, x->menubar_widget)) | ||
| 307 | return f; | ||
| 308 | #endif | ||
| 309 | } | ||
| 310 | return 0; | ||
| 311 | } | ||
| 312 | |||
| 313 | /* Return the frame whose principal (outermost) window is WDESC. | ||
| 314 | If WDESC is some other (smaller) window, we return 0. */ | ||
| 315 | |||
| 316 | struct frame * | ||
| 317 | x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc) | ||
| 318 | { | ||
| 319 | Lisp_Object tail, frame; | ||
| 320 | struct frame *f; | ||
| 321 | struct x_output *x; | ||
| 322 | |||
| 323 | if (wdesc == None) | ||
| 324 | return NULL; | ||
| 325 | |||
| 326 | FOR_EACH_FRAME (tail, frame) | ||
| 327 | { | ||
| 328 | f = XFRAME (frame); | ||
| 329 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) | ||
| 330 | continue; | ||
| 331 | x = f->output_data.x; | ||
| 332 | |||
| 333 | if (x->widget) | ||
| 334 | { | ||
| 335 | /* This frame matches if the window is its topmost widget. */ | ||
| 336 | #ifdef USE_GTK | ||
| 337 | GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); | ||
| 338 | if (gwdesc == x->widget) | ||
| 339 | return f; | ||
| 340 | #else | ||
| 341 | if (wdesc == XtWindow (x->widget)) | ||
| 342 | return f; | ||
| 343 | #if 0 /* I don't know why it did this, | ||
| 344 | but it seems logically wrong, | ||
| 345 | and it causes trouble for MapNotify events. */ | ||
| 346 | /* Match if the window is this frame's menubar. */ | ||
| 347 | if (x->menubar_widget | ||
| 348 | && wdesc == XtWindow (x->menubar_widget)) | ||
| 349 | return f; | ||
| 350 | #endif | ||
| 351 | #endif | ||
| 352 | } | ||
| 353 | else if (FRAME_X_WINDOW (f) == wdesc) | ||
| 354 | /* Tooltip frame. */ | ||
| 355 | return f; | ||
| 356 | } | ||
| 357 | return 0; | ||
| 358 | } | ||
| 359 | #endif /* USE_X_TOOLKIT || USE_GTK */ | ||
| 360 | |||
| 361 | |||
| 362 | |||
| 363 | /* Store the screen positions of frame F into XPTR and YPTR. | 182 | /* Store the screen positions of frame F into XPTR and YPTR. |
| 364 | These are the positions of the containing window manager window, | 183 | These are the positions of the containing window manager window, |
| 365 | not Emacs's own window. */ | 184 | not Emacs's own window. */ |
diff --git a/src/xterm.c b/src/xterm.c index c28ca824063..ef800461185 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -3389,6 +3389,181 @@ x_focus_changed (int type, int state, struct x_display_info *dpyinfo, struct fra | |||
| 3389 | } | 3389 | } |
| 3390 | } | 3390 | } |
| 3391 | 3391 | ||
| 3392 | /* Return the Emacs frame-object corresponding to an X window. | ||
| 3393 | It could be the frame's main window or an icon window. */ | ||
| 3394 | |||
| 3395 | static struct frame * | ||
| 3396 | x_window_to_frame (struct x_display_info *dpyinfo, int wdesc) | ||
| 3397 | { | ||
| 3398 | Lisp_Object tail, frame; | ||
| 3399 | struct frame *f; | ||
| 3400 | |||
| 3401 | if (wdesc == None) | ||
| 3402 | return NULL; | ||
| 3403 | |||
| 3404 | FOR_EACH_FRAME (tail, frame) | ||
| 3405 | { | ||
| 3406 | f = XFRAME (frame); | ||
| 3407 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) | ||
| 3408 | continue; | ||
| 3409 | if (f->output_data.x->hourglass_window == wdesc) | ||
| 3410 | return f; | ||
| 3411 | #ifdef USE_X_TOOLKIT | ||
| 3412 | if ((f->output_data.x->edit_widget | ||
| 3413 | && XtWindow (f->output_data.x->edit_widget) == wdesc) | ||
| 3414 | /* A tooltip frame? */ | ||
| 3415 | || (!f->output_data.x->edit_widget | ||
| 3416 | && FRAME_X_WINDOW (f) == wdesc) | ||
| 3417 | || f->output_data.x->icon_desc == wdesc) | ||
| 3418 | return f; | ||
| 3419 | #else /* not USE_X_TOOLKIT */ | ||
| 3420 | #ifdef USE_GTK | ||
| 3421 | if (f->output_data.x->edit_widget) | ||
| 3422 | { | ||
| 3423 | GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); | ||
| 3424 | struct x_output *x = f->output_data.x; | ||
| 3425 | if (gwdesc != 0 && gwdesc == x->edit_widget) | ||
| 3426 | return f; | ||
| 3427 | } | ||
| 3428 | #endif /* USE_GTK */ | ||
| 3429 | if (FRAME_X_WINDOW (f) == wdesc | ||
| 3430 | || f->output_data.x->icon_desc == wdesc) | ||
| 3431 | return f; | ||
| 3432 | #endif /* not USE_X_TOOLKIT */ | ||
| 3433 | } | ||
| 3434 | return 0; | ||
| 3435 | } | ||
| 3436 | |||
| 3437 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) | ||
| 3438 | |||
| 3439 | /* Like x_window_to_frame but also compares the window with the widget's | ||
| 3440 | windows. */ | ||
| 3441 | |||
| 3442 | static struct frame * | ||
| 3443 | x_any_window_to_frame (struct x_display_info *dpyinfo, int wdesc) | ||
| 3444 | { | ||
| 3445 | Lisp_Object tail, frame; | ||
| 3446 | struct frame *f, *found = NULL; | ||
| 3447 | struct x_output *x; | ||
| 3448 | |||
| 3449 | if (wdesc == None) | ||
| 3450 | return NULL; | ||
| 3451 | |||
| 3452 | FOR_EACH_FRAME (tail, frame) | ||
| 3453 | { | ||
| 3454 | if (found) | ||
| 3455 | break; | ||
| 3456 | f = XFRAME (frame); | ||
| 3457 | if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo) | ||
| 3458 | { | ||
| 3459 | /* This frame matches if the window is any of its widgets. */ | ||
| 3460 | x = f->output_data.x; | ||
| 3461 | if (x->hourglass_window == wdesc) | ||
| 3462 | found = f; | ||
| 3463 | else if (x->widget) | ||
| 3464 | { | ||
| 3465 | #ifdef USE_GTK | ||
| 3466 | GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); | ||
| 3467 | if (gwdesc != 0 | ||
| 3468 | && gtk_widget_get_toplevel (gwdesc) == x->widget) | ||
| 3469 | found = f; | ||
| 3470 | #else | ||
| 3471 | if (wdesc == XtWindow (x->widget) | ||
| 3472 | || wdesc == XtWindow (x->column_widget) | ||
| 3473 | || wdesc == XtWindow (x->edit_widget)) | ||
| 3474 | found = f; | ||
| 3475 | /* Match if the window is this frame's menubar. */ | ||
| 3476 | else if (lw_window_is_in_menubar (wdesc, x->menubar_widget)) | ||
| 3477 | found = f; | ||
| 3478 | #endif | ||
| 3479 | } | ||
| 3480 | else if (FRAME_X_WINDOW (f) == wdesc) | ||
| 3481 | /* A tooltip frame. */ | ||
| 3482 | found = f; | ||
| 3483 | } | ||
| 3484 | } | ||
| 3485 | |||
| 3486 | return found; | ||
| 3487 | } | ||
| 3488 | |||
| 3489 | /* Likewise, but consider only the menu bar widget. */ | ||
| 3490 | |||
| 3491 | static struct frame * | ||
| 3492 | x_menubar_window_to_frame (struct x_display_info *dpyinfo, XEvent *event) | ||
| 3493 | { | ||
| 3494 | Window wdesc = event->xany.window; | ||
| 3495 | Lisp_Object tail, frame; | ||
| 3496 | struct frame *f; | ||
| 3497 | struct x_output *x; | ||
| 3498 | |||
| 3499 | if (wdesc == None) | ||
| 3500 | return NULL; | ||
| 3501 | |||
| 3502 | FOR_EACH_FRAME (tail, frame) | ||
| 3503 | { | ||
| 3504 | f = XFRAME (frame); | ||
| 3505 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) | ||
| 3506 | continue; | ||
| 3507 | x = f->output_data.x; | ||
| 3508 | #ifdef USE_GTK | ||
| 3509 | if (x->menubar_widget && xg_event_is_for_menubar (f, event)) | ||
| 3510 | return f; | ||
| 3511 | #else | ||
| 3512 | /* Match if the window is this frame's menubar. */ | ||
| 3513 | if (x->menubar_widget | ||
| 3514 | && lw_window_is_in_menubar (wdesc, x->menubar_widget)) | ||
| 3515 | return f; | ||
| 3516 | #endif | ||
| 3517 | } | ||
| 3518 | return 0; | ||
| 3519 | } | ||
| 3520 | |||
| 3521 | /* Return the frame whose principal (outermost) window is WDESC. | ||
| 3522 | If WDESC is some other (smaller) window, we return 0. */ | ||
| 3523 | |||
| 3524 | struct frame * | ||
| 3525 | x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc) | ||
| 3526 | { | ||
| 3527 | Lisp_Object tail, frame; | ||
| 3528 | struct frame *f; | ||
| 3529 | struct x_output *x; | ||
| 3530 | |||
| 3531 | if (wdesc == None) | ||
| 3532 | return NULL; | ||
| 3533 | |||
| 3534 | FOR_EACH_FRAME (tail, frame) | ||
| 3535 | { | ||
| 3536 | f = XFRAME (frame); | ||
| 3537 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) | ||
| 3538 | continue; | ||
| 3539 | x = f->output_data.x; | ||
| 3540 | |||
| 3541 | if (x->widget) | ||
| 3542 | { | ||
| 3543 | /* This frame matches if the window is its topmost widget. */ | ||
| 3544 | #ifdef USE_GTK | ||
| 3545 | GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); | ||
| 3546 | if (gwdesc == x->widget) | ||
| 3547 | return f; | ||
| 3548 | #else | ||
| 3549 | if (wdesc == XtWindow (x->widget)) | ||
| 3550 | return f; | ||
| 3551 | #endif | ||
| 3552 | } | ||
| 3553 | else if (FRAME_X_WINDOW (f) == wdesc) | ||
| 3554 | /* Tooltip frame. */ | ||
| 3555 | return f; | ||
| 3556 | } | ||
| 3557 | return 0; | ||
| 3558 | } | ||
| 3559 | |||
| 3560 | #else /* !USE_X_TOOLKIT && !USE_GTK */ | ||
| 3561 | |||
| 3562 | #define x_any_window_to_frame(d, i) x_window_to_frame (d, i) | ||
| 3563 | #define x_top_window_to_frame(d, i) x_window_to_frame (d, i) | ||
| 3564 | |||
| 3565 | #endif /* USE_X_TOOLKIT || USE_GTK */ | ||
| 3566 | |||
| 3392 | /* The focus may have changed. Figure out if it is a real focus change, | 3567 | /* The focus may have changed. Figure out if it is a real focus change, |
| 3393 | by checking both FocusIn/Out and Enter/LeaveNotify events. | 3568 | by checking both FocusIn/Out and Enter/LeaveNotify events. |
| 3394 | 3569 | ||
diff --git a/src/xterm.h b/src/xterm.h index bdc8523009a..2f29667684d 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -376,20 +376,6 @@ struct x_display_info | |||
| 376 | extern int use_xim; | 376 | extern int use_xim; |
| 377 | #endif | 377 | #endif |
| 378 | 378 | ||
| 379 | extern struct frame *x_window_to_frame (struct x_display_info *, int); | ||
| 380 | extern struct frame *x_any_window_to_frame (struct x_display_info *, int); | ||
| 381 | extern struct frame *x_menubar_window_to_frame (struct x_display_info *, | ||
| 382 | XEvent *); | ||
| 383 | extern struct frame *x_top_window_to_frame (struct x_display_info *, int); | ||
| 384 | |||
| 385 | extern struct frame *x_menubar_window_to_frame (struct x_display_info *, | ||
| 386 | XEvent *); | ||
| 387 | |||
| 388 | #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) | ||
| 389 | #define x_any_window_to_frame x_window_to_frame | ||
| 390 | #define x_top_window_to_frame x_window_to_frame | ||
| 391 | #endif | ||
| 392 | |||
| 393 | /* This is a chain of structures for all the X displays currently in use. */ | 379 | /* This is a chain of structures for all the X displays currently in use. */ |
| 394 | extern struct x_display_info *x_display_list; | 380 | extern struct x_display_info *x_display_list; |
| 395 | 381 | ||
| @@ -400,7 +386,7 @@ extern struct x_display_info *x_display_list; | |||
| 400 | extern Lisp_Object x_display_name_list; | 386 | extern Lisp_Object x_display_name_list; |
| 401 | 387 | ||
| 402 | extern struct x_display_info *x_display_info_for_display (Display *); | 388 | extern struct x_display_info *x_display_info_for_display (Display *); |
| 403 | 389 | extern struct frame *x_top_window_to_frame (struct x_display_info *, int); | |
| 404 | extern struct x_display_info *x_term_init (Lisp_Object, char *, char *); | 390 | extern struct x_display_info *x_term_init (Lisp_Object, char *, char *); |
| 405 | extern bool x_display_ok (const char *); | 391 | extern bool x_display_ok (const char *); |
| 406 | 392 | ||