1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Ask window manager to hide decoration in normal-window mode.

Issue #485
This commit is contained in:
Dave Davenport 2016-09-08 08:53:14 +02:00
parent abc190fd7c
commit e3fb17a843
7 changed files with 78 additions and 43 deletions

View file

@ -39,16 +39,16 @@ typedef struct
typedef enum
{
TB_AUTOHEIGHT = 1 << 0,
TB_AUTOWIDTH = 1 << 1,
TB_LEFT = 1 << 16,
TB_RIGHT = 1 << 17,
TB_CENTER = 1 << 18,
TB_EDITABLE = 1 << 19,
TB_MARKUP = 1 << 20,
TB_WRAP = 1 << 21,
TB_PASSWORD = 1 << 22,
TB_INDICATOR = 1 << 23,
TB_AUTOHEIGHT = 1 << 0,
TB_AUTOWIDTH = 1 << 1,
TB_LEFT = 1 << 16,
TB_RIGHT = 1 << 17,
TB_CENTER = 1 << 18,
TB_EDITABLE = 1 << 19,
TB_MARKUP = 1 << 20,
TB_WRAP = 1 << 21,
TB_PASSWORD = 1 << 22,
TB_INDICATOR = 1 << 23,
} TextboxFlags;
typedef enum

View file

