Mercurial > emacs
comparison src/xfns.c @ 108398:1789ed4b257e
Merge from mainline.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Sun, 17 Jan 2010 00:12:59 +0000 |
parents | f12233437424 |
children | 68f669472e65 |
comparison
equal
deleted
inserted
replaced
108397:c5b62c5789d8 | 108398:1789ed4b257e |
---|---|
3143 x_wm_set_size_hint (f, 0, 0); | 3143 x_wm_set_size_hint (f, 0, 0); |
3144 UNBLOCK_INPUT; | 3144 UNBLOCK_INPUT; |
3145 return Qnil; | 3145 return Qnil; |
3146 } | 3146 } |
3147 | 3147 |
3148 /* Return current desktop index for the display where frame F is. | |
3149 If we can't find out the current desktop, return 0. */ | |
3150 | |
3151 static int | |
3152 x_get_current_desktop (f) | |
3153 struct frame *f; | |
3154 { | |
3155 Atom actual_type; | |
3156 unsigned long actual_size, bytes_remaining; | |
3157 int rc, actual_format; | |
3158 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | |
3159 long max_len = 10; | |
3160 Display *dpy = FRAME_X_DISPLAY (f); | |
3161 long *data = NULL; | |
3162 int current_desktop; | |
3163 | |
3164 BLOCK_INPUT; | |
3165 x_catch_errors (dpy); | |
3166 rc = XGetWindowProperty (dpy, dpyinfo->root_window, | |
3167 XInternAtom (dpy, "_NET_CURRENT_DESKTOP", False), | |
3168 0, max_len, False, XA_CARDINAL, | |
3169 &actual_type, &actual_format, &actual_size, | |
3170 &bytes_remaining, (unsigned char **)&data); | |
3171 | |
3172 if (rc != Success || actual_type != XA_CARDINAL || x_had_errors_p (dpy) | |
3173 || actual_size == 0 || actual_format != 32) | |
3174 current_desktop = 0; | |
3175 else | |
3176 current_desktop = (int)*data; | |
3177 | |
3178 if (data) XFree (data); | |
3179 x_uncatch_errors (); | |
3180 UNBLOCK_INPUT; | |
3181 return current_desktop; | |
3182 } | |
3183 | |
3184 /* Return current size for DESKTOP_INDEX on the display where frame F is. | |
3185 If we can't find out the size, return 0, otherwise 1. */ | |
3186 | |
3187 static int | |
3188 x_get_desktop_workarea (f, desktop_index, deskw, deskh) | |
3189 struct frame *f; | |
3190 int desktop_index; | |
3191 int *deskw, *deskh; | |
3192 { | |
3193 Atom actual_type; | |
3194 unsigned long actual_size, bytes_remaining; | |
3195 int rc, actual_format; | |
3196 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | |
3197 long max_len = 1000; /* This handles 250 desktops, who has that many? */ | |
3198 Display *dpy = FRAME_X_DISPLAY (f); | |
3199 long *data = NULL; | |
3200 int retval; | |
3201 | |
3202 BLOCK_INPUT; | |
3203 x_catch_errors (dpy); | |
3204 rc = XGetWindowProperty (dpy, dpyinfo->root_window, | |
3205 XInternAtom (dpy, "_NET_WORKAREA", False), | |
3206 0, max_len, False, XA_CARDINAL, | |
3207 &actual_type, &actual_format, &actual_size, | |
3208 &bytes_remaining, (unsigned char **)&data); | |
3209 | |
3210 if (rc != Success || actual_type != XA_CARDINAL || x_had_errors_p (dpy) | |
3211 || actual_size < 3 || actual_format != 32) | |
3212 retval = 0; | |
3213 else | |
3214 { | |
3215 int idx; | |
3216 | |
3217 if (actual_size == 4 /* Only one info for all desktops. */ | |
3218 || desktop_index*4 > actual_size) /* destop_index out of range. */ | |
3219 desktop_index = 0; | |
3220 | |
3221 idx = desktop_index*4; | |
3222 *deskw = data[idx+2] - data[idx]; | |
3223 *deskh = data[idx+3] - data[idx+1]; | |
3224 retval = 1; | |
3225 } | |
3226 | |
3227 if (data) XFree (data); | |
3228 x_uncatch_errors (); | |
3229 UNBLOCK_INPUT; | |
3230 return retval; | |
3231 } | |
3232 | |
3148 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, | 3233 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, |
3149 1, 1, 0, | 3234 1, 1, 0, |
3150 doc: /* Make a new X window, which is called a "frame" in Emacs terms. | 3235 doc: /* Make a new X window, which is called a "frame" in Emacs terms. |
3151 Return an Emacs frame object. | 3236 Return an Emacs frame object. |
3152 PARMS is an alist of frame parameters. | 3237 PARMS is an alist of frame parameters. |
3162 struct frame *f; | 3247 struct frame *f; |
3163 Lisp_Object frame, tem; | 3248 Lisp_Object frame, tem; |
3164 Lisp_Object name; | 3249 Lisp_Object name; |
3165 int minibuffer_only = 0; | 3250 int minibuffer_only = 0; |
3166 long window_prompting = 0; | 3251 long window_prompting = 0; |
3167 int width, height; | 3252 int width, height, deskw = -1, deskh = -1, current_desktop = -1; |
3168 int count = SPECPDL_INDEX (); | 3253 int count = SPECPDL_INDEX (); |
3169 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 3254 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
3170 Lisp_Object display; | 3255 Lisp_Object display; |
3171 struct x_display_info *dpyinfo = NULL; | 3256 struct x_display_info *dpyinfo = NULL; |
3172 Lisp_Object parent; | 3257 Lisp_Object parent; |
3438 tem = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER); | 3523 tem = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER); |
3439 if (EQ (tem, Qunbound)) | 3524 if (EQ (tem, Qunbound)) |
3440 { | 3525 { |
3441 int ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f)); | 3526 int ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f)); |
3442 int dph = DisplayHeight (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)); | 3527 int dph = DisplayHeight (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)); |
3528 /* Some desktops have fixed menus above and/or panels below. Try to | |
3529 figure out the usable size we have for emacs. */ | |
3530 current_desktop = x_get_current_desktop (f); | |
3531 x_get_desktop_workarea (f, current_desktop, &deskw, &deskh); | |
3532 if (deskh > 0 && deskh < dph) dph = deskh; | |
3533 | |
3443 if (ph > dph) | 3534 if (ph > dph) |
3444 { | 3535 { |
3445 height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, dph) - | 3536 height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, dph) - |
3446 FRAME_TOOL_BAR_LINES (f) - FRAME_MENU_BAR_LINES (f); | 3537 FRAME_TOOL_BAR_LINES (f) - FRAME_MENU_BAR_LINES (f); |
3447 if (FRAME_EXTERNAL_TOOL_BAR (f)) | 3538 if (FRAME_EXTERNAL_TOOL_BAR (f)) |
3457 tem = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER); | 3548 tem = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER); |
3458 if (EQ (tem, Qunbound)) | 3549 if (EQ (tem, Qunbound)) |
3459 { | 3550 { |
3460 int pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, FRAME_COLS (f)); | 3551 int pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, FRAME_COLS (f)); |
3461 int dpw = DisplayWidth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)); | 3552 int dpw = DisplayWidth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)); |
3553 if (deskw == -1) | |
3554 { | |
3555 current_desktop = x_get_current_desktop (f); | |
3556 x_get_desktop_workarea (f, current_desktop, &deskw, &deskh); | |
3557 } | |
3558 if (deskw > 0 && deskw < dpw) dpw = deskw; | |
3559 | |
3462 if (pw > dpw) | 3560 if (pw > dpw) |
3463 width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, dpw); | 3561 width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, dpw); |
3464 } | 3562 } |
3465 | 3563 |
3466 if (height != FRAME_LINES (f) || width != FRAME_COLS (f)) | 3564 if (height != FRAME_LINES (f) || width != FRAME_COLS (f)) |