From 92e4460911d23dd6889e9c02333e93882912e82a Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 9 Jan 2022 01:28:22 +0000 Subject: [PATCH] Implement override redirect on Haiku * 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 | 30 ++++++++++++++++++++++++++++++ src/haiku_support.h | 3 +++ src/haikufns.c | 17 ++++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 2e9eff40676..47a6af92f61 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -62,6 +62,7 @@ along with GNU Emacs. If not, see . */ #include #include +#include #include #include @@ -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 (); + } +} diff --git a/src/haiku_support.h b/src/haiku_support.h index 6a99eb245dc..961d6d3a892 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -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); diff --git a/src/haikufns.c b/src/haikufns.c index 4a0d2272d08..52bb13bc89b 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -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 }; -- 2.39.2