aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-07-18 10:02:19 +0400
committerDmitry Antipov2014-07-18 10:02:19 +0400
commit0e6040770c6d7c819f985e1a665dce3e78751480 (patch)
treed52fc24eb6ed76495ea5a855bd3104d91d24ee84 /src
parent5d59504a3198da6173a8cc1d4125a76b657b4538 (diff)
downloademacs-0e6040770c6d7c819f985e1a665dce3e78751480.tar.gz
emacs-0e6040770c6d7c819f985e1a665dce3e78751480.zip
* 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/ChangeLog14
-rw-r--r--src/frame.c126
-rw-r--r--src/frame.h5
-rw-r--r--src/lisp.h1
-rw-r--r--src/w32term.c54
-rw-r--r--src/xterm.c13
-rw-r--r--src/xterm.h18
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 @@
12014-07-18 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * frame.c (frame_unspecified_color): New function
4 refactored out from ...
5 (Fframe_parameters, Fframe_parameter): ... adjusted users.
6 (x_fullscreen_adjust, set_frame_param): Move Windows-specific
7 function to ...
8 * w32term.c (x_fullscreen_adjust, set_frame_param): ... static here.
9 * frame.h (x_fullscreen_adjust) [HAVE_NTGUI]:
10 * lisp.h (set_frame_param): Remove prototype.
11 * xterm.c (x_display_pixel_width, x_display_pixel_height): Now ...
12 * xterm.h (x_display_pixel_width, x_display_pixel_height): ...
13 inlined from here.
14
12014-07-17 Dmitry Antipov <dmantipov@yandex.ru> 152014-07-17 Dmitry Antipov <dmantipov@yandex.ru>
2 16
3 * print.c (print_preprocess): Adjust to match changed 17 * 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)
2081 update_mode_lines = 16; 2081 update_mode_lines = 16;
2082} 2082}
2083 2083
2084#ifdef HAVE_NTGUI
2085void
2086set_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
2087{
2088 register Lisp_Object old_alist_elt;
2089
2090 old_alist_elt = Fassq (prop, f->param_alist);
2091 if (EQ (old_alist_elt, Qnil))
2092 fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist));
2093 else
2094 Fsetcdr (old_alist_elt, val);
2095}
2096#endif
2097
2098void 2084void
2099store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) 2085store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
2100{ 2086{
@@ -2186,6 +2172,18 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
2186 } 2172 }
2187} 2173}
2188 2174
2175/* Return color matches UNSPEC on frame F or nil if UNSPEC
2176 is not an unspecified foreground or background color. */
2177
2178static Lisp_Object
2179frame_unspecified_color (struct frame *f, Lisp_Object unspec)
2180{
2181 return (!strncmp (SSDATA (unspec), unspecified_bg, SBYTES (unspec))
2182 ? tty_color_name (f, FRAME_BACKGROUND_PIXEL (f))
2183 : (!strncmp (SSDATA (unspec), unspecified_fg, SBYTES (unspec))
2184 ? tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)) : Qnil));
2185}
2186
2189DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0, 2187DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
2190 doc: /* Return the parameters-alist of frame FRAME. 2188 doc: /* Return the parameters-alist of frame FRAME.
2191It is a list of elements of the form (PARM . VALUE), where PARM is a symbol. 2189It 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.
2206 2204
2207 if (!FRAME_WINDOW_P (f)) 2205 if (!FRAME_WINDOW_P (f))
2208 { 2206 {
2209 int fg = FRAME_FOREGROUND_PIXEL (f);
2210 int bg = FRAME_BACKGROUND_PIXEL (f);
2211 Lisp_Object elt; 2207 Lisp_Object elt;
2212 2208
2213 /* If the frame's parameter alist says the colors are 2209 /* 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.
2216 elt = Fassq (Qforeground_color, alist); 2212 elt = Fassq (Qforeground_color, alist);
2217 if (CONSP (elt) && STRINGP (XCDR (elt))) 2213 if (CONSP (elt) && STRINGP (XCDR (elt)))
2218 { 2214 {
2219 if (strncmp (SSDATA (XCDR (elt)), 2215 elt = frame_unspecified_color (f, XCDR (elt));
2220 unspecified_bg, 2216 if (!NILP (elt))
2221 SCHARS (XCDR (elt))) == 0) 2217 store_in_alist (&alist, Qforeground_color, elt);
2222 store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg));
2223 else if (strncmp (SSDATA (XCDR (elt)),
2224 unspecified_fg,
2225 SCHARS (XCDR (elt))) == 0)
2226 store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
2227 } 2218 }
2228 else 2219 else
2229 store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg)); 2220 store_in_alist (&alist, Qforeground_color,
2221 tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)));
2230 elt = Fassq (Qbackground_color, alist); 2222 elt = Fassq (Qbackground_color, alist);
2231 if (CONSP (elt) && STRINGP (XCDR (elt))) 2223 if (CONSP (elt) && STRINGP (XCDR (elt)))
2232 { 2224 {
2233 if (strncmp (SSDATA (XCDR (elt)), 2225 elt = frame_unspecified_color (f, XCDR (elt));
2234 unspecified_fg, 2226 if (!NILP (elt))
2235 SCHARS (XCDR (elt))) == 0) 2227 store_in_alist (&alist, Qbackground_color, elt);
2236 store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg));
2237 else if (strncmp (SSDATA (XCDR (elt)),
2238 unspecified_bg,
2239 SCHARS (XCDR (elt))) == 0)
2240 store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
2241 } 2228 }
2242 else 2229 else
2243 store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg)); 2230 store_in_alist (&alist, Qbackground_color,
2231 tty_color_name (f, FRAME_BACKGROUND_PIXEL (f)));
2244 store_in_alist (&alist, intern ("font"), 2232 store_in_alist (&alist, intern ("font"),
2245 build_string (FRAME_MSDOS_P (f) 2233 build_string (FRAME_MSDOS_P (f)
2246 ? "ms-dos" 2234 ? "ms-dos"
@@ -2320,29 +2308,7 @@ If FRAME is nil, describe the currently selected frame. */)
2320 important when param_alist's notion of colors is 2308 important when param_alist's notion of colors is
2321 "unspecified". We need to do the same here. */ 2309 "unspecified". We need to do the same here. */
2322 if (STRINGP (value) && !FRAME_WINDOW_P (f)) 2310 if (STRINGP (value) && !FRAME_WINDOW_P (f))
2323 { 2311 value = frame_unspecified_color (f, value);
2324 const char *color_name;
2325 ptrdiff_t csz;
2326
2327 if (EQ (parameter, Qbackground_color))
2328 {
2329 color_name = SSDATA (value);
2330 csz = SCHARS (value);
2331 if (strncmp (color_name, unspecified_bg, csz) == 0)
2332 value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
2333 else if (strncmp (color_name, unspecified_fg, csz) == 0)
2334 value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
2335 }
2336 else if (EQ (parameter, Qforeground_color))
2337 {
2338 color_name = SSDATA (value);
2339 csz = SCHARS (value);
2340 if (strncmp (color_name, unspecified_fg, csz) == 0)
2341 value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
2342 else if (strncmp (color_name, unspecified_bg, csz) == 0)
2343 value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
2344 }
2345 }
2346 } 2312 }
2347 else 2313 else
2348 value = Fcdr (Fassq (parameter, Fframe_parameters (frame))); 2314 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
@@ -2786,52 +2752,6 @@ static const struct frame_parm_table frame_parms[] =
2786 {"tool-bar-position", &Qtool_bar_position}, 2752 {"tool-bar-position", &Qtool_bar_position},
2787}; 2753};
2788 2754
2789#ifdef HAVE_NTGUI
2790
2791/* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2792 wanted positions of the WM window (not Emacs window).
2793 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2794 window (FRAME_X_WINDOW).
2795 */
2796
2797void
2798x_fullscreen_adjust (struct frame *f, int *width, int *height, int *top_pos, int *left_pos)
2799{
2800 int newwidth = FRAME_COLS (f);
2801 int newheight = FRAME_LINES (f);
2802 Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
2803
2804 *top_pos = f->top_pos;
2805 *left_pos = f->left_pos;
2806
2807 if (f->want_fullscreen & FULLSCREEN_HEIGHT)
2808 {
2809 int ph;
2810
2811 ph = x_display_pixel_height (dpyinfo);
2812 newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
2813 ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, newheight) - f->y_pixels_diff;
2814 newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
2815 *top_pos = 0;
2816 }
2817
2818 if (f->want_fullscreen & FULLSCREEN_WIDTH)
2819 {
2820 int pw;
2821
2822 pw = x_display_pixel_width (dpyinfo);
2823 newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
2824 pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, newwidth) - f->x_pixels_diff;
2825 newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
2826 *left_pos = 0;
2827 }
2828
2829 *width = newwidth;
2830 *height = newheight;
2831}
2832
2833#endif /* HAVE_NTGUI */
2834
2835#ifdef HAVE_WINDOW_SYSTEM 2755#ifdef HAVE_WINDOW_SYSTEM
2836 2756
2837/* Change the parameters of frame F as specified by ALIST. 2757/* 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);
1317 1317
1318extern Lisp_Object Qface_set_after_frame_default; 1318extern Lisp_Object Qface_set_after_frame_default;
1319 1319
1320#ifdef HAVE_NTGUI
1321extern void x_fullscreen_adjust (struct frame *f, int *, int *,
1322 int *, int *);
1323#endif
1324
1325extern void x_set_frame_parameters (struct frame *, Lisp_Object); 1320extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1326 1321
1327extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object); 1322extern 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);
4122 4122
4123/* Defined in frame.c. */ 4123/* Defined in frame.c. */
4124extern Lisp_Object Qonly, Qnone; 4124extern Lisp_Object Qonly, Qnone;
4125extern void set_frame_param (struct frame *, Lisp_Object, Lisp_Object);
4126extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); 4125extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object);
4127extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object); 4126extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object);
4128extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object); 4127extern 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)
4135 } 4135 }
4136} 4136}
4137 4137
4138 4138static void
4139set_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
4140{
4141 register Lisp_Object old_alist_elt;
4142
4143 old_alist_elt = Fassq (prop, f->param_alist);
4144 if (EQ (old_alist_elt, Qnil))
4145 fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist));
4146 else
4147 Fsetcdr (old_alist_elt, val);
4148}
4149
4139/* The main W32 event-reading loop - w32_read_socket. */ 4150/* The main W32 event-reading loop - w32_read_socket. */
4140 4151
4141/* Record the last 100 characters stored 4152/* Record the last 100 characters stored
@@ -5561,6 +5572,47 @@ x_set_offset (struct frame *f, register int xoff, register int yoff,
5561 unblock_input (); 5572 unblock_input ();
5562} 5573}
5563 5574
5575/* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
5576 wanted positions of the WM window (not Emacs window).
5577 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
5578 window (FRAME_X_WINDOW).
5579 */
5580
5581static void
5582x_fullscreen_adjust (struct frame *f, int *width, int *height, int *top_pos, int *left_pos)
5583{
5584 int newwidth = FRAME_COLS (f);
5585 int newheight = FRAME_LINES (f);
5586 Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
5587
5588 *top_pos = f->top_pos;
5589 *left_pos = f->left_pos;
5590
5591 if (f->want_fullscreen & FULLSCREEN_HEIGHT)
5592 {
5593 int ph;
5594
5595 ph = x_display_pixel_height (dpyinfo);
5596 newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
5597 ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, newheight) - f->y_pixels_diff;
5598 newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
5599 *top_pos = 0;
5600 }
5601
5602 if (f->want_fullscreen & FULLSCREEN_WIDTH)
5603 {
5604 int pw;
5605
5606 pw = x_display_pixel_width (dpyinfo);
5607 newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
5608 pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, newwidth) - f->x_pixels_diff;
5609 newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
5610 *left_pos = 0;
5611 }
5612
5613 *width = newwidth;
5614 *height = newheight;
5615}
5564 5616
5565/* Check if we need to resize the frame due to a fullscreen request. 5617/* Check if we need to resize the frame due to a fullscreen request.
5566 If so needed, resize the frame. */ 5618 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)
442 x_uncatch_errors (); 442 x_uncatch_errors ();
443} 443}
444 444
445int
446x_display_pixel_height (struct x_display_info *dpyinfo)
447{
448 return HeightOfScreen (dpyinfo->screen);
449}
450
451int
452x_display_pixel_width (struct x_display_info *dpyinfo)
453{
454 return WidthOfScreen (dpyinfo->screen);
455}
456
457
458/*********************************************************************** 445/***********************************************************************
459 Starting and ending an update 446 Starting and ending an update
460 ***********************************************************************/ 447 ***********************************************************************/
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;
77#include "dispextern.h" 77#include "dispextern.h"
78#include "termhooks.h" 78#include "termhooks.h"
79 79
80INLINE_HEADER_BEGIN
81
80/* Black and white pixel values for the screen which frame F is on. */ 82/* Black and white pixel values for the screen which frame F is on. */
81#define BLACK_PIX_DEFAULT(f) \ 83#define BLACK_PIX_DEFAULT(f) \
82 BlackPixel (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)) 84 BlackPixel (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f))
@@ -953,8 +955,18 @@ extern void x_mouse_leave (struct x_display_info *);
953extern int x_dispatch_event (XEvent *, Display *); 955extern int x_dispatch_event (XEvent *, Display *);
954#endif 956#endif
955extern int x_x_to_emacs_modifiers (struct x_display_info *, int); 957extern int x_x_to_emacs_modifiers (struct x_display_info *, int);
956extern int x_display_pixel_height (struct x_display_info *); 958
957extern int x_display_pixel_width (struct x_display_info *); 959INLINE int
960x_display_pixel_height (struct x_display_info *dpyinfo)
961{
962 return HeightOfScreen (dpyinfo->screen);
963}
964
965INLINE int
966x_display_pixel_width (struct x_display_info *dpyinfo)
967{
968 return WidthOfScreen (dpyinfo->screen);
969}
958 970
959extern void x_set_sticky (struct frame *, Lisp_Object, Lisp_Object); 971extern void x_set_sticky (struct frame *, Lisp_Object, Lisp_Object);
960extern void x_wait_for_event (struct frame *, int); 972extern void x_wait_for_event (struct frame *, int);
@@ -1062,4 +1074,6 @@ extern void x_clear_under_internal_border (struct frame *f);
1062 (nr).width = (rwidth), \ 1074 (nr).width = (rwidth), \
1063 (nr).height = (rheight)) 1075 (nr).height = (rheight))
1064 1076
1077INLINE_HEADER_END
1078
1065#endif /* XTERM_H */ 1079#endif /* XTERM_H */