From 0537943561a37b54467bec19d1b8afbeba8e1e58 Mon Sep 17 00:00:00 2001 From: Jan D Date: Fri, 27 Feb 2015 18:46:26 +0100 Subject: Adjust offset and border calculations for X. * xfns.c (x_real_pos_and_offsets): Take outer_border as arg also. Initialize all args. Get outer_border from window attributes. Fix typo for top_offset_y. (x_real_positions): Adjust for new arg to x_real_pos_and_offsets. (Fx_frame_geometry): Get outer_border also. Use attrs.width/height. * xmenu.c (x_menu_show): Adjust for new arg to x_real_pos_and_offsets. * xterm.h (x_real_pos_and_offsets): Take outer_border as arg also. --- src/ChangeLog | 12 ++++++++++++ src/xfns.c | 36 +++++++++++++++++++++++++++++------- src/xmenu.c | 2 +- src/xterm.h | 3 ++- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 61bb321649..df68791491 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2015-02-27 Jan Djärv + + * xterm.h (x_real_pos_and_offsets): Take outer_border as arg also. + + * xmenu.c (x_menu_show): Adjust for new arg to x_real_pos_and_offsets. + + * xfns.c (x_real_pos_and_offsets): Take outer_border as arg also. + Initialize all args. Get outer_border from window attributes. + Fix typo for top_offset_y. + (x_real_positions): Adjust for new arg to x_real_pos_and_offsets. + (Fx_frame_geometry): Get outer_border also. Use attrs.width/height. + 2015-02-27 Mark Laws Support daemon mode on MS-Windows (bug#19688) diff --git a/src/xfns.c b/src/xfns.c index 4fc92c3fed..bd1db1013d 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -186,7 +186,8 @@ x_real_pos_and_offsets (struct frame *f, int *x_pixels_diff, int *y_pixels_diff, int *xptr, - int *yptr) + int *yptr, + int *outer_border) { int win_x, win_y, outer_x IF_LINT (= 0), outer_y IF_LINT (= 0); int real_x = 0, real_y = 0; @@ -206,6 +207,16 @@ x_real_pos_and_offsets (struct frame *f, x_catch_errors (dpy); + if (x_pixels_diff) *x_pixels_diff = 0; + if (y_pixels_diff) *y_pixels_diff = 0; + if (left_offset_x) *left_offset_x = 0; + if (top_offset_y) *top_offset_y = 0; + if (right_offset_x) *right_offset_x = 0; + if (bottom_offset_y) *bottom_offset_y = 0; + if (xptr) *xptr = 0; + if (yptr) *yptr = 0; + if (outer_border) *outer_border = 0; + if (win == dpyinfo->root_window) win = FRAME_OUTER_WINDOW (f); @@ -246,6 +257,13 @@ x_real_pos_and_offsets (struct frame *f, XGetGeometry (FRAME_X_DISPLAY (f), win, &rootw, &real_x, &real_y, &ow, &oh, &ign, &ign); + if (outer_border) + { + XWindowAttributes atts; + XGetWindowAttributes (FRAME_X_DISPLAY (f), win, &atts); + *outer_border = atts.border_width; + } + /* Translate real coordinates to coordinates relative to our window. For our window, the upper left corner is 0, 0. Since the upper left corner of the WM window is outside @@ -328,7 +346,7 @@ x_real_pos_and_offsets (struct frame *f, if (y_pixels_diff) *y_pixels_diff = -win_y; if (left_offset_x) *left_offset_x = -outer_x; - if (top_offset_y) *top_offset_y = -outer_x; + if (top_offset_y) *top_offset_y = -outer_y; if (xptr) *xptr = real_x; if (yptr) *yptr = real_y; @@ -353,7 +371,8 @@ x_real_pos_and_offsets (struct frame *f, void x_real_positions (struct frame *f, int *xptr, int *yptr) { - x_real_pos_and_offsets (f, NULL, NULL, NULL, NULL, NULL, NULL, xptr, yptr); + x_real_pos_and_offsets (f, NULL, NULL, NULL, NULL, NULL, NULL, xptr, yptr, + NULL); } @@ -4324,7 +4343,7 @@ elements (all size values are in pixels). Lisp_Object fullscreen = Fframe_parameter (frame, Qfullscreen); int menu_bar_height, menu_bar_width, tool_bar_height, tool_bar_width; - int left_off, right_off, top_off, bottom_off; + int left_off, right_off, top_off, bottom_off, outer_border; XWindowAttributes atts; block_input (); @@ -4332,15 +4351,18 @@ elements (all size values are in pixels). XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &atts); x_real_pos_and_offsets (f, &left_off, &right_off, &top_off, &bottom_off, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, &outer_border); + unblock_input (); border = atts.border_width; title = top_off; - outer_width = FRAME_PIXEL_WIDTH (f) + 2 * border + right_off + left_off; - outer_height = FRAME_PIXEL_HEIGHT (f) + 2 * border + top_off + bottom_off; + outer_width = atts.width + 2 * border + right_off + left_off + + 2 * outer_border; + outer_height = atts.height + 2 * border + top_off + bottom_off + + 2 * outer_border; #if defined (USE_GTK) { diff --git a/src/xmenu.c b/src/xmenu.c index 5794f12ccb..f183c70b11 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -2077,7 +2077,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, int left_off, top_off; x_real_pos_and_offsets (f, &left_off, NULL, &top_off, NULL, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); x += left_off; y += top_off; diff --git a/src/xterm.h b/src/xterm.h index 16868f114e..0366261b2f 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -960,7 +960,8 @@ extern void x_real_pos_and_offsets (struct frame *f, int *x_pixels_diff, int *y_pixels_diff, int *xptr, - int *yptr); + int *yptr, + int *outer_border); /* From xrdb.c. */ -- cgit v1.2.3