mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Add fullscreen mode and fix some redrawing issues.
This commit is contained in:
parent
291d1ed16c
commit
0818fbd68b
6 changed files with 33 additions and 16 deletions
|
@ -143,4 +143,5 @@ Settings config = {
|
||||||
/** Hide scrollbar */
|
/** Hide scrollbar */
|
||||||
.hide_scrollbar = FALSE,
|
.hide_scrollbar = FALSE,
|
||||||
.markup_rows = FALSE,
|
.markup_rows = FALSE,
|
||||||
|
.fullscreen = FALSE,
|
||||||
};
|
};
|
||||||
|
|
|
@ -244,6 +244,8 @@ typedef struct _Settings
|
||||||
unsigned int hide_scrollbar;
|
unsigned int hide_scrollbar;
|
||||||
/** show markup in elements. */
|
/** show markup in elements. */
|
||||||
unsigned int markup_rows;
|
unsigned int markup_rows;
|
||||||
|
/** fullscreen */
|
||||||
|
unsigned int fullscreen;
|
||||||
} Settings;
|
} Settings;
|
||||||
|
|
||||||
/** Global Settings structure. */
|
/** Global Settings structure. */
|
||||||
|
|
|
@ -45,6 +45,7 @@ int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned l
|
||||||
X ( _NET_WM_WINDOW_TYPE_DOCK ), \
|
X ( _NET_WM_WINDOW_TYPE_DOCK ), \
|
||||||
X ( _NET_WM_WINDOW_TYPE_DESKTOP ), \
|
X ( _NET_WM_WINDOW_TYPE_DESKTOP ), \
|
||||||
X ( _NET_WM_WINDOW_TYPE_NORMAL ), \
|
X ( _NET_WM_WINDOW_TYPE_NORMAL ), \
|
||||||
|
X ( _NET_WM_STATE_FULLSCREEN ), \
|
||||||
X ( _NET_WM_DESKTOP ), \
|
X ( _NET_WM_DESKTOP ), \
|
||||||
X ( CLIPBOARD ), \
|
X ( CLIPBOARD ), \
|
||||||
X ( UTF8_STRING ), \
|
X ( UTF8_STRING ), \
|
||||||
|
|
|
@ -247,7 +247,7 @@ static Window create_window ( Display *display )
|
||||||
cairo_set_operator ( draw, CAIRO_OPERATOR_SOURCE );
|
cairo_set_operator ( draw, CAIRO_OPERATOR_SOURCE );
|
||||||
|
|
||||||
// // make it an unmanaged window
|
// // make it an unmanaged window
|
||||||
if ( !normal_window_mode ) {
|
if ( !normal_window_mode && !config.fullscreen ) {
|
||||||
window_set_atom_prop ( display, box, netatoms[_NET_WM_STATE], &netatoms[_NET_WM_STATE_ABOVE], 1 );
|
window_set_atom_prop ( display, box, netatoms[_NET_WM_STATE], &netatoms[_NET_WM_STATE_ABOVE], 1 );
|
||||||
XSetWindowAttributes sattr = { .override_redirect = True };
|
XSetWindowAttributes sattr = { .override_redirect = True };
|
||||||
XChangeWindowAttributes ( display, box, CWOverrideRedirect, &sattr );
|
XChangeWindowAttributes ( display, box, CWOverrideRedirect, &sattr );
|
||||||
|
@ -255,6 +255,13 @@ static Window create_window ( Display *display )
|
||||||
else{
|
else{
|
||||||
window_set_atom_prop ( display, box, netatoms[_NET_WM_WINDOW_TYPE], &netatoms[_NET_WM_WINDOW_TYPE_NORMAL], 1 );
|
window_set_atom_prop ( display, box, netatoms[_NET_WM_WINDOW_TYPE], &netatoms[_NET_WM_WINDOW_TYPE_NORMAL], 1 );
|
||||||
}
|
}
|
||||||
|
if ( config.fullscreen ) {
|
||||||
|
Atom atoms[] = {
|
||||||
|
netatoms[_NET_WM_STATE_FULLSCREEN],
|
||||||
|
netatoms[_NET_WM_STATE_ABOVE]
|
||||||
|
};
|
||||||
|
window_set_atom_prop ( display, box, netatoms[_NET_WM_STATE], atoms, sizeof ( atoms ) / sizeof ( Atom ) );
|
||||||
|
}
|
||||||
|
|
||||||
xim = XOpenIM ( display, NULL, NULL, NULL );
|
xim = XOpenIM ( display, NULL, NULL, NULL );
|
||||||
xic = XCreateIC ( xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow,
|
xic = XCreateIC ( xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow,
|
||||||
|
@ -856,18 +863,18 @@ static void menu_update ( MenuState *state )
|
||||||
const double dashes[1] = { 4 };
|
const double dashes[1] = { 4 };
|
||||||
cairo_set_dash ( d, dashes, 1, 0.0 );
|
cairo_set_dash ( d, dashes, 1, 0.0 );
|
||||||
}
|
}
|
||||||
cairo_move_to ( d, config.menu_bw, state->line_height + ( state->border ) * 1 + config.line_margin + 1 );
|
cairo_move_to ( d, state->border, state->line_height + ( state->border ) * 1 + config.line_margin + 1 );
|
||||||
cairo_line_to ( d, state->w - config.menu_bw, state->line_height + ( state->border ) * 1 + config.line_margin + 1 );
|
cairo_line_to ( d, state->w - state->border, state->line_height + ( state->border ) * 1 + config.line_margin + 1 );
|
||||||
cairo_stroke ( d );
|
cairo_stroke ( d );
|
||||||
if ( state->message_tb ) {
|
if ( state->message_tb ) {
|
||||||
cairo_move_to ( d, config.menu_bw, state->top_offset - ( config.line_margin ) - 1 );
|
cairo_move_to ( d, state->border, state->top_offset - ( config.line_margin ) - 1 );
|
||||||
cairo_line_to ( d, state->w - config.menu_bw, state->top_offset - ( config.line_margin ) - 1 );
|
cairo_line_to ( d, state->w - state->border, state->top_offset - ( config.line_margin ) - 1 );
|
||||||
cairo_stroke ( d );
|
cairo_stroke ( d );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.sidebar_mode == TRUE ) {
|
if ( config.sidebar_mode == TRUE ) {
|
||||||
cairo_move_to ( d, config.menu_bw, state->h - state->line_height - ( state->border ) * 1 - 1 - config.line_margin );
|
cairo_move_to ( d, state->border, state->h - state->line_height - ( state->border ) * 1 - 1 - config.line_margin );
|
||||||
cairo_line_to ( d, state->w - config.menu_bw, state->h - state->line_height - ( state->border ) * 1 - 1 - config.line_margin );
|
cairo_line_to ( d, state->w - state->border, state->h - state->line_height - ( state->border ) * 1 - 1 - config.line_margin );
|
||||||
cairo_stroke ( d );
|
cairo_stroke ( d );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -924,11 +931,16 @@ static void menu_resize ( MenuState *state )
|
||||||
if ( config.sidebar_mode == TRUE ) {
|
if ( config.sidebar_mode == TRUE ) {
|
||||||
int width = ( state->w - ( 2 * ( state->border ) + ( num_switchers - 1 ) * config.line_margin ) ) / num_switchers;
|
int width = ( state->w - ( 2 * ( state->border ) + ( num_switchers - 1 ) * config.line_margin ) ) / num_switchers;
|
||||||
for ( unsigned int j = 0; j < num_switchers; j++ ) {
|
for ( unsigned int j = 0; j < num_switchers; j++ ) {
|
||||||
textbox_moveresize ( switchers[j].tb, state->border + j * ( width + config.line_margin ),
|
textbox_moveresize ( switchers[j].tb,
|
||||||
state->h - state->line_height - state->border, width, state->line_height );
|
state->border + j * ( width + config.line_margin ), state->h - state->line_height - state->border,
|
||||||
|
width, state->line_height );
|
||||||
textbox_draw ( switchers[j].tb, draw );
|
textbox_draw ( switchers[j].tb, draw );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int entrybox_width = state->w - ( 2 * ( state->border ) ) - textbox_get_width ( state->prompt_tb )
|
||||||
|
- textbox_get_width ( state->case_indicator );
|
||||||
|
textbox_moveresize ( state->text, state->text->x, state->text->y, entrybox_width, state->line_height );
|
||||||
|
textbox_move ( state->case_indicator, state->w - state->border - textbox_get_width ( state->case_indicator ), state->border );
|
||||||
/**
|
/**
|
||||||
* Resize in Height
|
* Resize in Height
|
||||||
*/
|
*/
|
||||||
|
@ -936,11 +948,11 @@ static void menu_resize ( MenuState *state )
|
||||||
unsigned int last_length = state->max_elements;
|
unsigned int last_length = state->max_elements;
|
||||||
int element_height = state->line_height * config.element_height + config.line_margin;
|
int element_height = state->line_height * config.element_height + config.line_margin;
|
||||||
// Calculated new number of boxes.
|
// Calculated new number of boxes.
|
||||||
unsigned int h = ( state->h - state->top_offset );
|
unsigned int h = ( state->h - state->top_offset - config.padding );
|
||||||
if ( config.sidebar_mode == TRUE ) {
|
if ( config.sidebar_mode == TRUE ) {
|
||||||
h -= state->line_height + state->border;
|
h -= state->line_height + config.line_margin;
|
||||||
}
|
}
|
||||||
state->max_rows = ( h / element_height );
|
state->max_rows = MAX ( 1, ( h / element_height ) );
|
||||||
state->max_elements = state->max_rows * config.menu_columns;
|
state->max_elements = state->max_rows * config.menu_columns;
|
||||||
// Free boxes no longer needed.
|
// Free boxes no longer needed.
|
||||||
for ( unsigned int i = state->max_elements; i < last_length; i++ ) {
|
for ( unsigned int i = state->max_elements; i < last_length; i++ ) {
|
||||||
|
@ -1049,7 +1061,6 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *select
|
||||||
// Entry box
|
// Entry box
|
||||||
int entrybox_width = state.w - ( 2 * ( state.border ) ) - textbox_get_width ( state.prompt_tb )
|
int entrybox_width = state.w - ( 2 * ( state.border ) ) - textbox_get_width ( state.prompt_tb )
|
||||||
- textbox_get_width ( state.case_indicator );
|
- textbox_get_width ( state.case_indicator );
|
||||||
|
|
||||||
state.text = textbox_create ( TB_EDITABLE,
|
state.text = textbox_create ( TB_EDITABLE,
|
||||||
( state.border ) + textbox_get_width ( state.prompt_tb ), ( state.border ),
|
( state.border ) + textbox_get_width ( state.prompt_tb ), ( state.border ),
|
||||||
entrybox_width, state.line_height, NORMAL, *input );
|
entrybox_width, state.line_height, NORMAL, *input );
|
||||||
|
@ -1063,7 +1074,7 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *select
|
||||||
textbox_text ( state.case_indicator, "*" );
|
textbox_text ( state.case_indicator, "*" );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
textbox_text ( state.case_indicator, "" );
|
textbox_text ( state.case_indicator, " " );
|
||||||
}
|
}
|
||||||
state.message_tb = NULL;
|
state.message_tb = NULL;
|
||||||
if ( message ) {
|
if ( message ) {
|
||||||
|
@ -1277,7 +1288,7 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *select
|
||||||
textbox_text ( state.case_indicator, "*" );
|
textbox_text ( state.case_indicator, "*" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
textbox_text ( state.case_indicator, "" );
|
textbox_text ( state.case_indicator, " " );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Special delete entry command.
|
// Special delete entry command.
|
||||||
|
|
|
@ -191,6 +191,7 @@ void textbox_moveresize ( textbox *tb, int x, int y, int w, int h )
|
||||||
|
|
||||||
// We always want to update this
|
// We always want to update this
|
||||||
pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->w - 2 * SIDE_MARGIN ) );
|
pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->w - 2 * SIDE_MARGIN ) );
|
||||||
|
tb->update = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// will also unmap the window if still displayed
|
// will also unmap the window if still displayed
|
||||||
|
|
|
@ -132,7 +132,8 @@ static XrmOption xrmOptions[] = {
|
||||||
{ xrm_String, "filter", { .str = &config.filter }, NULL, "Pre-set the filter" },
|
{ xrm_String, "filter", { .str = &config.filter }, NULL, "Pre-set the filter" },
|
||||||
{ xrm_String, "separator-style", { .str = &config.separator_style }, NULL, "Separator style (none, dash, solid)" },
|
{ xrm_String, "separator-style", { .str = &config.separator_style }, NULL, "Separator style (none, dash, solid)" },
|
||||||
{ xrm_Boolean, "hide-scrollbar", { .num = &config.hide_scrollbar }, NULL, "Hide the scroll-bar" },
|
{ xrm_Boolean, "hide-scrollbar", { .num = &config.hide_scrollbar }, NULL, "Hide the scroll-bar" },
|
||||||
{ xrm_Boolean, "markup-rows", { .num = &config.markup_rows }, NULL, "Show markup" }
|
{ xrm_Boolean, "markup-rows", { .num = &config.markup_rows }, NULL, "Show markup" },
|
||||||
|
{ xrm_Boolean, "fullscreen", { .num = &config.fullscreen }, NULL, "Fullscreen" }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Dynamic options.
|
// Dynamic options.
|
||||||
|
|
Loading…
Reference in a new issue