aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2025-12-23 10:39:45 +0800
committerPo Lu2025-12-23 10:39:45 +0800
commitb0140bcd44326632538dc377dd336b82a1df4dd9 (patch)
treedab1a81e3369797347d317b9fd11b033fe5e3aba /src
parent22070c6f2f2cf31861642295ec215a177741c361 (diff)
downloademacs-b0140bcd44326632538dc377dd336b82a1df4dd9.tar.gz
emacs-b0140bcd44326632538dc377dd336b82a1df4dd9.zip
Implement set_window_size_and_position_hook on Android
* java/org/gnu/emacs/EmacsWindow.java (moveResizeWindow): New method, which alters all of the bounding box of a window at once. * src/android.c (android_init_emacs_window): Load method `move_resize_window'. (android_move_resize_window): Invoke this method, rather than a sequence of operations that will produce two ConfigureNotify events. * src/androidterm.c (android_set_window_size_and_position_1) (android_set_window_size_and_position): New functions; ported from X. (android_create_terminal): Register the same.
Diffstat (limited to 'src')
-rw-r--r--src/android.c20
-rw-r--r--src/androidterm.c44
-rw-r--r--src/androidterm.h1
3 files changed, 62 insertions, 3 deletions
diff --git a/src/android.c b/src/android.c
index 5f2f2e35239..b87430bdd74 100644
--- a/src/android.c
+++ b/src/android.c
@@ -102,6 +102,7 @@ struct android_emacs_window
102 jmethodID unmap_window; 102 jmethodID unmap_window;
103 jmethodID resize_window; 103 jmethodID resize_window;
104 jmethodID move_window; 104 jmethodID move_window;
105 jmethodID move_resize_window;
105 jmethodID make_input_focus; 106 jmethodID make_input_focus;
106 jmethodID raise; 107 jmethodID raise;
107 jmethodID lower; 108 jmethodID lower;
@@ -1965,6 +1966,7 @@ android_init_emacs_window (void)
1965 FIND_METHOD (unmap_window, "unmapWindow", "()V"); 1966 FIND_METHOD (unmap_window, "unmapWindow", "()V");
1966 FIND_METHOD (resize_window, "resizeWindow", "(II)V"); 1967 FIND_METHOD (resize_window, "resizeWindow", "(II)V");
1967 FIND_METHOD (move_window, "moveWindow", "(II)V"); 1968 FIND_METHOD (move_window, "moveWindow", "(II)V");
1969 FIND_METHOD (move_resize_window, "moveResizeWindow", "(IIII)V");
1968 FIND_METHOD (make_input_focus, "makeInputFocus", "(J)V"); 1970 FIND_METHOD (make_input_focus, "makeInputFocus", "(J)V");
1969 FIND_METHOD (raise, "raise", "()V"); 1971 FIND_METHOD (raise, "raise", "()V");
1970 FIND_METHOD (lower, "lower", "()V"); 1972 FIND_METHOD (lower, "lower", "()V");
@@ -5331,11 +5333,23 @@ android_get_geometry (android_window handle,
5331} 5333}
5332 5334
5333void 5335void
5334android_move_resize_window (android_window window, int x, int y, 5336android_move_resize_window (android_window handle, int x, int y,
5335 unsigned int width, unsigned int height) 5337 unsigned int width, unsigned int height)
5336{ 5338{
5337 android_move_window (window, x, y); 5339 jobject window;
5338 android_resize_window (window, width, height); 5340 jmethodID move_resize_window;
5341
5342 window = android_resolve_handle (handle);
5343 move_resize_window = window_class.move_resize_window;
5344
5345 (*android_java_env)->CallNonvirtualVoidMethod (android_java_env,
5346 window,
5347 window_class.class,
5348 move_resize_window,
5349 (jint) x, (jint) y,
5350 (jint) width,
5351 (jint) height);
5352 android_exception_check ();
5339} 5353}
5340 5354
5341void 5355void
diff --git a/src/androidterm.c b/src/androidterm.c
index d9830e5cd08..7342b8d2dae 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -2334,6 +2334,48 @@ android_set_window_size (struct frame *f, bool change_gravity,
2334 do_pending_window_change (false); 2334 do_pending_window_change (false);
2335} 2335}
2336 2336
2337static void
2338android_set_window_size_and_position_1 (struct frame *f, int width, int height)
2339{
2340 int x = f->left_pos;
2341 int y = f->top_pos;
2342
2343 android_move_resize_window (FRAME_ANDROID_WINDOW (f), x, y, width, height);
2344
2345 SET_FRAME_GARBAGED (f);
2346
2347 if (FRAME_VISIBLE_P (f))
2348 android_wait_for_event (f, ANDROID_CONFIGURE_NOTIFY);
2349 else
2350 /* Call adjust_frame_size right. It might be tempting to clear out
2351 f->new_width and f->new_height here. */
2352 adjust_frame_size (f, FRAME_PIXEL_TO_TEXT_WIDTH (f, width),
2353 FRAME_PIXEL_TO_TEXT_HEIGHT (f, height),
2354 5, 0, Qx_set_window_size_1);
2355}
2356
2357void
2358android_set_window_size_and_position (struct frame *f, int width, int height)
2359{
2360 block_input ();
2361
2362 android_set_window_size_and_position_1 (f, width, height);
2363 android_clear_under_internal_border (f);
2364
2365 /* If cursor was outside the new size, mark it as off. */
2366 mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
2367
2368 /* Clear out any recollection of where the mouse highlighting was,
2369 since it might be in a place that's outside the new frame size.
2370 Actually checking whether it is outside is a pain in the neck,
2371 so don't try--just let the highlighting be done afresh with new size. */
2372 cancel_mouse_face (f);
2373
2374 unblock_input ();
2375
2376 do_pending_window_change (false);
2377}
2378
2337/* Calculate the absolute position in frame F 2379/* Calculate the absolute position in frame F
2338 from its current recorded position values and gravity. */ 2380 from its current recorded position values and gravity. */
2339 2381
@@ -6705,6 +6747,8 @@ android_create_terminal (struct android_display_info *dpyinfo)
6705 terminal->fullscreen_hook = android_fullscreen_hook; 6747 terminal->fullscreen_hook = android_fullscreen_hook;
6706 terminal->iconify_frame_hook = android_iconify_frame; 6748 terminal->iconify_frame_hook = android_iconify_frame;
6707 terminal->set_window_size_hook = android_set_window_size; 6749 terminal->set_window_size_hook = android_set_window_size;
6750 terminal->set_window_size_and_position_hook
6751 = android_set_window_size_and_position;
6708 terminal->set_frame_offset_hook = android_set_offset; 6752 terminal->set_frame_offset_hook = android_set_offset;
6709 terminal->set_frame_alpha_hook = android_set_alpha; 6753 terminal->set_frame_alpha_hook = android_set_alpha;
6710 terminal->set_new_font_hook = android_new_font; 6754 terminal->set_new_font_hook = android_new_font;
diff --git a/src/androidterm.h b/src/androidterm.h
index e9e8d594169..10806ce39bf 100644
--- a/src/androidterm.h
+++ b/src/androidterm.h
@@ -404,6 +404,7 @@ extern void android_set_preeditarea (struct window *, int, int);
404 404
405extern void android_term_init (void); 405extern void android_term_init (void);
406extern void android_set_window_size (struct frame *, bool, int, int); 406extern void android_set_window_size (struct frame *, bool, int, int);
407extern void android_set_window_size_and_position (struct frame *, int, int);
407extern void android_iconify_frame (struct frame *); 408extern void android_iconify_frame (struct frame *);
408extern void android_make_frame_visible (struct frame *); 409extern void android_make_frame_visible (struct frame *);
409extern void android_make_frame_invisible (struct frame *); 410extern void android_make_frame_invisible (struct frame *);