/* The emacs frame widget.
- Copyright (C) 1992, 1993, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1992-1993, 2000-2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <config.h>
#include <stdio.h>
-#include <setjmp.h>
+
#include "lisp.h"
#include "xterm.h"
#include <X11/ShellP.h>
#include "../lwlib/lwlib.h"
-#include <signal.h>
-#include "syssignal.h"
-
#include "character.h"
#include "font.h"
#define DEFAULT_FACE_FONT "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*"
-static void EmacsFrameInitialize (/*Widget, Widget, ArgList, Cardinal * */);
-static void EmacsFrameDestroy (/* Widget */);
-static void EmacsFrameRealize (/* Widget, XtValueMask*, XSetWindowAttributes* */);
-void EmacsFrameResize (/* Widget widget */);
-static Boolean EmacsFrameSetValues (/* Widget, Widget, Widget,
- ArgList, Cardinal * */);
-static XtGeometryResult EmacsFrameQueryGeometry (/* Widget, XtWidgetGeometry*,
- XtWidgetGeometry* */);
+static void EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2);
+static void EmacsFrameDestroy (Widget widget);
+static void EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs);
+static void EmacsFrameResize (Widget widget);
+static Boolean EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, ArgList dum1, Cardinal *dum2);
+static XtGeometryResult EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result);
#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),
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),
";
*/
-EmacsFrameClassRec emacsFrameClassRec = {
+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,
/* 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,
WidgetClass emacsFrameClass = (WidgetClass) &emacsFrameClassRec;
static void
-get_default_char_pixel_size (ew, pixel_width, pixel_height)
- EmacsFrame ew;
- int* pixel_width;
- int* pixel_height;
+get_default_char_pixel_size (EmacsFrame ew, int *pixel_width, int *pixel_height)
{
struct frame* f = ew->emacs_frame.frame;
*pixel_width = FRAME_COLUMN_WIDTH (f);
}
static void
-pixel_to_char_size (ew, pixel_width, pixel_height, char_width, char_height)
- EmacsFrame ew;
- Dimension pixel_width;
- Dimension pixel_height;
- int* char_width;
- int* char_height;
+pixel_to_char_size (EmacsFrame ew, Dimension pixel_width, Dimension pixel_height, int *char_width, int *char_height)
{
struct frame* f = ew->emacs_frame.frame;
*char_width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, (int) pixel_width);
}
static void
-char_to_pixel_size (ew, char_width, char_height, pixel_width, pixel_height)
- EmacsFrame ew;
- int char_width;
- int char_height;
- Dimension* pixel_width;
- Dimension* pixel_height;
+char_to_pixel_size (EmacsFrame ew, int char_width, int char_height, Dimension *pixel_width, Dimension *pixel_height)
{
struct frame* f = ew->emacs_frame.frame;
*pixel_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, char_width);
}
static void
-round_size_to_char (ew, in_width, in_height, out_width, out_height)
- EmacsFrame ew;
- Dimension in_width;
- Dimension in_height;
- Dimension* out_width;
- Dimension* out_height;
+round_size_to_char (EmacsFrame ew, Dimension in_width, Dimension in_height, Dimension *out_width, Dimension *out_height)
{
int char_width;
int char_height;
}
static Widget
-get_wm_shell (w)
- Widget w;
+get_wm_shell (Widget w)
{
Widget wmshell;
#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;
#endif
static void
-set_frame_size (ew)
- EmacsFrame ew;
+set_frame_size (EmacsFrame ew)
{
/* The widget hierarchy is
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. */
might end up with a frame width that is not a multiple of the
frame's character width which is bad for vertically split
windows. */
- f->scroll_bar_actual_width
- = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
compute_fringe_widths (f, 0);
#if 0 /* This can run Lisp code, and it is dangerous to give
out the frame to Lisp code before it officially exists.
This is handled in Fx_create_frame so not needed here. */
- change_frame_size (f, h, w, 1, 0, 0);
+ change_frame_size (f, w, h, 1, 0, 0, 0);
#endif
char_to_pixel_size (ew, w, h, &pixel_width, &pixel_height);
ew->core.width = pixel_width;
{
/* 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
}
}
-/* Nonzero tells update_wm_hints not to do anything
- (the caller should call update_wm_hints explicitly later.) */
-int update_hints_inhibit;
-
static void
-update_wm_hints (ew)
- EmacsFrame ew;
+update_wm_hints (EmacsFrame ew)
{
Widget wmshell = get_wm_shell ((Widget)ew);
int cw;
int base_height;
int min_rows = 0, min_cols = 0;
- if (update_hints_inhibit)
- return;
+ /* This happens when the frame is just created. */
+ if (! wmshell) return;
#if 0
- check_frame_size (ew->emacs_frame.frame, &min_rows, &min_cols);
+ check_frame_size (ew->emacs_frame.frame, &min_cols, &min_rows, 0);
#endif
pixel_to_char_size (ew, ew->core.width, ew->core.height,
NULL);
}
-#if 0
-
-static void
-create_frame_gcs (ew)
- EmacsFrame ew;
+void
+widget_update_wm_size_hints (Widget widget)
{
- struct frame *s = ew->emacs_frame.frame;
-
- s->output_data.x->normal_gc
- = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)),
- (unsigned long)0, (XGCValues *)0);
- s->output_data.x->reverse_gc
- = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)),
- (unsigned long)0, (XGCValues *)0);
- s->output_data.x->cursor_gc
- = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)),
- (unsigned long)0, (XGCValues *)0);
- s->output_data.x->black_relief.gc = 0;
- s->output_data.x->white_relief.gc = 0;
+ EmacsFrame ew = (EmacsFrame)widget;
+ update_wm_hints (ew);
}
-#endif /* 0 */
-
static char setup_frame_cursor_bits[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static void
-setup_frame_gcs (ew)
- EmacsFrame ew;
+setup_frame_gcs (EmacsFrame ew)
{
XGCValues gc_values;
struct frame* s = ew->emacs_frame.frame;
font = Ffont_xlfd_name (font, Qnil);
if (STRINGP (font))
{
- XFontStruct *xfont = XLoadQueryFont (FRAME_X_DISPLAY_INFO (s)->display,
- SDATA (font));
+ XFontStruct *xfont = XLoadQueryFont (FRAME_DISPLAY_INFO (s)->display,
+ SSDATA (font));
if (xfont)
{
gc_values.font = xfont->fid;
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,
- (unsigned long)0, (unsigned long)1,
- ew->core.depth);
+ 0, 1, ew->core.depth);
/* Normal video */
gc_values.foreground = ew->emacs_frame.foreground_pixel;
}
static void
-update_various_frame_slots (ew)
- EmacsFrame ew;
+update_various_frame_slots (EmacsFrame ew)
{
struct frame *f = ew->emacs_frame.frame;
struct x_output *x = f->output_data.x;
}
static void
-update_from_various_frame_slots (ew)
- EmacsFrame ew;
+update_from_various_frame_slots (EmacsFrame ew)
{
struct frame *f = ew->emacs_frame.frame;
struct x_output *x = f->output_data.x;
}
static void
-EmacsFrameInitialize (request, new, dum1, dum2)
- Widget request;
- Widget new;
- ArgList dum1;
- Cardinal *dum2;
+EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2)
{
EmacsFrame ew = (EmacsFrame)new;
set_frame_size (ew);
}
+static void
+resize_cb (Widget widget,
+ XtPointer closure,
+ XEvent* event,
+ Boolean* continue_to_dispatch)
+{
+ EmacsFrameResize (widget);
+}
+
static void
-EmacsFrameRealize (widget, mask, attrs)
- Widget widget;
- XtValueMask *mask;
- XSetWindowAttributes *attrs;
+EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs)
{
EmacsFrame ew = (EmacsFrame)widget;
*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 widget;
+EmacsFrameDestroy (Widget widget)
{
- EmacsFrame ew = (EmacsFrame) widget;
- struct frame* s = ew->emacs_frame.frame;
-
- if (! s) abort ();
- if (! s->output_data.x) abort ();
-
- 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;
+ /* All GCs are now freed in x_free_frame_resources. */
}
-void
-EmacsFrameResize (widget)
- Widget widget;
+static void
+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, columns, rows, 0, 1, 0, 0);
+ update_wm_hints (ew);
+ update_various_frame_slots (ew);
- cancel_mouse_face (f);
+ cancel_mouse_face (f);
+ }
}
static Boolean
-EmacsFrameSetValues (cur_widget, req_widget, new_widget, dum1, dum2)
- Widget cur_widget;
- Widget req_widget;
- Widget new_widget;
- ArgList dum1;
- Cardinal *dum2;
+EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, ArgList dum1, Cardinal *dum2)
{
EmacsFrame cur = (EmacsFrame)cur_widget;
EmacsFrame new = (EmacsFrame)new_widget;
new->core.width = pixel_width;
new->core.height = pixel_height;
- change_frame_size (new->emacs_frame.frame, char_height, char_width,
- 1, 0, 0);
+ change_frame_size (new->emacs_frame.frame, char_width, char_height,
+ 1, 0, 0, 0);
needs_a_refresh = True;
}
}
static XtGeometryResult
-EmacsFrameQueryGeometry (widget, request, result)
- Widget widget;
- XtWidgetGeometry* request;
- XtWidgetGeometry* result;
+EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result)
{
EmacsFrame ew = (EmacsFrame)widget;
return result->request_mode ? XtGeometryAlmost : XtGeometryYes;
}
-/* Special entrypoints */
+/* Special entry points */
void
-EmacsFrameSetCharSize (widget, columns, rows)
- Widget widget;
- int columns;
- int rows;
+EmacsFrameSetCharSize (Widget widget, int columns, int rows)
{
EmacsFrame ew = (EmacsFrame) widget;
struct frame *f = ew->emacs_frame.frame;
- x_set_window_size (f, 0, columns, rows);
+ x_set_window_size (f, 0, columns, rows, 0);
}
\f
void
-widget_store_internal_border (widget)
- Widget widget;
+widget_store_internal_border (Widget widget)
{
EmacsFrame ew = (EmacsFrame) widget;
- FRAME_PTR f = ew->emacs_frame.frame;
+ struct frame *f = ew->emacs_frame.frame;
ew->emacs_frame.internal_border_width = f->internal_border_width;
}
-
-/* arch-tag: 931d28e5-0d59-405a-8325-7d475d0a13d9
- (do not change this comment) */