diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2014-07-18 10:02:19 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2014-07-18 10:02:19 +0400 |
commit | 0e6040770c6d7c819f985e1a665dce3e78751480 (patch) | |
tree | d52fc24eb6ed76495ea5a855bd3104d91d24ee84 /src | |
parent | 5d59504a3198da6173a8cc1d4125a76b657b4538 (diff) | |
download | emacs-0e6040770c6d7c819f985e1a665dce3e78751480.tar.gz |
* frame.c (frame_unspecified_color): New function
refactored out from ...
(Fframe_parameters, Fframe_parameter): ... adjusted users.
(x_fullscreen_adjust, set_frame_param): Move Windows-specific
function to ...
* w32term.c (x_fullscreen_adjust, set_frame_param): ... static here.
* frame.h (x_fullscreen_adjust) [HAVE_NTGUI]:
* lisp.h (set_frame_param): Remove prototype.
* xterm.c (x_display_pixel_width, x_display_pixel_height): Now ...
* xterm.h (x_display_pixel_width, x_display_pixel_height): ...
inlined from here.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 14 | ||||
-rw-r--r-- | src/frame.c | 126 | ||||
-rw-r--r-- | src/frame.h | 5 | ||||
-rw-r--r-- | src/lisp.h | 1 | ||||
-rw-r--r-- | src/w32term.c | 54 | ||||
-rw-r--r-- | src/xterm.c | 13 | ||||
-rw-r--r-- | src/xterm.h | 18 |
7 files changed, 106 insertions, 125 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 2dde558af45..01dc819480f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2014-07-18 Dmitry Antipov <dmantipov@yandex.ru> + + * frame.c (frame_unspecified_color): New function + refactored out from ... + (Fframe_parameters, Fframe_parameter): ... adjusted users. + (x_fullscreen_adjust, set_frame_param): Move Windows-specific + function to ... + * w32term.c (x_fullscreen_adjust, set_frame_param): ... static here. + * frame.h (x_fullscreen_adjust) [HAVE_NTGUI]: + * lisp.h (set_frame_param): Remove prototype. + * xterm.c (x_display_pixel_width, x_display_pixel_height): Now ... + * xterm.h (x_display_pixel_width, x_display_pixel_height): ... + inlined from here. + 2014-07-17 Dmitry Antipov <dmantipov@yandex.ru> * print.c (print_preprocess): Adjust to match changed diff --git a/src/frame.c b/src/frame.c index 6a4aec2218d..8d6f3567334 100644 --- a/src/frame.c +++ b/src/frame.c @@ -2081,20 +2081,6 @@ set_term_frame_name (struct frame *f, Lisp_Object name) update_mode_lines = 16; } -#ifdef HAVE_NTGUI -void -set_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) -{ - register Lisp_Object old_alist_elt; - - old_alist_elt = Fassq (prop, f->param_alist); - if (EQ (old_alist_elt, Qnil)) - fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist)); - else - Fsetcdr (old_alist_elt, val); -} -#endif - void store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) { @@ -2186,6 +2172,18 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) } } +/* Return color matches UNSPEC on frame F or nil if UNSPEC + is not an unspecified foreground or background color. */ + +static Lisp_Object +frame_unspecified_color (struct frame *f, Lisp_Object unspec) +{ + return (!strncmp (SSDATA (unspec), unspecified_bg, SBYTES (unspec)) + ? tty_color_name (f, FRAME_BACKGROUND_PIXEL (f)) + : (!strncmp (SSDATA (unspec), unspecified_fg, SBYTES (unspec)) + ? tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)) : Qnil)); +} + DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0, doc: /* Return the parameters-alist of frame FRAME. It is a list of elements of the form (PARM . VALUE), where PARM is a symbol. @@ -2206,8 +2204,6 @@ If FRAME is omitted or nil, return information on the currently selected frame. if (!FRAME_WINDOW_P (f)) { - int fg = FRAME_FOREGROUND_PIXEL (f); - int bg = FRAME_BACKGROUND_PIXEL (f); Lisp_Object elt; /* If the frame's parameter alist says the colors are @@ -2216,31 +2212,23 @@ If FRAME is omitted or nil, return information on the currently selected frame. elt = Fassq (Qforeground_color, alist); if (CONSP (elt) && STRINGP (XCDR (elt))) { - if (strncmp (SSDATA (XCDR (elt)), - unspecified_bg, - SCHARS (XCDR (elt))) == 0) - store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg)); - else if (strncmp (SSDATA (XCDR (elt)), - unspecified_fg, - SCHARS (XCDR (elt))) == 0) - store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg)); + elt = frame_unspecified_color (f, XCDR (elt)); + if (!NILP (elt)) + store_in_alist (&alist, Qforeground_color, elt); } else - store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg)); + store_in_alist (&alist, Qforeground_color, + tty_color_name (f, FRAME_FOREGROUND_PIXEL (f))); elt = Fassq (Qbackground_color, alist); if (CONSP (elt) && STRINGP (XCDR (elt))) { - if (strncmp (SSDATA (XCDR (elt)), - unspecified_fg, - SCHARS (XCDR (elt))) == 0) - store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg)); - else if (strncmp (SSDATA (XCDR (elt)), - unspecified_bg, - SCHARS (XCDR (elt))) == 0) - store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg)); + elt = frame_unspecified_color (f, XCDR (elt)); + if (!NILP (elt)) + store_in_alist (&alist, Qbackground_color, elt); } else - store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg)); + store_in_alist (&alist, Qbackground_color, + tty_color_name (f, FRAME_BACKGROUND_PIXEL (f))); store_in_alist (&alist, intern ("font"), build_string (FRAME_MSDOS_P (f) ? "ms-dos" @@ -2320,29 +2308,7 @@ If FRAME is nil, describe the currently selected frame. */) important when param_alist's notion of colors is "unspecified". We need to do the same here. */ if (STRINGP (value) && !FRAME_WINDOW_P (f)) - { - const char *color_name; - ptrdiff_t csz; - - if (EQ (parameter, Qbackground_color)) - { - color_name = SSDATA (value); - csz = SCHARS (value); - if (strncmp (color_name, unspecified_bg, csz) == 0) - value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f)); - else if (strncmp (color_name, unspecified_fg, csz) == 0) - value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)); - } - else if (EQ (parameter, Qforeground_color)) - { - color_name = SSDATA (value); - csz = SCHARS (value); - if (strncmp (color_name, unspecified_fg, csz) == 0) - value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)); - else if (strncmp (color_name, unspecified_bg, csz) == 0) - value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f)); - } - } + value = frame_unspecified_color (f, value); } else value = Fcdr (Fassq (parameter, Fframe_parameters (frame))); @@ -2786,52 +2752,6 @@ static const struct frame_parm_table frame_parms[] = {"tool-bar-position", &Qtool_bar_position}, }; -#ifdef HAVE_NTGUI - -/* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the - wanted positions of the WM window (not Emacs window). - Return in *WIDTH and *HEIGHT the wanted width and height of Emacs - window (FRAME_X_WINDOW). - */ - -void -x_fullscreen_adjust (struct frame *f, int *width, int *height, int *top_pos, int *left_pos) -{ - int newwidth = FRAME_COLS (f); - int newheight = FRAME_LINES (f); - Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f); - - *top_pos = f->top_pos; - *left_pos = f->left_pos; - - if (f->want_fullscreen & FULLSCREEN_HEIGHT) - { - int ph; - - ph = x_display_pixel_height (dpyinfo); - newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph); - ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, newheight) - f->y_pixels_diff; - newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph); - *top_pos = 0; - } - - if (f->want_fullscreen & FULLSCREEN_WIDTH) - { - int pw; - - pw = x_display_pixel_width (dpyinfo); - newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw); - pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, newwidth) - f->x_pixels_diff; - newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw); - *left_pos = 0; - } - - *width = newwidth; - *height = newheight; -} - -#endif /* HAVE_NTGUI */ - #ifdef HAVE_WINDOW_SYSTEM /* Change the parameters of frame F as specified by ALIST. diff --git a/src/frame.h b/src/frame.h index 6d7ee02e44f..faeac2ad625 100644 --- a/src/frame.h +++ b/src/frame.h @@ -1317,11 +1317,6 @@ extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int); extern Lisp_Object Qface_set_after_frame_default; -#ifdef HAVE_NTGUI -extern void x_fullscreen_adjust (struct frame *f, int *, int *, - int *, int *); -#endif - extern void x_set_frame_parameters (struct frame *, Lisp_Object); extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object); diff --git a/src/lisp.h b/src/lisp.h index 5ef0fcaecfc..bf25f073d4b 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4122,7 +4122,6 @@ extern void syms_of_indent (void); /* Defined in frame.c. */ extern Lisp_Object Qonly, Qnone; -extern void set_frame_param (struct frame *, Lisp_Object, Lisp_Object); extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object); extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object); diff --git a/src/w32term.c b/src/w32term.c index 553764a8de5..479744073cd 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -4135,7 +4135,18 @@ x_scroll_bar_clear (struct frame *f) } } - +static void +set_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) +{ + register Lisp_Object old_alist_elt; + + old_alist_elt = Fassq (prop, f->param_alist); + if (EQ (old_alist_elt, Qnil)) + fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist)); + else + Fsetcdr (old_alist_elt, val); +} + /* The main W32 event-reading loop - w32_read_socket. */ /* Record the last 100 characters stored @@ -5561,6 +5572,47 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, unblock_input (); } +/* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the + wanted positions of the WM window (not Emacs window). + Return in *WIDTH and *HEIGHT the wanted width and height of Emacs + window (FRAME_X_WINDOW). + */ + +static void +x_fullscreen_adjust (struct frame *f, int *width, int *height, int *top_pos, int *left_pos) +{ + int newwidth = FRAME_COLS (f); + int newheight = FRAME_LINES (f); + Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f); + + *top_pos = f->top_pos; + *left_pos = f->left_pos; + + if (f->want_fullscreen & FULLSCREEN_HEIGHT) + { + int ph; + + ph = x_display_pixel_height (dpyinfo); + newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph); + ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, newheight) - f->y_pixels_diff; + newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph); + *top_pos = 0; + } + + if (f->want_fullscreen & FULLSCREEN_WIDTH) + { + int pw; + + pw = x_display_pixel_width (dpyinfo); + newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw); + pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, newwidth) - f->x_pixels_diff; + newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw); + *left_pos = 0; + } + + *width = newwidth; + *height = newheight; +} /* Check if we need to resize the frame due to a fullscreen request. If so needed, resize the frame. */ diff --git a/src/xterm.c b/src/xterm.c index b7a7f0b3d4c..1d2ae196355 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -442,19 +442,6 @@ x_set_frame_alpha (struct frame *f) x_uncatch_errors (); } -int -x_display_pixel_height (struct x_display_info *dpyinfo) -{ - return HeightOfScreen (dpyinfo->screen); -} - -int -x_display_pixel_width (struct x_display_info *dpyinfo) -{ - return WidthOfScreen (dpyinfo->screen); -} - - /*********************************************************************** Starting and ending an update ***********************************************************************/ diff --git a/src/xterm.h b/src/xterm.h index 6d80d1253ae..243deb5b72d 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -77,6 +77,8 @@ typedef GtkWidget *xt_or_gtk_widget; #include "dispextern.h" #include "termhooks.h" +INLINE_HEADER_BEGIN + /* Black and white pixel values for the screen which frame F is on. */ #define BLACK_PIX_DEFAULT(f) \ BlackPixel (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)) @@ -953,8 +955,18 @@ extern void x_mouse_leave (struct x_display_info *); extern int x_dispatch_event (XEvent *, Display *); #endif extern int x_x_to_emacs_modifiers (struct x_display_info *, int); -extern int x_display_pixel_height (struct x_display_info *); -extern int x_display_pixel_width (struct x_display_info *); + +INLINE int +x_display_pixel_height (struct x_display_info *dpyinfo) +{ + return HeightOfScreen (dpyinfo->screen); +} + +INLINE int +x_display_pixel_width (struct x_display_info *dpyinfo) +{ + return WidthOfScreen (dpyinfo->screen); +} extern void x_set_sticky (struct frame *, Lisp_Object, Lisp_Object); extern void x_wait_for_event (struct frame *, int); @@ -1062,4 +1074,6 @@ extern void x_clear_under_internal_border (struct frame *f); (nr).width = (rwidth), \ (nr).height = (rheight)) +INLINE_HEADER_END + #endif /* XTERM_H */ |