mirror of https://github.com/davatorium/rofi.git
Add fake transparency
This commit is contained in:
parent
64cb4c781c
commit
a7c7cf8159
|
@ -144,4 +144,5 @@ Settings config = {
|
|||
.hide_scrollbar = FALSE,
|
||||
.markup_rows = FALSE,
|
||||
.fullscreen = FALSE,
|
||||
.fake_transparency = FALSE,
|
||||
};
|
||||
|
|
|
@ -246,6 +246,8 @@ typedef struct _Settings
|
|||
unsigned int markup_rows;
|
||||
/** fullscreen */
|
||||
unsigned int fullscreen;
|
||||
/** bg image */
|
||||
unsigned int fake_transparency;
|
||||
} Settings;
|
||||
|
||||
/** Global Settings structure. */
|
||||
|
|
|
@ -224,6 +224,7 @@ typedef struct MenuState
|
|||
int *lines_not_ascii;
|
||||
int line_height;
|
||||
unsigned int border;
|
||||
cairo_surface_t *bg;
|
||||
}MenuState;
|
||||
|
||||
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->case_indicator );
|
||||
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++ ) {
|
||||
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_t *d = cairo_create ( surf );
|
||||
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.
|
||||
color_background ( display, d );
|
||||
cairo_paint ( d );
|
||||
}
|
||||
color_border ( display, d );
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
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.
|
||||
monitor_active ( display, &mon );
|
||||
|
||||
|
@ -1215,6 +1249,11 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *select
|
|||
else if ( ev.type == ConfigureNotify ) {
|
||||
XConfigureEvent xce = ev.xconfigure;
|
||||
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 ) {
|
||||
state.w = xce.width;
|
||||
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_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, "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.
|
||||
|
|
Loading…
Reference in New Issue