aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2023-10-10 13:11:14 +0800
committerPo Lu2023-10-10 13:11:14 +0800
commit336c3674119f61bd78a056476769ce83b97230bb (patch)
tree0af3b8f39dabdf71849c30fe0bf67952305b9319 /src
parent238292d6571402e93d4f7886baac9853011b36f6 (diff)
downloademacs-336c3674119f61bd78a056476769ce83b97230bb.tar.gz
emacs-336c3674119f61bd78a056476769ce83b97230bb.zip
Implement frame restacking under Android
* java/org/gnu/emacs/EmacsActivity.java (invalidateFocus1): Synchronize with window.children for iteration through it. * java/org/gnu/emacs/EmacsService.java (queryTree): Synchronize with windowList for iteration through it. * java/org/gnu/emacs/EmacsView.java (moveChildToBack): Correct formatting mistake. (moveAbove, moveBelow): New functions. * java/org/gnu/emacs/EmacsWindow.java (destroyHandle, reparentTo) (raise, lower): Remedy synchronization blunders. (reconfigure): New function. * src/android.c (android_init_emacs_window): Link with `reconfigure'. (android_reconfigure_wm_window): New wrapper function. * src/androidfns.c (android_frame_restack): New function. (Fandroid_frame_restack): Properly implement this function and expunge outdated comment. * src/androidgui.h (enum android_stack_mode) (enum android_window_changes): New enumerators.
Diffstat (limited to 'src')
-rw-r--r--src/android.c33
-rw-r--r--src/androidfns.c49
-rw-r--r--src/androidgui.h21
3 files changed, 93 insertions, 10 deletions
diff --git a/src/android.c b/src/android.c
index b9236075a1e..d1182698669 100644
--- a/src/android.c
+++ b/src/android.c
@@ -104,6 +104,7 @@ struct android_emacs_window
104 jmethodID make_input_focus; 104 jmethodID make_input_focus;
105 jmethodID raise; 105 jmethodID raise;
106 jmethodID lower; 106 jmethodID lower;
107 jmethodID reconfigure;
107 jmethodID get_window_geometry; 108 jmethodID get_window_geometry;
108 jmethodID translate_coordinates; 109 jmethodID translate_coordinates;
109 jmethodID set_dont_accept_focus; 110 jmethodID set_dont_accept_focus;
@@ -1755,6 +1756,7 @@ android_init_emacs_window (void)
1755 FIND_METHOD (make_input_focus, "makeInputFocus", "(J)V"); 1756 FIND_METHOD (make_input_focus, "makeInputFocus", "(J)V");
1756 FIND_METHOD (raise, "raise", "()V"); 1757 FIND_METHOD (raise, "raise", "()V");
1757 FIND_METHOD (lower, "lower", "()V"); 1758 FIND_METHOD (lower, "lower", "()V");
1759 FIND_METHOD (reconfigure, "reconfigure", "(Lorg/gnu/emacs/EmacsWindow;I)V");
1758 FIND_METHOD (get_window_geometry, "getWindowGeometry", 1760 FIND_METHOD (get_window_geometry, "getWindowGeometry",
1759 "()[I"); 1761 "()[I");
1760 FIND_METHOD (translate_coordinates, "translateCoordinates", 1762 FIND_METHOD (translate_coordinates, "translateCoordinates",
@@ -4963,6 +4965,37 @@ android_lower_window (android_window handle)
4963 android_exception_check (); 4965 android_exception_check ();
4964} 4966}
4965 4967
4968void
4969android_reconfigure_wm_window (android_window handle,
4970 enum android_wc_value_mask value_mask,
4971 struct android_window_changes *values)
4972{
4973 jobject sibling, window;
4974
4975 window = android_resolve_handle (handle, ANDROID_HANDLE_WINDOW);
4976
4977 if (!(value_mask & ANDROID_CW_STACK_MODE))
4978 return;
4979
4980 /* If value_mask & ANDROID_CW_SIBLING, place HANDLE above or below
4981 values->sibling pursuant to values->stack_mode; else, reposition
4982 it at the top or the bottom of its parent. */
4983
4984 sibling = NULL;
4985
4986 if (value_mask & ANDROID_CW_SIBLING)
4987 sibling = android_resolve_handle (values->sibling,
4988 ANDROID_HANDLE_WINDOW);
4989
4990 (*android_java_env)->CallNonvirtualVoidMethod (android_java_env,
4991 window,
4992 window_class.class,
4993 window_class.reconfigure,
4994 sibling,
4995 (jint) values->stack_mode);
4996 android_exception_check ();
4997}
4998
4966int 4999int
4967android_query_tree (android_window handle, android_window *root_return, 5000android_query_tree (android_window handle, android_window *root_return,
4968 android_window *parent_return, 5001 android_window *parent_return,
diff --git a/src/androidfns.c b/src/androidfns.c
index 3ee9f7634aa..772a4f51e78 100644
--- a/src/androidfns.c
+++ b/src/androidfns.c
@@ -1591,7 +1591,8 @@ and width values are in pixels.
1591#endif 1591#endif
1592} 1592}
1593 1593
1594DEFUN ("android-frame-edges", Fandroid_frame_edges, Sandroid_frame_edges, 0, 2, 0, 1594DEFUN ("android-frame-edges", Fandroid_frame_edges,
1595 Sandroid_frame_edges, 0, 2, 0,
1595 doc: /* Return edge coordinates of FRAME. 1596 doc: /* Return edge coordinates of FRAME.
1596FRAME must be a live frame and defaults to the selected one. The return 1597FRAME must be a live frame and defaults to the selected one. The return
1597value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are 1598value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are
@@ -1693,6 +1694,28 @@ TERMINAL is a frame. */)
1693#endif 1694#endif
1694} 1695}
1695 1696
1697#ifndef ANDROID_STUBIFY
1698
1699static void
1700android_frame_restack (struct frame *f1, struct frame *f2,
1701 bool above_flag)
1702{
1703 android_window window1;
1704 struct android_window_changes wc;
1705 unsigned long mask;
1706
1707 window1 = FRAME_ANDROID_WINDOW (f1);
1708 wc.sibling = FRAME_ANDROID_WINDOW (f2);
1709 wc.stack_mode = above_flag ? ANDROID_ABOVE : ANDROID_BELOW;
1710 mask = ANDROID_CW_SIBLING | ANDROID_CW_STACK_MODE;
1711
1712 block_input ();
1713 android_reconfigure_wm_window (window1, mask, &wc);
1714 unblock_input ();
1715}
1716
1717#endif /* !ANDROID_STUBIFY */
1718
1696DEFUN ("android-frame-restack", Fandroid_frame_restack, 1719DEFUN ("android-frame-restack", Fandroid_frame_restack,
1697 Sandroid_frame_restack, 2, 3, 0, 1720 Sandroid_frame_restack, 2, 3, 0,
1698 doc: /* Restack FRAME1 below FRAME2. 1721 doc: /* Restack FRAME1 below FRAME2.
@@ -1709,19 +1732,25 @@ that of FRAME2. Hence the position of FRAME2 in its display's Z
1709\(stacking) order relative to all other frames excluding FRAME1 remains 1732\(stacking) order relative to all other frames excluding FRAME1 remains
1710unaltered. 1733unaltered.
1711 1734
1712The Android system refuses to restack windows, so this does not 1735Android does not facilitate restacking top-level windows managed by
1713work. */) 1736its own window manager; nor is it possible to restack frames that are
1714 (Lisp_Object frame1, Lisp_Object frame2, Lisp_Object frame3) 1737children of different parents. Consequently, this function only
1738functions when FRAME1 and FRAME2 are both child frames subordinate to
1739the same parent frame. */)
1740 (Lisp_Object frame1, Lisp_Object frame2, Lisp_Object above)
1715{ 1741{
1716#ifdef ANDROID_STUBIFY 1742#ifdef ANDROID_STUBIFY
1717 error ("Android cross-compilation stub called!"); 1743 error ("Android cross-compilation stub called!");
1718 return Qnil; 1744 return Qnil;
1719#else 1745#else /* !ANDROID_STUBIFY */
1720 /* This is not supported on Android because of limitations in the 1746 struct frame *f1 = decode_live_frame (frame1);
1721 platform that prevent ViewGroups from restacking 1747 struct frame *f2 = decode_live_frame (frame2);
1722 SurfaceViews. */ 1748
1723 return Qnil; 1749 if (!(FRAME_ANDROID_WINDOW (f1) && FRAME_ANDROID_WINDOW (f2)))
1724#endif 1750 error ("Cannot restack frames");
1751 android_frame_restack (f1, f2, !NILP (above));
1752 return Qt;
1753#endif /* ANDROID_STUBIFY */
1725} 1754}
1726 1755
1727DEFUN ("android-mouse-absolute-pixel-position", 1756DEFUN ("android-mouse-absolute-pixel-position",
diff --git a/src/androidgui.h b/src/androidgui.h
index 936706b092e..b58c39a5276 100644
--- a/src/androidgui.h
+++ b/src/androidgui.h
@@ -564,6 +564,24 @@ enum android_ic_mode
564 ANDROID_IC_MODE_TEXT = 2, 564 ANDROID_IC_MODE_TEXT = 2,
565 }; 565 };
566 566
567enum android_stack_mode
568 {
569 ANDROID_ABOVE = 0,
570 ANDROID_BELOW = 1,
571 };
572
573enum android_wc_value_mask
574 {
575 ANDROID_CW_SIBLING = 0,
576 ANDROID_CW_STACK_MODE = 1,
577 };
578
579struct android_window_changes
580{
581 android_window sibling;
582 enum android_stack_mode stack_mode;
583};
584
567extern int android_pending (void); 585extern int android_pending (void);
568extern void android_next_event (union android_event *); 586extern void android_next_event (union android_event *);
569extern bool android_check_if_event (union android_event *, 587extern bool android_check_if_event (union android_event *,
@@ -643,6 +661,9 @@ extern void android_bell (void);
643extern void android_set_input_focus (android_window, unsigned long); 661extern void android_set_input_focus (android_window, unsigned long);
644extern void android_raise_window (android_window); 662extern void android_raise_window (android_window);
645extern void android_lower_window (android_window); 663extern void android_lower_window (android_window);
664extern void android_reconfigure_wm_window (android_window,
665 enum android_wc_value_mask,
666 struct android_window_changes *);
646extern int android_query_tree (android_window, android_window *, 667extern int android_query_tree (android_window, android_window *,
647 android_window *, android_window **, 668 android_window *, android_window **,
648 unsigned int *); 669 unsigned int *);