diff options
| author | Eli Zaretskii | 2002-01-13 12:17:33 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2002-01-13 12:17:33 +0000 |
| commit | 49d41073f9b2e20e03fbfbabfe410ea9a9c1a4a2 (patch) | |
| tree | aca644c9ef78efe9647a35fe4a970fb15a6c220f /src | |
| parent | 53823ab9c1100230c774fb178a3a61a42b5a64ad (diff) | |
| download | emacs-49d41073f9b2e20e03fbfbabfe410ea9a9c1a4a2.tar.gz emacs-49d41073f9b2e20e03fbfbabfe410ea9a9c1a4a2.zip | |
(Qfullscreen, Qfullwidth, Qfullheight, Qfullboth): New variables.
(syms_of_xfns): Intern and staticpro them.
(x_frame_parms) <"fullscreen">: New parameter.
(x_fullscreen_move, x_set_fullscreen): New functions.
(x_set_frame_parameters): Support for Qfullscreen.
(x_real_positions): More accurate computation of the frame position.
(x_figure_window_size): Support full-screen frames.
(Fx_create_frame): Default the fullscreen parameter.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 219 |
1 files changed, 176 insertions, 43 deletions
diff --git a/src/xfns.c b/src/xfns.c index c8bce15fbd6..8fc083510f8 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -219,6 +219,10 @@ Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background; | |||
| 219 | Lisp_Object Qscreen_gamma, Qline_spacing, Qcenter; | 219 | Lisp_Object Qscreen_gamma, Qline_spacing, Qcenter; |
| 220 | Lisp_Object Qcompound_text, Qcancel_timer; | 220 | Lisp_Object Qcompound_text, Qcancel_timer; |
| 221 | Lisp_Object Qwait_for_wm; | 221 | Lisp_Object Qwait_for_wm; |
| 222 | Lisp_Object Qfullscreen; | ||
| 223 | Lisp_Object Qfullwidth; | ||
| 224 | Lisp_Object Qfullheight; | ||
| 225 | Lisp_Object Qfullboth; | ||
| 222 | 226 | ||
| 223 | /* The below are defined in frame.c. */ | 227 | /* The below are defined in frame.c. */ |
| 224 | 228 | ||
| @@ -733,6 +737,7 @@ static void x_disable_image P_ ((struct frame *, struct image *)); | |||
| 733 | void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 737 | void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 734 | static void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 738 | static void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 735 | static void x_set_wait_for_wm P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 739 | static void x_set_wait_for_wm P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 740 | static void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object)); | ||
| 736 | void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 741 | void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 737 | void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 742 | void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 738 | void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 743 | void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| @@ -805,7 +810,9 @@ static struct x_frame_parm_table x_frame_parms[] = | |||
| 805 | {"line-spacing", x_set_line_spacing}, | 810 | {"line-spacing", x_set_line_spacing}, |
| 806 | {"left-fringe", x_set_fringe_width}, | 811 | {"left-fringe", x_set_fringe_width}, |
| 807 | {"right-fringe", x_set_fringe_width}, | 812 | {"right-fringe", x_set_fringe_width}, |
| 808 | {"wait-for-wm", x_set_wait_for_wm} | 813 | {"wait-for-wm", x_set_wait_for_wm}, |
| 814 | {"fullscreen", x_set_fullscreen}, | ||
| 815 | |||
| 809 | }; | 816 | }; |
| 810 | 817 | ||
| 811 | /* Attach the `x-frame-parameter' properties to | 818 | /* Attach the `x-frame-parameter' properties to |
| @@ -821,6 +828,28 @@ init_x_parm_symbols () | |||
| 821 | make_number (i)); | 828 | make_number (i)); |
| 822 | } | 829 | } |
| 823 | 830 | ||
| 831 | |||
| 832 | /* Really try to move where we want to be in case of fullscreen. Some WMs | ||
| 833 | moves the window where we tell them. Some (mwm, twm) moves the outer | ||
| 834 | window manager window there instead. | ||
| 835 | Try to compensate for those WM here. */ | ||
| 836 | static void | ||
| 837 | x_fullscreen_move (f, new_top, new_left) | ||
| 838 | struct frame *f; | ||
| 839 | int new_top; | ||
| 840 | int new_left; | ||
| 841 | { | ||
| 842 | if (new_top != f->output_data.x->top_pos | ||
| 843 | || new_left != f->output_data.x->left_pos) | ||
| 844 | { | ||
| 845 | int move_x = new_left + f->output_data.x->x_pixels_outer_diff; | ||
| 846 | int move_y = new_top + f->output_data.x->y_pixels_outer_diff; | ||
| 847 | |||
| 848 | f->output_data.x->want_fullscreen |= FULLSCREEN_MOVE_WAIT; | ||
| 849 | x_set_offset (f, move_x, move_y, 1); | ||
| 850 | } | ||
| 851 | } | ||
| 852 | |||
| 824 | /* Change the parameters of frame F as specified by ALIST. | 853 | /* Change the parameters of frame F as specified by ALIST. |
| 825 | If a parameter is not specially recognized, do nothing special; | 854 | If a parameter is not specially recognized, do nothing special; |
| 826 | otherwise call the `x_set_...' function for that parameter. | 855 | otherwise call the `x_set_...' function for that parameter. |
| @@ -900,6 +929,7 @@ x_set_frame_parameters (f, alist) | |||
| 900 | They are independent of other properties, but other properties (e.g., | 929 | They are independent of other properties, but other properties (e.g., |
| 901 | cursor_color) are dependent upon them. */ | 930 | cursor_color) are dependent upon them. */ |
| 902 | /* Process default font as well, since fringe widths depends on it. */ | 931 | /* Process default font as well, since fringe widths depends on it. */ |
| 932 | /* Also, process fullscreen, width and height depend upon that */ | ||
| 903 | for (p = 0; p < i; p++) | 933 | for (p = 0; p < i; p++) |
| 904 | { | 934 | { |
| 905 | Lisp_Object prop, val; | 935 | Lisp_Object prop, val; |
| @@ -908,7 +938,8 @@ x_set_frame_parameters (f, alist) | |||
| 908 | val = values[p]; | 938 | val = values[p]; |
| 909 | if (EQ (prop, Qforeground_color) | 939 | if (EQ (prop, Qforeground_color) |
| 910 | || EQ (prop, Qbackground_color) | 940 | || EQ (prop, Qbackground_color) |
| 911 | || EQ (prop, Qfont)) | 941 | || EQ (prop, Qfont) |
| 942 | || EQ (prop, Qfullscreen)) | ||
| 912 | { | 943 | { |
| 913 | register Lisp_Object param_index, old_value; | 944 | register Lisp_Object param_index, old_value; |
| 914 | 945 | ||
| @@ -949,7 +980,8 @@ x_set_frame_parameters (f, alist) | |||
| 949 | icon_left = val; | 980 | icon_left = val; |
| 950 | else if (EQ (prop, Qforeground_color) | 981 | else if (EQ (prop, Qforeground_color) |
| 951 | || EQ (prop, Qbackground_color) | 982 | || EQ (prop, Qbackground_color) |
| 952 | || EQ (prop, Qfont)) | 983 | || EQ (prop, Qfont) |
| 984 | || EQ (prop, Qfullscreen)) | ||
| 953 | /* Processed above. */ | 985 | /* Processed above. */ |
| 954 | continue; | 986 | continue; |
| 955 | else | 987 | else |
| @@ -1002,6 +1034,23 @@ x_set_frame_parameters (f, alist) | |||
| 1002 | XSETINT (icon_top, 0); | 1034 | XSETINT (icon_top, 0); |
| 1003 | } | 1035 | } |
| 1004 | 1036 | ||
| 1037 | if (FRAME_VISIBLE_P (f)) | ||
| 1038 | { | ||
| 1039 | /* If the frame is visible already and the fullscreen parameter is | ||
| 1040 | being set, it is too late to set WM manager hints to specify | ||
| 1041 | size and position. | ||
| 1042 | Here we first get the width, height and position that applies to | ||
| 1043 | fullscreen. We then move the frame to the appropriate | ||
| 1044 | position. Resize of the frame is taken care of in the code after | ||
| 1045 | this if-statement. | ||
| 1046 | If fullscreen is not specified, x_fullscreen_adjust returns | ||
| 1047 | the current parameters and then x_fullscreen_move does nothing. */ | ||
| 1048 | int new_left, new_top; | ||
| 1049 | |||
| 1050 | x_fullscreen_adjust (f, &width, &height, &new_top, &new_left); | ||
| 1051 | x_fullscreen_move (f, new_top, new_left); | ||
| 1052 | } | ||
| 1053 | |||
| 1005 | /* Don't set these parameters unless they've been explicitly | 1054 | /* Don't set these parameters unless they've been explicitly |
| 1006 | specified. The window might be mapped or resized while we're in | 1055 | specified. The window might be mapped or resized while we're in |
| 1007 | this function, and we don't want to override that unless the lisp | 1056 | this function, and we don't want to override that unless the lisp |
| @@ -1104,70 +1153,109 @@ x_real_positions (f, xptr, yptr) | |||
| 1104 | FRAME_PTR f; | 1153 | FRAME_PTR f; |
| 1105 | int *xptr, *yptr; | 1154 | int *xptr, *yptr; |
| 1106 | { | 1155 | { |
| 1107 | int win_x, win_y; | 1156 | int win_x, win_y, outer_x, outer_y; |
| 1108 | Window child; | 1157 | int real_x = 0, real_y = 0; |
| 1158 | int had_errors = 0; | ||
| 1159 | Window win = f->output_data.x->parent_desc; | ||
| 1109 | 1160 | ||
| 1110 | /* This is pretty gross, but seems to be the easiest way out of | 1161 | int count; |
| 1111 | the problem that arises when restarting window-managers. */ | ||
| 1112 | 1162 | ||
| 1113 | #ifdef USE_X_TOOLKIT | 1163 | BLOCK_INPUT; |
| 1114 | Window outer = (f->output_data.x->widget | 1164 | |
| 1115 | ? XtWindow (f->output_data.x->widget) | 1165 | count = x_catch_errors (FRAME_X_DISPLAY (f)); |
| 1116 | : FRAME_X_WINDOW (f)); | ||
| 1117 | #else | ||
| 1118 | Window outer = f->output_data.x->window_desc; | ||
| 1119 | #endif | ||
| 1120 | Window tmp_root_window; | ||
| 1121 | Window *tmp_children; | ||
| 1122 | unsigned int tmp_nchildren; | ||
| 1123 | 1166 | ||
| 1124 | while (1) | 1167 | if (win == FRAME_X_DISPLAY_INFO (f)->root_window) |
| 1168 | win = FRAME_OUTER_WINDOW (f); | ||
| 1169 | |||
| 1170 | /* This loop traverses up the containment tree until we hit the root | ||
| 1171 | window. Window managers may intersect many windows between our window | ||
| 1172 | and the root window. The window we find just before the root window | ||
| 1173 | should be the outer WM window. */ | ||
| 1174 | for (;;) | ||
| 1125 | { | 1175 | { |
| 1126 | int count = x_catch_errors (FRAME_X_DISPLAY (f)); | 1176 | Window wm_window, rootw; |
| 1127 | Window outer_window; | 1177 | Window *tmp_children; |
| 1178 | unsigned int tmp_nchildren; | ||
| 1128 | 1179 | ||
| 1129 | XQueryTree (FRAME_X_DISPLAY (f), outer, &tmp_root_window, | 1180 | XQueryTree (FRAME_X_DISPLAY (f), win, &rootw, |
| 1130 | &f->output_data.x->parent_desc, | 1181 | &wm_window, &tmp_children, &tmp_nchildren); |
| 1131 | &tmp_children, &tmp_nchildren); | ||
| 1132 | XFree ((char *) tmp_children); | 1182 | XFree ((char *) tmp_children); |
| 1133 | 1183 | ||
| 1134 | win_x = win_y = 0; | 1184 | had_errors = x_had_errors_p (FRAME_X_DISPLAY (f)); |
| 1135 | 1185 | ||
| 1136 | /* Find the position of the outside upper-left corner of | 1186 | if (wm_window == rootw || had_errors) |
| 1137 | the inner window, with respect to the outer window. */ | 1187 | break; |
| 1138 | if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) | ||
| 1139 | outer_window = f->output_data.x->parent_desc; | ||
| 1140 | else | ||
| 1141 | outer_window = outer; | ||
| 1142 | 1188 | ||
| 1189 | win = wm_window; | ||
| 1190 | } | ||
| 1191 | |||
| 1192 | if (! had_errors) | ||
| 1193 | { | ||
| 1194 | int ign; | ||
| 1195 | Window child, rootw; | ||
| 1196 | |||
| 1197 | /* Get the real coordinates for the WM window upper left corner */ | ||
| 1198 | XGetGeometry (FRAME_X_DISPLAY (f), win, | ||
| 1199 | &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign); | ||
| 1200 | |||
| 1201 | /* Translate real coordinates to coordinates relative to our | ||
| 1202 | window. For our window, the upper left corner is 0, 0. | ||
| 1203 | Since the upper left corner of the WM window is outside | ||
| 1204 | our window, win_x and win_y will be negative: | ||
| 1205 | |||
| 1206 | ------------------ ---> x | ||
| 1207 | | title | | ||
| 1208 | | ----------------- v y | ||
| 1209 | | | our window | ||
| 1210 | */ | ||
| 1143 | XTranslateCoordinates (FRAME_X_DISPLAY (f), | 1211 | XTranslateCoordinates (FRAME_X_DISPLAY (f), |
| 1144 | 1212 | ||
| 1145 | /* From-window, to-window. */ | 1213 | /* From-window, to-window. */ |
| 1146 | outer_window, | ||
| 1147 | FRAME_X_DISPLAY_INFO (f)->root_window, | 1214 | FRAME_X_DISPLAY_INFO (f)->root_window, |
| 1215 | FRAME_X_WINDOW (f), | ||
| 1148 | 1216 | ||
| 1149 | /* From-position, to-position. */ | 1217 | /* From-position, to-position. */ |
| 1150 | 0, 0, &win_x, &win_y, | 1218 | real_x, real_y, &win_x, &win_y, |
| 1151 | 1219 | ||
| 1152 | /* Child of win. */ | 1220 | /* Child of win. */ |
| 1153 | &child); | 1221 | &child); |
| 1154 | 1222 | ||
| 1155 | /* It is possible for the window returned by the XQueryNotify | 1223 | if (FRAME_X_WINDOW (f) == FRAME_OUTER_WINDOW (f)) |
| 1156 | to become invalid by the time we call XTranslateCoordinates. | ||
| 1157 | That can happen when you restart some window managers. | ||
| 1158 | If so, we get an error in XTranslateCoordinates. | ||
| 1159 | Detect that and try the whole thing over. */ | ||
| 1160 | if (! x_had_errors_p (FRAME_X_DISPLAY (f))) | ||
| 1161 | { | 1224 | { |
| 1162 | x_uncatch_errors (FRAME_X_DISPLAY (f), count); | 1225 | outer_x = win_x; |
| 1163 | break; | 1226 | outer_y = win_y; |
| 1164 | } | 1227 | } |
| 1228 | else | ||
| 1229 | { | ||
| 1230 | XTranslateCoordinates (FRAME_X_DISPLAY (f), | ||
| 1165 | 1231 | ||
| 1166 | x_uncatch_errors (FRAME_X_DISPLAY (f), count); | 1232 | /* From-window, to-window. */ |
| 1233 | FRAME_X_DISPLAY_INFO (f)->root_window, | ||
| 1234 | FRAME_OUTER_WINDOW (f), | ||
| 1235 | |||
| 1236 | /* From-position, to-position. */ | ||
| 1237 | real_x, real_y, &outer_x, &outer_y, | ||
| 1238 | |||
| 1239 | /* Child of win. */ | ||
| 1240 | &child); | ||
| 1167 | } | 1241 | } |
| 1168 | 1242 | ||
| 1169 | *xptr = win_x; | 1243 | had_errors = x_had_errors_p (FRAME_X_DISPLAY (f)); |
| 1170 | *yptr = win_y; | 1244 | } |
| 1245 | |||
| 1246 | x_uncatch_errors (FRAME_X_DISPLAY (f), count); | ||
| 1247 | |||
| 1248 | UNBLOCK_INPUT; | ||
| 1249 | |||
| 1250 | if (had_errors) return; | ||
| 1251 | |||
| 1252 | f->output_data.x->x_pixels_diff = -win_x; | ||
| 1253 | f->output_data.x->y_pixels_diff = -win_y; | ||
| 1254 | f->output_data.x->x_pixels_outer_diff = -outer_x; | ||
| 1255 | f->output_data.x->y_pixels_outer_diff = -outer_y; | ||
| 1256 | |||
| 1257 | *xptr = real_x; | ||
| 1258 | *yptr = real_y; | ||
| 1171 | } | 1259 | } |
| 1172 | 1260 | ||
| 1173 | /* Insert a description of internally-recorded parameters of frame X | 1261 | /* Insert a description of internally-recorded parameters of frame X |
| @@ -1351,6 +1439,25 @@ x_set_wait_for_wm (f, new_value, old_value) | |||
| 1351 | } | 1439 | } |
| 1352 | 1440 | ||
| 1353 | 1441 | ||
| 1442 | /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is | ||
| 1443 | the previous value of that parameter, NEW_VALUE is the new value. */ | ||
| 1444 | |||
| 1445 | static void | ||
| 1446 | x_set_fullscreen (f, new_value, old_value) | ||
| 1447 | struct frame *f; | ||
| 1448 | Lisp_Object new_value, old_value; | ||
| 1449 | { | ||
| 1450 | if (NILP (new_value)) | ||
| 1451 | f->output_data.x->want_fullscreen = FULLSCREEN_NONE; | ||
| 1452 | else if (EQ (new_value, Qfullboth)) | ||
| 1453 | f->output_data.x->want_fullscreen = FULLSCREEN_BOTH; | ||
| 1454 | else if (EQ (new_value, Qfullwidth)) | ||
| 1455 | f->output_data.x->want_fullscreen = FULLSCREEN_WIDTH; | ||
| 1456 | else if (EQ (new_value, Qfullheight)) | ||
| 1457 | f->output_data.x->want_fullscreen = FULLSCREEN_HEIGHT; | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | |||
| 1354 | /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is | 1461 | /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is |
| 1355 | the previous value of that parameter, NEW_VALUE is the new | 1462 | the previous value of that parameter, NEW_VALUE is the new |
| 1356 | value. */ | 1463 | value. */ |
| @@ -3217,6 +3324,22 @@ x_figure_window_size (f, parms) | |||
| 3217 | window_prompting |= PPosition; | 3324 | window_prompting |= PPosition; |
| 3218 | } | 3325 | } |
| 3219 | 3326 | ||
| 3327 | if (f->output_data.x->want_fullscreen != FULLSCREEN_NONE) | ||
| 3328 | { | ||
| 3329 | int left, top; | ||
| 3330 | int width, height; | ||
| 3331 | |||
| 3332 | /* It takes both for some WM:s to place it where we want */ | ||
| 3333 | window_prompting = USPosition | PPosition; | ||
| 3334 | x_fullscreen_adjust (f, &width, &height, &top, &left); | ||
| 3335 | f->width = width; | ||
| 3336 | f->height = height; | ||
| 3337 | f->output_data.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width); | ||
| 3338 | f->output_data.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height); | ||
| 3339 | f->output_data.x->left_pos = left; | ||
| 3340 | f->output_data.x->top_pos = top; | ||
| 3341 | } | ||
| 3342 | |||
| 3220 | return window_prompting; | 3343 | return window_prompting; |
| 3221 | } | 3344 | } |
| 3222 | 3345 | ||
| @@ -4413,6 +4536,8 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 4413 | "title", "Title", RES_TYPE_STRING); | 4536 | "title", "Title", RES_TYPE_STRING); |
| 4414 | x_default_parameter (f, parms, Qwait_for_wm, Qt, | 4537 | x_default_parameter (f, parms, Qwait_for_wm, Qt, |
| 4415 | "waitForWM", "WaitForWM", RES_TYPE_BOOLEAN); | 4538 | "waitForWM", "WaitForWM", RES_TYPE_BOOLEAN); |
| 4539 | x_default_parameter (f, parms, Qfullscreen, Qnil, | ||
| 4540 | "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); | ||
| 4416 | 4541 | ||
| 4417 | f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; | 4542 | f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; |
| 4418 | 4543 | ||
| @@ -11760,6 +11885,14 @@ syms_of_xfns () | |||
| 11760 | staticpro (&Qcancel_timer); | 11885 | staticpro (&Qcancel_timer); |
| 11761 | Qwait_for_wm = intern ("wait-for-wm"); | 11886 | Qwait_for_wm = intern ("wait-for-wm"); |
| 11762 | staticpro (&Qwait_for_wm); | 11887 | staticpro (&Qwait_for_wm); |
| 11888 | Qfullscreen = intern ("fullscreen"); | ||
| 11889 | staticpro (&Qfullscreen); | ||
| 11890 | Qfullwidth = intern ("fullwidth"); | ||
| 11891 | staticpro (&Qfullwidth); | ||
| 11892 | Qfullheight = intern ("fullheight"); | ||
| 11893 | staticpro (&Qfullheight); | ||
| 11894 | Qfullboth = intern ("fullboth"); | ||
| 11895 | staticpro (&Qfullboth); | ||
| 11763 | /* This is the end of symbol initialization. */ | 11896 | /* This is the end of symbol initialization. */ |
| 11764 | 11897 | ||
| 11765 | /* Text property `display' should be nonsticky by default. */ | 11898 | /* Text property `display' should be nonsticky by default. */ |