diff options
Diffstat (limited to 'src/widget.c')
| -rw-r--r-- | src/widget.c | 90 |
1 files changed, 31 insertions, 59 deletions
diff --git a/src/widget.c b/src/widget.c index 0cb1013b971..ec0b506046b 100644 --- a/src/widget.c +++ b/src/widget.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* The emacs frame widget. | 1 | /* The emacs frame widget. |
| 2 | Copyright (C) 1992-1993, 2000-2012 Free Software Foundation, Inc. | 2 | Copyright (C) 1992-1993, 2000-2013 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -30,7 +30,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 30 | 30 | ||
| 31 | #include <config.h> | 31 | #include <config.h> |
| 32 | #include <stdio.h> | 32 | #include <stdio.h> |
| 33 | #include <setjmp.h> | 33 | |
| 34 | #include "lisp.h" | 34 | #include "lisp.h" |
| 35 | #include "xterm.h" | 35 | #include "xterm.h" |
| 36 | 36 | ||
| @@ -50,9 +50,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 50 | #include <X11/ShellP.h> | 50 | #include <X11/ShellP.h> |
| 51 | #include "../lwlib/lwlib.h" | 51 | #include "../lwlib/lwlib.h" |
| 52 | 52 | ||
| 53 | #include <signal.h> | ||
| 54 | #include "syssignal.h" | ||
| 55 | |||
| 56 | #include "character.h" | 53 | #include "character.h" |
| 57 | #include "font.h" | 54 | #include "font.h" |
| 58 | 55 | ||
| @@ -226,7 +223,7 @@ get_wm_shell (Widget w) | |||
| 226 | static void | 223 | static void |
| 227 | mark_shell_size_user_specified (Widget wmshell) | 224 | mark_shell_size_user_specified (Widget wmshell) |
| 228 | { | 225 | { |
| 229 | if (! XtIsWMShell (wmshell)) abort (); | 226 | if (! XtIsWMShell (wmshell)) emacs_abort (); |
| 230 | /* This is kind of sleazy, but I can't see how else to tell it to make it | 227 | /* This is kind of sleazy, but I can't see how else to tell it to make it |
| 231 | mark the WM_SIZE_HINTS size as user specified when appropriate. */ | 228 | mark the WM_SIZE_HINTS size as user specified when appropriate. */ |
| 232 | ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize; | 229 | ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize; |
| @@ -290,7 +287,7 @@ set_frame_size (EmacsFrame ew) | |||
| 290 | Widget wmshell = get_wm_shell ((Widget) ew); | 287 | Widget wmshell = get_wm_shell ((Widget) ew); |
| 291 | /* Each Emacs shell is now independent and top-level. */ | 288 | /* Each Emacs shell is now independent and top-level. */ |
| 292 | 289 | ||
| 293 | if (! XtIsSubclass (wmshell, shellWidgetClass)) abort (); | 290 | if (! XtIsSubclass (wmshell, shellWidgetClass)) emacs_abort (); |
| 294 | 291 | ||
| 295 | /* We don't need this for the moment. The geometry is computed in | 292 | /* We don't need this for the moment. The geometry is computed in |
| 296 | xfns.c. */ | 293 | xfns.c. */ |
| @@ -429,25 +426,15 @@ set_frame_size (EmacsFrame ew) | |||
| 429 | { | 426 | { |
| 430 | /* the tricky things with the sign is to make sure that | 427 | /* the tricky things with the sign is to make sure that |
| 431 | -0 is printed -0. */ | 428 | -0 is printed -0. */ |
| 432 | int len; | ||
| 433 | char *tem; | ||
| 434 | sprintf (shell_position, "=%c%d%c%d", | 429 | sprintf (shell_position, "=%c%d%c%d", |
| 435 | flags & XNegative ? '-' : '+', x < 0 ? -x : x, | 430 | flags & XNegative ? '-' : '+', x < 0 ? -x : x, |
| 436 | flags & YNegative ? '-' : '+', y < 0 ? -y : y); | 431 | flags & YNegative ? '-' : '+', y < 0 ? -y : y); |
| 437 | len = strlen (shell_position) + 1; | 432 | XtVaSetValues (wmshell, XtNgeometry, xstrdup (shell_position), NULL); |
| 438 | tem = (char *) xmalloc (len); | ||
| 439 | strncpy (tem, shell_position, len); | ||
| 440 | XtVaSetValues (wmshell, XtNgeometry, tem, NULL); | ||
| 441 | } | 433 | } |
| 442 | else if (flags & (WidthValue | HeightValue)) | 434 | else if (flags & (WidthValue | HeightValue)) |
| 443 | { | 435 | { |
| 444 | int len; | ||
| 445 | char *tem; | ||
| 446 | sprintf (shell_position, "=%dx%d", pixel_width, pixel_height); | 436 | sprintf (shell_position, "=%dx%d", pixel_width, pixel_height); |
| 447 | len = strlen (shell_position) + 1; | 437 | XtVaSetValues (wmshell, XtNgeometry, xstrdup (shell_position), NULL); |
| 448 | tem = (char *) xmalloc (len); | ||
| 449 | strncpy (tem, shell_position, len); | ||
| 450 | XtVaSetValues (wmshell, XtNgeometry, tem, NULL); | ||
| 451 | } | 438 | } |
| 452 | 439 | ||
| 453 | /* If the geometry spec we're using has W/H components, mark the size | 440 | /* If the geometry spec we're using has W/H components, mark the size |
| @@ -516,26 +503,6 @@ widget_update_wm_size_hints (Widget widget) | |||
| 516 | update_wm_hints (ew); | 503 | update_wm_hints (ew); |
| 517 | } | 504 | } |
| 518 | 505 | ||
| 519 | |||
| 520 | #if 0 | ||
| 521 | |||
| 522 | static void | ||
| 523 | create_frame_gcs (EmacsFrame ew) | ||
| 524 | { | ||
| 525 | struct frame *s = ew->emacs_frame.frame; | ||
| 526 | |||
| 527 | s->output_data.x->normal_gc | ||
| 528 | = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0); | ||
| 529 | s->output_data.x->reverse_gc | ||
| 530 | = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0); | ||
| 531 | s->output_data.x->cursor_gc | ||
| 532 | = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0); | ||
| 533 | s->output_data.x->black_relief.gc = 0; | ||
| 534 | s->output_data.x->white_relief.gc = 0; | ||
| 535 | } | ||
| 536 | |||
| 537 | #endif /* 0 */ | ||
| 538 | |||
| 539 | static char setup_frame_cursor_bits[] = | 506 | static char setup_frame_cursor_bits[] = |
| 540 | { | 507 | { |
| 541 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 508 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| @@ -663,6 +630,15 @@ EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2) | |||
| 663 | set_frame_size (ew); | 630 | set_frame_size (ew); |
| 664 | } | 631 | } |
| 665 | 632 | ||
| 633 | static void | ||
| 634 | resize_cb (Widget widget, | ||
| 635 | XtPointer closure, | ||
| 636 | XEvent* event, | ||
| 637 | Boolean* continue_to_dispatch) | ||
| 638 | { | ||
| 639 | EmacsFrameResize (widget); | ||
| 640 | } | ||
| 641 | |||
| 666 | 642 | ||
| 667 | static void | 643 | static void |
| 668 | EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs) | 644 | EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs) |
| @@ -678,27 +654,16 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs | |||
| 678 | *mask |= CWEventMask; | 654 | *mask |= CWEventMask; |
| 679 | XtCreateWindow (widget, InputOutput, (Visual *)CopyFromParent, *mask, | 655 | XtCreateWindow (widget, InputOutput, (Visual *)CopyFromParent, *mask, |
| 680 | attrs); | 656 | attrs); |
| 657 | /* Some ConfigureNotify events does not end up in EmacsFrameResize so | ||
| 658 | make sure we get them all. Seen with xfcwm4 for example. */ | ||
| 659 | XtAddRawEventHandler (widget, StructureNotifyMask, False, resize_cb, NULL); | ||
| 681 | update_wm_hints (ew); | 660 | update_wm_hints (ew); |
| 682 | } | 661 | } |
| 683 | 662 | ||
| 684 | extern void free_frame_faces (struct frame *); | ||
| 685 | |||
| 686 | static void | 663 | static void |
| 687 | EmacsFrameDestroy (Widget widget) | 664 | EmacsFrameDestroy (Widget widget) |
| 688 | { | 665 | { |
| 689 | EmacsFrame ew = (EmacsFrame) widget; | 666 | /* All GCs are now freed in x_free_frame_resources. */ |
| 690 | struct frame* s = ew->emacs_frame.frame; | ||
| 691 | |||
| 692 | if (! s) abort (); | ||
| 693 | if (! s->output_data.x) abort (); | ||
| 694 | |||
| 695 | BLOCK_INPUT; | ||
| 696 | x_free_gcs (s); | ||
| 697 | if (s->output_data.x->white_relief.gc) | ||
| 698 | XFreeGC (XtDisplay (widget), s->output_data.x->white_relief.gc); | ||
| 699 | if (s->output_data.x->black_relief.gc) | ||
| 700 | XFreeGC (XtDisplay (widget), s->output_data.x->black_relief.gc); | ||
| 701 | UNBLOCK_INPUT; | ||
| 702 | } | 667 | } |
| 703 | 668 | ||
| 704 | static void | 669 | static void |
| @@ -706,15 +671,22 @@ EmacsFrameResize (Widget widget) | |||
| 706 | { | 671 | { |
| 707 | EmacsFrame ew = (EmacsFrame)widget; | 672 | EmacsFrame ew = (EmacsFrame)widget; |
| 708 | struct frame *f = ew->emacs_frame.frame; | 673 | struct frame *f = ew->emacs_frame.frame; |
| 674 | struct x_output *x = f->output_data.x; | ||
| 709 | int columns; | 675 | int columns; |
| 710 | int rows; | 676 | int rows; |
| 711 | 677 | ||
| 712 | pixel_to_char_size (ew, ew->core.width, ew->core.height, &columns, &rows); | 678 | pixel_to_char_size (ew, ew->core.width, ew->core.height, &columns, &rows); |
| 713 | change_frame_size (f, rows, columns, 0, 1, 0); | 679 | if (columns != FRAME_COLS (f) |
| 714 | update_wm_hints (ew); | 680 | || rows != FRAME_LINES (f) |
| 715 | update_various_frame_slots (ew); | 681 | || ew->core.width != FRAME_PIXEL_WIDTH (f) |
| 682 | || ew->core.height + x->menubar_height != FRAME_PIXEL_HEIGHT (f)) | ||
| 683 | { | ||
| 684 | change_frame_size (f, rows, columns, 0, 1, 0); | ||
| 685 | update_wm_hints (ew); | ||
| 686 | update_various_frame_slots (ew); | ||
| 716 | 687 | ||
| 717 | cancel_mouse_face (f); | 688 | cancel_mouse_face (f); |
| 689 | } | ||
| 718 | } | 690 | } |
| 719 | 691 | ||
| 720 | static Boolean | 692 | static Boolean |
| @@ -834,7 +806,7 @@ void | |||
| 834 | widget_store_internal_border (Widget widget) | 806 | widget_store_internal_border (Widget widget) |
| 835 | { | 807 | { |
| 836 | EmacsFrame ew = (EmacsFrame) widget; | 808 | EmacsFrame ew = (EmacsFrame) widget; |
| 837 | FRAME_PTR f = ew->emacs_frame.frame; | 809 | struct frame *f = ew->emacs_frame.frame; |
| 838 | 810 | ||
| 839 | ew->emacs_frame.internal_border_width = f->internal_border_width; | 811 | ew->emacs_frame.internal_border_width = f->internal_border_width; |
| 840 | } | 812 | } |