diff options
| author | Ken Raeburn | 2015-11-07 03:06:32 -0500 |
|---|---|---|
| committer | Ken Raeburn | 2015-11-12 03:58:08 -0500 |
| commit | e1c27dbd25ab22f6000d1e46259e2a60d56416c1 (patch) | |
| tree | 8ee00c53fc71622c75eb61f617d830d32eccb51d /src | |
| parent | 25e32bd861cdf405e74f8025116625b2f6d6607b (diff) | |
| download | emacs-e1c27dbd25ab22f6000d1e46259e2a60d56416c1.tar.gz emacs-e1c27dbd25ab22f6000d1e46259e2a60d56416c1.zip | |
Reduce some data dependencies between X calls
Gains nothing in the traditional-Xlib code, but more closely aligns
with how the XCB version will work.
* src/xfns.c (x_real_pos_and_offsets): When translating coordinates,
send coordinates (0,0) to the X server and add in the real coordinates
after getting the response. Move XGetGeometry for outer window inside
error-trapping block. Use DPY variable more, since it's available.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/src/xfns.c b/src/xfns.c index db87fcc94fc..c55e6fee168 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -194,6 +194,7 @@ x_real_pos_and_offsets (struct frame *f, | |||
| 194 | unsigned char *tmp_data = NULL; | 194 | unsigned char *tmp_data = NULL; |
| 195 | Atom target_type = XA_CARDINAL; | 195 | Atom target_type = XA_CARDINAL; |
| 196 | unsigned int ow IF_LINT (= 0), oh IF_LINT (= 0); | 196 | unsigned int ow IF_LINT (= 0), oh IF_LINT (= 0); |
| 197 | unsigned int fw, fh; | ||
| 197 | 198 | ||
| 198 | block_input (); | 199 | block_input (); |
| 199 | 200 | ||
| @@ -223,10 +224,10 @@ x_real_pos_and_offsets (struct frame *f, | |||
| 223 | unsigned int tmp_nchildren; | 224 | unsigned int tmp_nchildren; |
| 224 | int success; | 225 | int success; |
| 225 | 226 | ||
| 226 | success = XQueryTree (FRAME_X_DISPLAY (f), win, &rootw, | 227 | success = XQueryTree (dpy, win, &rootw, |
| 227 | &wm_window, &tmp_children, &tmp_nchildren); | 228 | &wm_window, &tmp_children, &tmp_nchildren); |
| 228 | 229 | ||
| 229 | had_errors = x_had_errors_p (FRAME_X_DISPLAY (f)); | 230 | had_errors = x_had_errors_p (dpy); |
| 230 | 231 | ||
| 231 | /* Don't free tmp_children if XQueryTree failed. */ | 232 | /* Don't free tmp_children if XQueryTree failed. */ |
| 232 | if (! success) | 233 | if (! success) |
| @@ -246,7 +247,7 @@ x_real_pos_and_offsets (struct frame *f, | |||
| 246 | Window child, rootw; | 247 | Window child, rootw; |
| 247 | 248 | ||
| 248 | /* Get the real coordinates for the WM window upper left corner */ | 249 | /* Get the real coordinates for the WM window upper left corner */ |
| 249 | XGetGeometry (FRAME_X_DISPLAY (f), win, | 250 | XGetGeometry (dpy, win, |
| 250 | &rootw, &real_x, &real_y, &ow, &oh, &bw, &ign); | 251 | &rootw, &real_x, &real_y, &ow, &oh, &bw, &ign); |
| 251 | 252 | ||
| 252 | if (outer_border) | 253 | if (outer_border) |
| @@ -262,18 +263,21 @@ x_real_pos_and_offsets (struct frame *f, | |||
| 262 | | ----------------- v y | 263 | | ----------------- v y |
| 263 | | | our window | 264 | | | our window |
| 264 | */ | 265 | */ |
| 265 | XTranslateCoordinates (FRAME_X_DISPLAY (f), | 266 | XTranslateCoordinates (dpy, |
| 266 | 267 | ||
| 267 | /* From-window, to-window. */ | 268 | /* From-window, to-window. */ |
| 268 | FRAME_DISPLAY_INFO (f)->root_window, | 269 | FRAME_DISPLAY_INFO (f)->root_window, |
| 269 | FRAME_X_WINDOW (f), | 270 | FRAME_X_WINDOW (f), |
| 270 | 271 | ||
| 271 | /* From-position, to-position. */ | 272 | /* From-position, to-position. */ |
| 272 | real_x, real_y, &win_x, &win_y, | 273 | 0, 0, &win_x, &win_y, |
| 273 | 274 | ||
| 274 | /* Child of win. */ | 275 | /* Child of win. */ |
| 275 | &child); | 276 | &child); |
| 276 | 277 | ||
| 278 | win_x += real_x; | ||
| 279 | win_y += real_y; | ||
| 280 | |||
| 277 | if (FRAME_X_WINDOW (f) == FRAME_OUTER_WINDOW (f)) | 281 | if (FRAME_X_WINDOW (f) == FRAME_OUTER_WINDOW (f)) |
| 278 | { | 282 | { |
| 279 | outer_x = win_x; | 283 | outer_x = win_x; |
| @@ -281,20 +285,23 @@ x_real_pos_and_offsets (struct frame *f, | |||
| 281 | } | 285 | } |
| 282 | else | 286 | else |
| 283 | { | 287 | { |
| 284 | XTranslateCoordinates (FRAME_X_DISPLAY (f), | 288 | XTranslateCoordinates (dpy, |
| 285 | 289 | ||
| 286 | /* From-window, to-window. */ | 290 | /* From-window, to-window. */ |
| 287 | FRAME_DISPLAY_INFO (f)->root_window, | 291 | FRAME_DISPLAY_INFO (f)->root_window, |
| 288 | FRAME_OUTER_WINDOW (f), | 292 | FRAME_OUTER_WINDOW (f), |
| 289 | 293 | ||
| 290 | /* From-position, to-position. */ | 294 | /* From-position, to-position. */ |
| 291 | real_x, real_y, &outer_x, &outer_y, | 295 | 0, 0, &outer_x, &outer_y, |
| 292 | 296 | ||
| 293 | /* Child of win. */ | 297 | /* Child of win. */ |
| 294 | &child); | 298 | &child); |
| 299 | |||
| 300 | outer_x += real_x; | ||
| 301 | outer_y += real_y; | ||
| 295 | } | 302 | } |
| 296 | 303 | ||
| 297 | had_errors = x_had_errors_p (FRAME_X_DISPLAY (f)); | 304 | had_errors = x_had_errors_p (dpy); |
| 298 | } | 305 | } |
| 299 | 306 | ||
| 300 | if (!had_errors && dpyinfo->root_window == f->output_data.x->parent_desc) | 307 | if (!had_errors && dpyinfo->root_window == f->output_data.x->parent_desc) |
| @@ -319,6 +326,16 @@ x_real_pos_and_offsets (struct frame *f, | |||
| 319 | if (tmp_data) XFree (tmp_data); | 326 | if (tmp_data) XFree (tmp_data); |
| 320 | } | 327 | } |
| 321 | 328 | ||
| 329 | if (right_offset_x || bottom_offset_y) | ||
| 330 | { | ||
| 331 | int xy_ign; | ||
| 332 | unsigned int ign; | ||
| 333 | Window rootw; | ||
| 334 | |||
| 335 | XGetGeometry (dpy, FRAME_OUTER_WINDOW (f), | ||
| 336 | &rootw, &xy_ign, &xy_ign, &fw, &fh, &ign, &ign); | ||
| 337 | } | ||
| 338 | |||
| 322 | x_uncatch_errors (); | 339 | x_uncatch_errors (); |
| 323 | 340 | ||
| 324 | unblock_input (); | 341 | unblock_input (); |
| @@ -334,17 +351,8 @@ x_real_pos_and_offsets (struct frame *f, | |||
| 334 | if (xptr) *xptr = real_x; | 351 | if (xptr) *xptr = real_x; |
| 335 | if (yptr) *yptr = real_y; | 352 | if (yptr) *yptr = real_y; |
| 336 | 353 | ||
| 337 | if (right_offset_x || bottom_offset_y) | 354 | if (right_offset_x) *right_offset_x = ow - fw + outer_x; |
| 338 | { | 355 | if (bottom_offset_y) *bottom_offset_y = oh - fh + outer_y; |
| 339 | int xy_ign; | ||
| 340 | unsigned int ign, fw, fh; | ||
| 341 | Window rootw; | ||
| 342 | |||
| 343 | XGetGeometry (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), | ||
| 344 | &rootw, &xy_ign, &xy_ign, &fw, &fh, &ign, &ign); | ||
| 345 | if (right_offset_x) *right_offset_x = ow - fw + outer_x; | ||
| 346 | if (bottom_offset_y) *bottom_offset_y = oh - fh + outer_y; | ||
| 347 | } | ||
| 348 | } | 356 | } |
| 349 | 357 | ||
| 350 | /* Store the screen positions of frame F into XPTR and YPTR. | 358 | /* Store the screen positions of frame F into XPTR and YPTR. |