mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Add fake transparency
This commit is contained in:
parent
64cb4c781c
commit
a7c7cf8159
5 changed files with 93 additions and 50 deletions
|
@ -144,4 +144,5 @@ Settings config = {
|
||||||
.hide_scrollbar = FALSE,
|
.hide_scrollbar = FALSE,
|
||||||
.markup_rows = FALSE,
|
.markup_rows = FALSE,
|
||||||
.fullscreen = FALSE,
|
.fullscreen = FALSE,
|
||||||
|
.fake_transparency = FALSE,
|
||||||
};
|
};
|
||||||
|
|
|
@ -246,6 +246,8 @@ typedef struct _Settings
|
||||||
unsigned int markup_rows;
|
unsigned int markup_rows;
|
||||||
/** fullscreen */
|
/** fullscreen */
|
||||||
unsigned int fullscreen;
|
unsigned int fullscreen;
|
||||||
|
/** bg image */
|
||||||
|
unsigned int fake_transparency;
|
||||||
} Settings;
|
} Settings;
|
||||||
|
|
||||||
/** Global Settings structure. */
|
/** Global Settings structure. */
|
||||||
|
|
|
@ -224,6 +224,7 @@ typedef struct MenuState
|
||||||
int *lines_not_ascii;
|
int *lines_not_ascii;
|
||||||
int line_height;
|
int line_height;
|
||||||
unsigned int border;
|
unsigned int border;
|
||||||
|
cairo_surface_t *bg;
|
||||||
}MenuState;
|
}MenuState;
|
||||||
|
|
||||||
static Window create_window ( Display *display )
|
static Window create_window ( Display *display )
|
||||||
|
@ -285,6 +286,10 @@ static void menu_free_state ( MenuState *state )
|
||||||
textbox_free ( state->prompt_tb );
|
textbox_free ( state->prompt_tb );
|
||||||
textbox_free ( state->case_indicator );
|
textbox_free ( state->case_indicator );
|
||||||
scrollbar_free ( state->scrollbar );
|
scrollbar_free ( state->scrollbar );
|
||||||
|
if ( state->bg ) {
|
||||||
|
cairo_surface_destroy ( state->bg );
|
||||||
|
state->bg = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < state->max_elements; i++ ) {
|
for ( unsigned int i = 0; i < state->max_elements; i++ ) {
|
||||||
textbox_free ( state->boxes[i] );
|
textbox_free ( state->boxes[i] );
|
||||||
|
@ -829,9 +834,20 @@ static void menu_update ( MenuState *state )
|
||||||
cairo_surface_t *surf = cairo_image_surface_create ( get_format (), state->w, state->h );
|
cairo_surface_t *surf = cairo_image_surface_create ( get_format (), state->w, state->h );
|
||||||
cairo_t *d = cairo_create ( surf );
|
cairo_t *d = cairo_create ( surf );
|
||||||
cairo_set_operator ( d, CAIRO_OPERATOR_SOURCE );
|
cairo_set_operator ( d, CAIRO_OPERATOR_SOURCE );
|
||||||
|
if ( config.fake_transparency ) {
|
||||||
|
if ( state->bg != NULL ) {
|
||||||
|
cairo_set_source_surface ( d, state->bg, -(double) ( state->x ), -(double) ( state->y ) );
|
||||||
|
cairo_paint ( d );
|
||||||
|
cairo_set_operator ( d, CAIRO_OPERATOR_OVER );
|
||||||
|
color_background ( display, d );
|
||||||
|
cairo_paint ( d );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Paint the background.
|
// Paint the background.
|
||||||
color_background ( display, d );
|
color_background ( display, d );
|
||||||
cairo_paint ( d );
|
cairo_paint ( d );
|
||||||
|
}
|
||||||
color_border ( display, d );
|
color_border ( display, d );
|
||||||
|
|
||||||
if ( config.menu_bw > 0 ) {
|
if ( config.menu_bw > 0 ) {
|
||||||
|
@ -1042,6 +1058,24 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *select
|
||||||
sn_launchee_context_setup_window ( sncontext, main_window );
|
sn_launchee_context_setup_window ( sncontext, main_window );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Window root = DefaultRootWindow ( display );
|
||||||
|
if ( config.fake_transparency ) {
|
||||||
|
cairo_surface_t *s = cairo_xlib_surface_create ( display,
|
||||||
|
root,
|
||||||
|
DefaultVisual ( display, DefaultScreen ( display ) ),
|
||||||
|
DisplayWidth ( display, DefaultScreen ( display ) ),
|
||||||
|
DisplayHeight ( display, DefaultScreen ( display ) ) );
|
||||||
|
|
||||||
|
state.bg = cairo_image_surface_create ( get_format (),
|
||||||
|
DisplayWidth ( display, DefaultScreen ( display ) ),
|
||||||
|
DisplayHeight ( display, DefaultScreen ( display ) ) );
|
||||||
|
cairo_t *dr = cairo_create ( state.bg );
|
||||||
|
cairo_set_source_surface ( dr, s, 0, 0 );
|
||||||
|
cairo_paint ( dr );
|
||||||
|
cairo_destroy ( dr );
|
||||||
|
cairo_surface_destroy ( s );
|
||||||
|
}
|
||||||
|
|
||||||
// Get active monitor size.
|
// Get active monitor size.
|
||||||
monitor_active ( display, &mon );
|
monitor_active ( display, &mon );
|
||||||
|
|
||||||
|
@ -1215,6 +1249,11 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *select
|
||||||
else if ( ev.type == ConfigureNotify ) {
|
else if ( ev.type == ConfigureNotify ) {
|
||||||
XConfigureEvent xce = ev.xconfigure;
|
XConfigureEvent xce = ev.xconfigure;
|
||||||
if ( xce.window == main_window ) {
|
if ( xce.window == main_window ) {
|
||||||
|
if ( state.x != (int ) xce.x || state.y != (int) xce.y ) {
|
||||||
|
state.x = xce.x;
|
||||||
|
state.y = xce.y;
|
||||||
|
state.update = TRUE;
|
||||||
|
}
|
||||||
if ( state.w != (unsigned int) xce.width || state.h != (unsigned int ) xce.height ) {
|
if ( state.w != (unsigned int) xce.width || state.h != (unsigned int ) xce.height ) {
|
||||||
state.w = xce.width;
|
state.w = xce.width;
|
||||||
state.h = xce.height;
|
state.h = xce.height;
|
||||||
|
|
|
@ -133,7 +133,8 @@ static XrmOption xrmOptions[] = {
|
||||||
{ 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" }
|
{ xrm_Boolean, "fullscreen", { .num = &config.fullscreen }, NULL, "Fullscreen" },
|
||||||
|
{ xrm_Boolean, "fake-transparency", { .num = &config.fake_transparency }, NULL, "Fake transparency" }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Dynamic options.
|
// Dynamic options.
|
||||||
|
|
Loading…
Reference in a new issue