@ -39,6 +39,7 @@ void window_set_atom_prop ( xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms,
X ( STRING ), \
X ( WM_WINDOW_ROLE ), \
X ( _XROOTPMAP_ID ), \
X ( _MOTIF_WM_HINTS ), \
X ( ESETROOT_PMAP_ID )
enum { EWMH_ATOMS ( ATOM_ENUM ), NUM_NETATOMS };
@ -167,6 +168,14 @@ cairo_surface_t * x11_helper_get_bg_surface ( void );
*/
void x11_build_monitor_layout ( void );
void x11_dump_monitor_layout ( void );
int x11_modifier_active ( unsigned int mask, int key );
int x11_modifier_active ( unsigned int mask, int key );
/**
* @param window The X11 window to modify
*
* Set the right hints to disable the window decoration.
* (Set MOTIF_WM_HINTS, decoration field)
*/
void x11_disable_decoration ( xcb_window_t window );
/*@}*/
#endif

View file

@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
// Reading one line per time.
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
// Evaluate one line.
unsigned int index = 0, ti = 0;
unsigned int index = 0, ti = 0;
char *token = buffer;
// Tokenize it.

View file

@ -194,7 +194,7 @@ static GRegex * create_regex ( const char *input, int case_sensitive )
{
#define R( s ) g_regex_new ( s, G_REGEX_OPTIMIZE | ( ( case_sensitive ) ? 0 : G_REGEX_CASELESS ), 0, NULL )
GRegex * retv = NULL;
gchar *r;
gchar *r;
switch ( config.matching_method )
{
case MM_GLOB:
@ -234,7 +234,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
}
char *saveptr = NULL, *token;
GRegex **retv = NULL;
GRegex **retv = NULL;
if ( !config.tokenize ) {
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
retv[0] = (GRegex *) create_regex ( input, case_sensitive );

View file

@ -73,9 +73,9 @@ struct xkb_stuff xkb = {
.keymap = NULL,
.state = NULL,
.compose = {
.table = NULL,
.state = NULL
}
.table = NULL,
.state = NULL
}
};
char *config_path = NULL;
// Array of modi.
@ -470,22 +470,22 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
break;
case XCB_XKB_STATE_NOTIFY:
{
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
guint modmask;
xkb_state_update_mask ( xkb.state,
ksne->baseMods,
ksne->latchedMods,
ksne->lockedMods,
ksne->baseGroup,
ksne->latchedGroup,
ksne->lockedGroup );
modmask = x11_get_current_mask ( &xkb );
if ( modmask == 0 ) {
abe_trigger_release ( );
}
break;
{
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
guint modmask;
xkb_state_update_mask ( xkb.state,
ksne->baseMods,
ksne->latchedMods,
ksne->lockedMods,
ksne->baseGroup,
ksne->latchedGroup,
ksne->lockedGroup );
modmask = x11_get_current_mask ( &xkb );
if ( modmask == 0 ) {
abe_trigger_release ( );
}
break;
}
}
return G_SOURCE_CONTINUE;
}

View file

@ -611,6 +611,7 @@ void __create_window ( MenuFlags menu_flags )
}
else{
window_set_atom_prop ( box, xcb->ewmh._NET_WM_WINDOW_TYPE, &( xcb->ewmh._NET_WM_WINDOW_TYPE_NORMAL ), 1 );
x11_disable_decoration ( box );
}
if ( config.fullscreen ) {
xcb_atom_t atoms[] = {
@ -1199,7 +1200,7 @@ static void rofi_view_mouse_navigation ( RofiViewState *state, xcb_button_press_
}
for ( unsigned int i = 0; i < state->max_elements; i++ ) {
if ( widget_intersect ( &( state->boxes[i]->widget ), xbe->event_x, xbe->event_y ) ) {
int control = x11_modifier_active ( xbe->state, X11MOD_CONTROL);
int control = x11_modifier_active ( xbe->state, X11MOD_CONTROL );
// Only allow items that are visible to be selected.
if ( ( state->last_offset + i ) >= state->filtered_lines ) {
break;

View file

@ -58,7 +58,7 @@
#define LOG_DOMAIN "X11Helper"
struct _xcb_stuff xcb_int = {
struct _xcb_stuff xcb_int = {
.connection = NULL,
.screen = NULL,
.screen_nbr = -1,
@ -66,14 +66,13 @@ struct _xcb_stuff xcb_int = {
.sncontext = NULL,
.monitors = NULL
};
xcb_stuff *xcb = &xcb_int;
xcb_stuff *xcb = &xcb_int;
xcb_depth_t *depth = NULL;
xcb_visualtype_t *visual = NULL;
xcb_colormap_t map = XCB_COLORMAP_NONE;
xcb_depth_t *root_depth = NULL;
xcb_visualtype_t *root_visual = NULL;
xcb_depth_t *depth = NULL;
xcb_visualtype_t *visual = NULL;
xcb_colormap_t map = XCB_COLORMAP_NONE;
xcb_depth_t *root_depth = NULL;
xcb_visualtype_t *root_visual = NULL;
xcb_atom_t netatoms[NUM_NETATOMS];
const char *netatom_names[] = { EWMH_ATOMS ( ATOM_CHAR ) };
static unsigned int x11_mod_masks[NUM_X11MOD];
@ -587,9 +586,9 @@ static void x11_figure_out_masks ( xkb_stuff *xkb )
}
}
int x11_modifier_active ( unsigned int mask, int key )
int x11_modifier_active ( unsigned int mask, int key )
{
return (x11_mod_masks[key]&mask) != 0;
return ( x11_mod_masks[key] & mask ) != 0;
}
unsigned int x11_canonalize_mask ( unsigned int mask )
@ -949,3 +948,29 @@ void xcb_stuff_wipe ( xcb_stuff *xcb )
xcb->screen_nbr = 0;
}
}
void x11_disable_decoration ( xcb_window_t window )
{
#define MWM_HINTS_FUNCTIONS ( 1 << 0 )
#define MWM_HINTS_DECORATIONS ( 1 << 1 )
struct MotifWMHints
{
uint32_t flags;
uint32_t functions;
uint32_t decorations;
int32_t inputMode;
uint32_t state;
};
struct MotifWMHints hints;
hints.flags = /*MWM_HINTS_FUNCTIONS |*/ MWM_HINTS_DECORATIONS;
hints.decorations = 0;
hints.functions = 0;
hints.inputMode = 0;
hints.state = 0;
xcb_atom_t ha = netatoms[_MOTIF_WM_HINTS];
xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, window, ha, ha, 32, 5, &hints );
#undef MWM_HINTS_DECORATIONS
#undef MWM_HINTS_FUNCTIONS
}