aboutsummaryrefslogtreecommitdiffstats
path: root/src/androidterm.c
diff options
context:
space:
mode:
authorPo Lu2025-02-17 11:32:43 +0800
committerPo Lu2025-02-17 11:34:06 +0800
commit0a6997b58d417043406dadf3d40e6f9de9ded6a8 (patch)
treeb7e41db9753ce91ac0f640215738d527044a4fa4 /src/androidterm.c
parentf2fb19d008f57d83053e7981eecded6ace9ab6c7 (diff)
downloademacs-0a6997b58d417043406dadf3d40e6f9de9ded6a8.tar.gz
emacs-0a6997b58d417043406dadf3d40e6f9de9ded6a8.zip
Synchronize frame placement logic with X
* src/androidterm.c (android_calc_absolute_position): New function. (android_set_offset): Call android_calc_absolute_position. * src/pgtkterm.c (pgtk_calc_absolute_position): Synchronize with X.
Diffstat (limited to 'src/androidterm.c')
-rw-r--r--src/androidterm.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/androidterm.c b/src/androidterm.c
index 3e367b391a8..5951135eaa6 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -2291,6 +2291,81 @@ android_set_window_size (struct frame *f, bool change_gravity,
2291 do_pending_window_change (false); 2291 do_pending_window_change (false);
2292} 2292}
2293 2293
2294/* Calculate the absolute position in frame F
2295 from its current recorded position values and gravity. */
2296
2297static void
2298android_calc_absolute_position (struct frame *f)
2299{
2300 int flags = f->size_hint_flags;
2301 struct frame *p = FRAME_PARENT_FRAME (f);
2302
2303 /* We have nothing to do if the current position
2304 is already for the top-left corner. */
2305 if (!((flags & XNegative) || (flags & YNegative)))
2306 return;
2307
2308 /* Treat negative positions as relative to the leftmost bottommost
2309 position that fits on the screen. */
2310 if (flags & XNegative)
2311 {
2312 int width = FRAME_PIXEL_WIDTH (f);
2313
2314 /* A frame that has been visible at least once should have outer
2315 edges. */
2316 if (f->output_data.android->has_been_visible && !p)
2317 {
2318 Lisp_Object frame;
2319 Lisp_Object edges = Qnil;
2320
2321 XSETFRAME (frame, f);
2322 edges = Fandroid_frame_edges (frame, Qouter_edges);
2323 if (!NILP (edges))
2324 width = (XFIXNUM (Fnth (make_fixnum (2), edges))
2325 - XFIXNUM (Fnth (make_fixnum (0), edges)));
2326 }
2327
2328 if (p)
2329 f->left_pos = (FRAME_PIXEL_WIDTH (p) - width - 2 * f->border_width
2330 + f->left_pos);
2331 else
2332 /* Not that this is of much significance, for Android programs
2333 cannot position their windows at absolute positions in the
2334 screen. */
2335 f->left_pos = (android_get_screen_width () - width + f->left_pos);
2336
2337 }
2338
2339 if (flags & YNegative)
2340 {
2341 int height = FRAME_PIXEL_HEIGHT (f);
2342
2343 if (f->output_data.android->has_been_visible && !p)
2344 {
2345 Lisp_Object frame;
2346 Lisp_Object edges = Qnil;
2347
2348 XSETFRAME (frame, f);
2349 if (NILP (edges))
2350 edges = Fandroid_frame_edges (frame, Qouter_edges);
2351 if (!NILP (edges))
2352 height = (XFIXNUM (Fnth (make_fixnum (3), edges))
2353 - XFIXNUM (Fnth (make_fixnum (1), edges)));
2354 }
2355
2356 if (p)
2357 f->top_pos = (FRAME_PIXEL_HEIGHT (p) - height - 2 * f->border_width
2358 + f->top_pos);
2359 else
2360 f->top_pos = (android_get_screen_height () - height + f->top_pos);
2361 }
2362
2363 /* The left_pos and top_pos
2364 are now relative to the top and left screen edges,
2365 so the flags should correspond. */
2366 f->size_hint_flags &= ~(XNegative | YNegative);
2367}
2368
2294static void 2369static void
2295android_set_offset (struct frame *f, int xoff, int yoff, 2370android_set_offset (struct frame *f, int xoff, int yoff,
2296 int change_gravity) 2371 int change_gravity)
@@ -2307,6 +2382,7 @@ android_set_offset (struct frame *f, int xoff, int yoff,
2307 f->win_gravity = NorthWestGravity; 2382 f->win_gravity = NorthWestGravity;
2308 } 2383 }
2309 2384
2385 android_calc_absolute_position (f);
2310 android_move_window (FRAME_ANDROID_WINDOW (f), xoff, yoff); 2386 android_move_window (FRAME_ANDROID_WINDOW (f), xoff, yoff);
2311} 2387}
2312 2388