Skip to content

Commit

Permalink
Fixed QT5 dialog, tearoff window, and gtk3-demo behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
alisabedard committed Oct 15, 2016
1 parent b1ad1f2 commit 009e327
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 25 deletions.
52 changes: 37 additions & 15 deletions mwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 22 additions & 8 deletions new.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "mwm.h"
#include "screen.h"
#include "shape.h"
#include "titlebar.h"
#include "util.h"

#include <stdlib.h>
Expand All @@ -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))
Expand All @@ -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))
Expand Down Expand Up @@ -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);
}
6 changes: 4 additions & 2 deletions titlebar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}

0 comments on commit 009e327

Please sign in to comment.