From 009e327503a4db2ed920edec7a3ed41391c08197 Mon Sep 17 00:00:00 2001 From: "Jeffrey E. Bedard" Date: Sat, 15 Oct 2016 17:00:24 -0400 Subject: [PATCH] Fixed QT5 dialog, tearoff window, and gtk3-demo behavior. --- mwm.c | 52 +++++++++++++++++++++++++++++++++++++--------------- new.c | 30 ++++++++++++++++++++++-------- titlebar.c | 6 ++++-- 3 files changed, 63 insertions(+), 25 deletions(-) diff --git a/mwm.c b/mwm.c index 18f6966..c285c14 100644 --- a/mwm.c +++ b/mwm.c @@ -42,39 +42,61 @@ struct JBWMMwm { // paraphrased from MwmUtil.h static void process_flags(struct JBWMClient * c) { - if (c->opt.tearoff) { - c->opt.no_border = c->opt.no_resize = c->opt.no_min - = c->opt.no_max = true; + struct JBWMClientOptions * o = &c->opt; +// if (o->no_titlebar && o->no_close_decor) +// o->no_titlebar = false; + if (o->tearoff) { + o->no_border = o->no_resize = o->no_min = o->no_max + = o->no_titlebar = true; } - c->border=!c->opt.no_border; + c->border = o->no_border ? 0 : 1; +#if 0 + if (o->no_titlebar) + c->ignore_unmap ++; +#endif } static void do_functions(struct JBWMClientOptions * restrict o, const enum MwmFunctions f) { - o->no_resize=!(f & MWM_FUNC_RESIZE); - o->no_close=!(f & MWM_FUNC_CLOSE); - o->no_min=!(f & MWM_FUNC_MINIMIZE); - o->no_max=!(f & MWM_FUNC_MAXIMIZE); - o->no_move=!(f & MWM_FUNC_MOVE); - LOG("MWM_HINTS_FUNCTIONS\topts: %d, %d, %d, %d, %d", - o->no_resize, o->no_close, o->no_min, o->no_max, - o->no_move); + o->no_resize=!(f & MWM_FUNC_RESIZE); + o->no_close=!(f & MWM_FUNC_CLOSE); + o->no_min=!(f & MWM_FUNC_MINIMIZE); + o->no_max=!(f & MWM_FUNC_MAXIMIZE); + o->no_move=!(f & MWM_FUNC_MOVE); + LOG("MWM_HINTS_FUNCTIONS\topts: %d, %d, %d, %d, %d", + o->no_resize, o->no_close, o->no_min, o->no_max, + o->no_move); } static void do_decorations(struct JBWMClientOptions * restrict o, const enum MwmDecor f) { - o->no_border=!(f & MWM_DECOR_BORDER); + o->no_border=!(f & MWM_DECOR_BORDER); + if (!(f & MWM_DECOR_RESIZEH)) + o->no_resize_decor = true; + if (!(f & MWM_DECOR_MENU)) + o->no_close_decor = true; + if (!(f & MWM_DECOR_MINIMIZE)) + o->no_min_decor = true; + if (!(f & MWM_DECOR_TITLE)) + o->no_titlebar = true; +#if 0 + o->no_resize_decor = true; o->no_resize_decor=!(f & MWM_DECOR_RESIZEH); + o->no_close_decor=!(f & MWM_DECOR_MENU); + o->no_min_decor=!(f & MWM_DECOR_MINIMIZE); // This causes problems with QT5 dialogs: - // o->no_titlebar=!(f & MWM_DECOR_TITLE); + o->no_titlebar=!(f & MWM_DECOR_TITLE); o->no_close_decor=!(f & MWM_DECOR_MENU); o->no_min_decor=!(f & MWM_DECOR_MINIMIZE); - //o->no_max_decor=!(f & MWM_DECOR_MAXIMIZE); + o->no_titlebar=!(f & MWM_DECOR_TITLE); + if ((f & MWM_DECOR_MENU) && (f & MWM_DECOR_TITLE)) + o->tearoff = true; LOG("MWM_HINTS_DECORATIONS\topts: %d, %d, %d, %d", o->no_resize_decor, o->no_titlebar, o->no_close_decor, o->no_min_decor); +#endif } static Atom get_mwm_hints_atom(void) diff --git a/new.c b/new.c index 58e59e5..0ed4d95 100644 --- a/new.c +++ b/new.c @@ -11,6 +11,7 @@ #include "mwm.h" #include "screen.h" #include "shape.h" +#include "titlebar.h" #include "util.h" #include @@ -25,26 +26,37 @@ static uint8_t wm_desktop(const jbwm_window_t w, uint8_t vdesk) if (n && lprop[0] < JBWM_MAX_DESKTOPS) // is valid vdesk = lprop[0]; // Set vdesk to property value else // Set to a valid desktop number: - jbwm_set_property(w, ewmh[WM_DESKTOP], XA_CARDINAL, &vdesk, 1); + jbwm_set_property(w, ewmh[WM_DESKTOP], + XA_CARDINAL, &vdesk, 1); XFree(lprop); } LOG("wm_desktop(): vdesk is %d\n", vdesk); return vdesk; } +#else//!EWMH +#define wm_desktop(w, vdesk) vdesk #endif//EWMH +#ifdef EWMH __attribute__((nonnull)) -static void init_properties(struct JBWMClient * c) +static void set_frame_extents(struct JBWMClient * c) { - handle_mwm_hints(c); - c->vdesk = c->screen->vdesk; -#ifdef EWMH - c->vdesk = wm_desktop(c->window, c->vdesk); // Required by wm-spec 1.4: const uint8_t b = c->border; jbwm_set_property(c->window, ewmh[FRAME_EXTENTS], XA_CARDINAL, - (&(jbwm_atom_t[]){b, b, b, b}), 4); + (&(jbwm_atom_t[]){b, b, b + (c->opt.no_titlebar ? 0 : TDIM), + b}), 4); +} +#else//!EWMH +#define set_frame_extents(c) #endif//EWMH + +__attribute__((nonnull)) +static void init_properties(struct JBWMClient * c) +{ + handle_mwm_hints(c); + c->vdesk = c->screen->vdesk; + c->vdesk = wm_desktop(c->window, c->vdesk); } __attribute__((nonnull)) @@ -66,7 +78,7 @@ static void init_geometry(struct JBWMClient * c) - (c->size.height >> 1); // Test if the reparent that is to come would trigger an unmap event. - c->ignore_unmap = attr.map_state == IsViewable; + c->ignore_unmap += attr.map_state == IsViewable ? 1 : 0; } __attribute__((nonnull)) @@ -120,5 +132,7 @@ void jbwm_new_client(const jbwm_window_t w, struct JBWMScreen * s) init_properties(c); init_geometry(c); reparent(c); + set_frame_extents(c); jbwm_restore_client(c); + jbwm_update_titlebar(c); } diff --git a/titlebar.c b/titlebar.c index 08b8c5a..45225a0 100644 --- a/titlebar.c +++ b/titlebar.c @@ -142,8 +142,8 @@ static void remove_titlebar(struct JBWMClient * restrict c) void jbwm_update_titlebar(struct JBWMClient * c) { - if (c->opt.no_titlebar || c->opt.shaped) - return; + if (c->opt.shaped) + return; jbwm_window_t w = c->tb.win; if (c->opt.fullscreen && w) { remove_titlebar(c); @@ -158,5 +158,7 @@ void jbwm_update_titlebar(struct JBWMClient * c) move_buttons(c); XClearWindow(jbwm.d, w); draw_title(c); + if (c->opt.no_titlebar) + remove_titlebar(c); }