aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeff Walsh2020-06-25 16:17:37 +1000
committerJeff Walsh2020-11-24 12:24:40 +1100
commit383ced7aee884c44d7422b085fe0d2a036e51724 (patch)
tree7d0e0bdac0afa24330b07004547f6ab94e395c26 /src
parent89cbe3756c373ca3d1c83055498291f724ca8aa6 (diff)
downloademacs-383ced7aee884c44d7422b085fe0d2a036e51724.tar.gz
emacs-383ced7aee884c44d7422b085fe0d2a036e51724.zip
Fix migrating Child frames
* src/pgtkterm.c: (x_calc_absolute_position): Remove Function that has no effect (x_set_offset): titlebar off should not be stored as an offset, only used to calculate final move locations
Diffstat (limited to 'src')
-rw-r--r--src/pgtkterm.c117
1 files changed, 18 insertions, 99 deletions
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index 413d421fa44..5318d66917a 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -286,80 +286,6 @@ x_destroy_window (struct frame *f)
286 dpyinfo->reference_count--; 286 dpyinfo->reference_count--;
287} 287}
288 288
289/* Calculate the absolute position in frame F
290 from its current recorded position values and gravity. */
291
292static void
293x_calc_absolute_position (struct frame *f)
294{
295 int flags = f->size_hint_flags;
296 struct frame *p = FRAME_PARENT_FRAME (f);
297
298 /* We have nothing to do if the current position
299 is already for the top-left corner. */
300 if (!((flags & XNegative) || (flags & YNegative)))
301 return;
302
303 /* Treat negative positions as relative to the leftmost bottommost
304 position that fits on the screen. */
305 if ((flags & XNegative) && (f->left_pos <= 0))
306 {
307 int width = FRAME_PIXEL_WIDTH (f);
308
309 /* A frame that has been visible at least once should have outer
310 edges. */
311 if (FRAME_X_OUTPUT (f)->has_been_visible && !p)
312 {
313 Lisp_Object frame;
314 Lisp_Object edges = Qnil;
315
316 XSETFRAME (frame, f);
317 edges = Fpgtk_frame_edges (frame, Qouter_edges);
318 if (!NILP (edges))
319 width = (XFIXNUM (Fnth (make_fixnum (2), edges))
320 - XFIXNUM (Fnth (make_fixnum (0), edges)));
321 }
322
323 if (p)
324 f->left_pos = (FRAME_PIXEL_WIDTH (p) - width - 2 * f->border_width
325 + f->left_pos);
326 else
327 f->left_pos = (x_display_pixel_width (FRAME_DISPLAY_INFO (f))
328 - width + f->left_pos);
329
330 }
331
332 if ((flags & YNegative) && (f->top_pos <= 0))
333 {
334 int height = FRAME_PIXEL_HEIGHT (f);
335
336 if (FRAME_X_OUTPUT (f)->has_been_visible && !p)
337 {
338 Lisp_Object frame;
339 Lisp_Object edges = Qnil;
340
341 XSETFRAME (frame, f);
342 if (NILP (edges))
343 edges = Fpgtk_frame_edges (frame, Qouter_edges);
344 if (!NILP (edges))
345 height = (XFIXNUM (Fnth (make_fixnum (3), edges))
346 - XFIXNUM (Fnth (make_fixnum (1), edges)));
347 }
348
349 if (p)
350 f->top_pos = (FRAME_PIXEL_HEIGHT (p) - height - 2 * f->border_width
351 + f->top_pos);
352 else
353 f->top_pos = (x_display_pixel_height (FRAME_DISPLAY_INFO (f))
354 - height + f->top_pos);
355 }
356
357 /* The left_pos and top_pos
358 are now relative to the top and left screen edges,
359 so the flags should correspond. */
360 f->size_hint_flags &= ~(XNegative | YNegative);
361}
362
363/* CHANGE_GRAVITY is 1 when calling from Fset_frame_position, 289/* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
364 to really change the position, and 0 when calling from 290 to really change the position, and 0 when calling from
365 x_make_frame_visible (in that case, XOFF and YOFF are the current 291 x_make_frame_visible (in that case, XOFF and YOFF are the current
@@ -376,53 +302,46 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_gravity)
376 302
377 struct frame *parent = FRAME_PARENT_FRAME (f); 303 struct frame *parent = FRAME_PARENT_FRAME (f);
378 GtkAllocation a = { 0 }; 304 GtkAllocation a = { 0 };
379 if (change_gravity > 0) 305 int surface_pos_x = 0;
306 int surface_pos_y = 0;
307
308 if (parent)
380 { 309 {
381 if (parent) 310 /* determing the "height" of the titlebar, by finding the
382 { 311 location of the "emacsfixed" widget on the surface/window */
383 /* determing the "height" of the titlebar, by finding the 312 GtkWidget *w = FRAME_GTK_WIDGET (parent);
384 location of the "emacsfixed" widget on the surface/window */ 313 gtk_widget_get_allocation (w, &a);
385 GtkWidget *w = FRAME_GTK_WIDGET (parent); 314 }
386 gtk_widget_get_allocation (w, &a);
387 }
388 315
316 if (change_gravity > 0)
317 {
389 f->size_hint_flags &= ~(XNegative | YNegative); 318 f->size_hint_flags &= ~(XNegative | YNegative);
390 /* if the value is negative, don't include the titlebar offset */ 319 f->left_pos = xoff;
320 f->top_pos = yoff;
321
391 if (xoff < 0) 322 if (xoff < 0)
392 { 323 {
393 f->size_hint_flags |= XNegative; 324 f->size_hint_flags |= XNegative;
394 f->left_pos = xoff;
395 }
396 else
397 {
398 f->left_pos = xoff + a.x; //~25
399 } 325 }
400
401 if (yoff < 0) 326 if (yoff < 0)
402 { 327 {
403 f->size_hint_flags |= YNegative; 328 f->size_hint_flags |= YNegative;
404 f->top_pos = yoff;
405 }
406 else
407 {
408 f->top_pos = yoff + a.y; //~60
409 } 329 }
410 f->win_gravity = NorthWestGravity; 330 f->win_gravity = NorthWestGravity;
411 } 331 }
412 332
413 x_calc_absolute_position (f);
414
415 block_input (); 333 block_input ();
416 x_wm_set_size_hint (f, 0, false); 334 surface_pos_y = f->top_pos + a.y;
335 surface_pos_x = f->left_pos + a.x;
417 336
418 /* When a position change was requested and the outer GTK widget 337 /* When a position change was requested and the outer GTK widget
419 has been realized already, leave it to gtk_window_move to DTRT 338 has been realized already, leave it to gtk_window_move to DTRT
420 and return. Used for Bug#25851 and Bug#25943. */ 339 and return. Used for Bug#25851 and Bug#25943. */
421 if (change_gravity != 0 && FRAME_GTK_OUTER_WIDGET (f)) 340 if (change_gravity != 0 && FRAME_GTK_OUTER_WIDGET (f))
422 { 341 {
423 PGTK_TRACE ("x_set_offset: move to %d,%d.", f->left_pos, f->top_pos); 342 PGTK_TRACE ("x_set_offset: move to %d,%d.", surface_pos_x, surface_pos_y);
424 gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 343 gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
425 f->left_pos, f->top_pos); 344 surface_pos_x, surface_pos_y);
426 } 345 }
427 346
428 unblock_input (); 347 unblock_input ();