X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/e8f2a944716884ba72b9ef3a49db2d5bca428ac9..ab422c4d6899b1442cb6954c1829c1fb656b006c:/src/widget.c diff --git a/src/widget.c b/src/widget.c index 6d871ad7cb..28e9fc29a9 100644 --- a/src/widget.c +++ b/src/widget.c @@ -1,5 +1,5 @@ /* The emacs frame widget. - Copyright (C) 1992-1993, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1992-1993, 2000-2013 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -30,7 +30,7 @@ along with GNU Emacs. If not, see . */ #include #include -#include + #include "lisp.h" #include "xterm.h" @@ -50,9 +50,6 @@ along with GNU Emacs. If not, see . */ #include #include "../lwlib/lwlib.h" -#include -#include "syssignal.h" - #include "character.h" #include "font.h" @@ -86,12 +83,12 @@ static XtGeometryResult EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry #undef XtOffset #define XtOffset(p_type,field) \ ((Cardinal) (((char *) (&(((p_type)0)->field))) - ((char *)0))) -#define offset(field) XtOffset(EmacsFrame, emacs_frame.field) +#define offset(field) XtOffset (EmacsFrame, emacs_frame.field) static XtResource resources[] = { - {XtNgeometry, XtCGeometry, XtRString, sizeof(String), + {XtNgeometry, XtCGeometry, XtRString, sizeof (String), offset (geometry), XtRString, (XtPointer) 0}, - {XtNiconic, XtCIconic, XtRBoolean, sizeof(Boolean), + {XtNiconic, XtCIconic, XtRBoolean, sizeof (Boolean), offset (iconic), XtRImmediate, (XtPointer) False}, {XtNemacsFrame, XtCEmacsFrame, XtRPointer, sizeof (XtPointer), @@ -105,12 +102,12 @@ static XtResource resources[] = { offset (internal_border_width), XtRImmediate, (XtPointer)4}, {XtNinterline, XtCInterline, XtRInt, sizeof (int), offset (interline), XtRImmediate, (XtPointer)0}, - {XtNfont, XtCFont, XtRFontStruct, sizeof(struct font *), - offset(font),XtRString, DEFAULT_FACE_FONT}, - {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), - offset(foreground_pixel), XtRString, "XtDefaultForeground"}, - {XtNcursorColor, XtCForeground, XtRPixel, sizeof(Pixel), - offset(cursor_color), XtRString, "XtDefaultForeground"}, + {XtNfont, XtCFont, XtRFontStruct, sizeof (struct font *), + offset (font),XtRString, DEFAULT_FACE_FONT}, + {XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel), + offset (foreground_pixel), XtRString, "XtDefaultForeground"}, + {XtNcursorColor, XtCForeground, XtRPixel, sizeof (Pixel), + offset (cursor_color), XtRString, "XtDefaultForeground"}, {XtNbarCursor, XtCBarCursor, XtRBoolean, sizeof (Boolean), offset (bar_cursor), XtRImmediate, (XtPointer)0}, {XtNvisualBell, XtCVisualBell, XtRBoolean, sizeof (Boolean), @@ -141,7 +138,7 @@ static EmacsFrameClassRec emacsFrameClassRec = { { /* core fields */ /* superclass */ &widgetClassRec, /* class_name */ "EmacsFrame", - /* widget_size */ sizeof(EmacsFrameRec), + /* widget_size */ sizeof (EmacsFrameRec), /* class_initialize */ 0, /* class_part_initialize */ 0, /* class_inited */ FALSE, @@ -151,7 +148,7 @@ static EmacsFrameClassRec emacsFrameClassRec = { /* actions */ 0, /*emacsFrameActionsTable*/ /* num_actions */ 0, /*XtNumber (emacsFrameActionsTable)*/ /* resources */ resources, - /* resource_count */ XtNumber(resources), + /* resource_count */ XtNumber (resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, @@ -224,10 +221,9 @@ get_wm_shell (Widget w) #if 0 /* Currently not used. */ static void -mark_shell_size_user_specified (wmshell) - Widget wmshell; +mark_shell_size_user_specified (Widget wmshell) { - if (! XtIsWMShell (wmshell)) abort (); + if (! XtIsWMShell (wmshell)) emacs_abort (); /* This is kind of sleazy, but I can't see how else to tell it to make it mark the WM_SIZE_HINTS size as user specified when appropriate. */ ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize; @@ -291,7 +287,7 @@ set_frame_size (EmacsFrame ew) Widget wmshell = get_wm_shell ((Widget) ew); /* Each Emacs shell is now independent and top-level. */ - if (! XtIsSubclass (wmshell, shellWidgetClass)) abort (); + if (! XtIsSubclass (wmshell, shellWidgetClass)) emacs_abort (); /* We don't need this for the moment. The geometry is computed in xfns.c. */ @@ -430,25 +426,15 @@ set_frame_size (EmacsFrame ew) { /* the tricky things with the sign is to make sure that -0 is printed -0. */ - int len; - char *tem; sprintf (shell_position, "=%c%d%c%d", flags & XNegative ? '-' : '+', x < 0 ? -x : x, flags & YNegative ? '-' : '+', y < 0 ? -y : y); - len = strlen (shell_position) + 1; - tem = (char *) xmalloc (len); - strncpy (tem, shell_position, len); - XtVaSetValues (wmshell, XtNgeometry, tem, NULL); + XtVaSetValues (wmshell, XtNgeometry, xstrdup (shell_position), NULL); } else if (flags & (WidthValue | HeightValue)) { - int len; - char *tem; sprintf (shell_position, "=%dx%d", pixel_width, pixel_height); - len = strlen (shell_position) + 1; - tem = (char *) xmalloc (len); - strncpy (tem, shell_position, len); - XtVaSetValues (wmshell, XtNgeometry, tem, NULL); + XtVaSetValues (wmshell, XtNgeometry, xstrdup (shell_position), NULL); } /* If the geometry spec we're using has W/H components, mark the size @@ -477,6 +463,9 @@ update_wm_hints (EmacsFrame ew) int base_height; int min_rows = 0, min_cols = 0; + /* This happens when the frame is just created. */ + if (! wmshell) return; + #if 0 check_frame_size (ew->emacs_frame.frame, &min_rows, &min_cols); #endif @@ -507,11 +496,18 @@ update_wm_hints (EmacsFrame ew) NULL); } +void +widget_update_wm_size_hints (Widget widget) +{ + EmacsFrame ew = (EmacsFrame)widget; + update_wm_hints (ew); +} + + #if 0 static void -create_frame_gcs (ew) - EmacsFrame ew; +create_frame_gcs (EmacsFrame ew) { struct frame *s = ew->emacs_frame.frame; @@ -576,7 +572,7 @@ setup_frame_gcs (EmacsFrame ew) never actually get used as a background tile! */ blank_tile - = XCreatePixmapFromBitmapData (XtDisplay(ew), + = XCreatePixmapFromBitmapData (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), setup_frame_cursor_bits, 2, 2, 0, 1, ew->core.depth); @@ -654,6 +650,16 @@ EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2) set_frame_size (ew); } +static void +resize_cb (Widget widget, + XtPointer closure, + XEvent* event, + Boolean* continue_to_dispatch) +{ + EmacsFrame ew = (EmacsFrame) widget; + EmacsFrameResize (widget); +} + static void EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs) @@ -669,27 +675,28 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs *mask |= CWEventMask; XtCreateWindow (widget, InputOutput, (Visual *)CopyFromParent, *mask, attrs); + /* Some ConfigureNotify events does not end up in EmacsFrameResize so + make sure we get them all. Seen with xfcwm4 for example. */ + XtAddRawEventHandler (widget, StructureNotifyMask, False, resize_cb, NULL); update_wm_hints (ew); } -extern void free_frame_faces (struct frame *); - static void EmacsFrameDestroy (Widget widget) { EmacsFrame ew = (EmacsFrame) widget; struct frame* s = ew->emacs_frame.frame; - if (! s) abort (); - if (! s->output_data.x) abort (); + if (! s) emacs_abort (); + if (! s->output_data.x) emacs_abort (); - BLOCK_INPUT; + block_input (); x_free_gcs (s); if (s->output_data.x->white_relief.gc) XFreeGC (XtDisplay (widget), s->output_data.x->white_relief.gc); if (s->output_data.x->black_relief.gc) XFreeGC (XtDisplay (widget), s->output_data.x->black_relief.gc); - UNBLOCK_INPUT; + unblock_input (); } static void @@ -697,15 +704,22 @@ EmacsFrameResize (Widget widget) { EmacsFrame ew = (EmacsFrame)widget; struct frame *f = ew->emacs_frame.frame; + struct x_output *x = f->output_data.x; int columns; int rows; pixel_to_char_size (ew, ew->core.width, ew->core.height, &columns, &rows); - change_frame_size (f, rows, columns, 0, 1, 0); - update_wm_hints (ew); - update_various_frame_slots (ew); + if (columns != FRAME_COLS (f) + || rows != FRAME_LINES (f) + || ew->core.width != FRAME_PIXEL_WIDTH (f) + || ew->core.height + x->menubar_height != FRAME_PIXEL_HEIGHT (f)) + { + change_frame_size (f, rows, columns, 0, 1, 0); + update_wm_hints (ew); + update_various_frame_slots (ew); - cancel_mouse_face (f); + cancel_mouse_face (f); + } } static Boolean @@ -810,7 +824,7 @@ EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeome return result->request_mode ? XtGeometryAlmost : XtGeometryYes; } -/* Special entrypoints */ +/* Special entry points */ void EmacsFrameSetCharSize (Widget widget, int columns, int rows) {