]> git.eshelyaron.com Git - emacs.git/commitdiff
Implement override redirect on Haiku
authorPo Lu <luangruo@yahoo.com>
Sun, 9 Jan 2022 01:28:22 +0000 (01:28 +0000)
committerPo Lu <luangruo@yahoo.com>
Sun, 9 Jan 2022 01:33:02 +0000 (01:33 +0000)
* src/haiku_support.cc (pre_override_redirect_style):
(pre_override_redirect_feel): New variables.
(BWindow_set_override_redirect):
* src/haiku_support.h (BWindow_set_override_redirect): New
functions.
* src/haikufns.c (haiku_create_frame): Set override redirect.
(haiku_set_override_redirect): New function.
(haiku_frame_parm_handlers): Add `haiku_set_override_redirect'

src/haiku_support.cc
src/haiku_support.h
src/haikufns.c

index 2e9eff4067600b62bab12a4f83ca91fdb50c05cb..47a6af92f61b8917897974e5afb47629e19760d7 100644 (file)
@@ -62,6 +62,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #include <kernel/scheduler.h>
 
 #include <private/interface/ToolTip.h>
+#include <private/interface/WindowPrivate.h>
 
 #include <cmath>
 #include <cstring>
@@ -271,6 +272,8 @@ public:
   int shown_flag = 0;
   volatile int was_shown_p = 0;
   bool menu_bar_active_p = false;
+  window_look pre_override_redirect_style;
+  window_feel pre_override_redirect_feel;
 
   EmacsWindow () : BWindow (BRect (0, 0, 0, 0), "", B_TITLED_WINDOW_LOOK,
                            B_NORMAL_WINDOW_FEEL, B_NO_SERVER_SIDE_WINDOW_MODIFIERS)
@@ -3058,3 +3061,30 @@ be_use_subpixel_antialiasing (void)
 
   return current_subpixel_antialiasing;
 }
+
+/* This isn't implemented very properly (for example: what if
+   decorations are changed while the window is under override
+   redirect?) but it works well enough for most use cases.  */
+void
+BWindow_set_override_redirect (void *window, bool override_redirect_p)
+{
+  EmacsWindow *w = (EmacsWindow *) window;
+
+  if (w->LockLooper ())
+    {
+      if (override_redirect_p)
+       {
+         w->pre_override_redirect_feel = w->Feel ();
+         w->pre_override_redirect_style = w->Look ();
+         w->SetFeel (kMenuWindowFeel);
+         w->SetLook (B_NO_BORDER_WINDOW_LOOK);
+       }
+      else
+       {
+         w->SetFeel (w->pre_override_redirect_feel);
+         w->SetLook (w->pre_override_redirect_style);
+       }
+
+      w->UnlockLooper ();
+    }
+}
index 6a99eb245dc6e3748decf2af2637a576c8f58ede..961d6d3a8922767427dc154afec64024092b18bb 100644 (file)
@@ -856,6 +856,9 @@ extern "C"
   extern bool
   be_use_subpixel_antialiasing (void);
 
+  extern void
+  BWindow_set_override_redirect (void *window, bool override_redirect_p);
+
 #ifdef __cplusplus
   extern void *
   find_appropriate_view_for_draw (void *vw);
index 4a0d2272d08d77a881c5fad7c441592a0afe8557..52bb13bc89b80446ec1af3fe79f29e24c5817f9f 100644 (file)
@@ -835,6 +835,7 @@ haiku_create_frame (Lisp_Object parms, int ttip_p)
     haiku_set_parent_frame (f, parent_frame, Qnil);
 
   gui_default_parameter (f, parms, Qundecorated, Qnil, NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qoverride_redirect, Qnil, NULL, NULL, RES_TYPE_BOOLEAN);
 
   gui_default_parameter (f, parms, Qicon_type, Qnil,
                          "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
@@ -1067,6 +1068,20 @@ haiku_set_undecorated (struct frame *f, Lisp_Object new_value,
   unblock_input ();
 }
 
+static void
+haiku_set_override_redirect (struct frame *f, Lisp_Object new_value,
+                            Lisp_Object old_value)
+{
+  if (EQ (new_value, old_value))
+    return;
+
+  block_input ();
+  BWindow_set_override_redirect (FRAME_HAIKU_WINDOW (f),
+                                !NILP (new_value));
+  FRAME_OVERRIDE_REDIRECT (f) = !NILP (new_value);
+  unblock_input ();
+}
+
 static void
 haiku_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 {
@@ -2430,7 +2445,7 @@ frame_parm_handler haiku_frame_parm_handlers[] =
     haiku_set_no_focus_on_map,
     haiku_set_no_accept_focus,
     NULL, /* set z group */
-    NULL, /* set override redir */
+    haiku_set_override_redirect,
     gui_set_no_special_glyphs
   };