mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Add option to set background for rofi window
This commit is contained in:
parent
8f6c9ee070
commit
b8ecbdcef5
3 changed files with 36 additions and 11 deletions
|
@ -591,7 +591,8 @@ Enable fake transparency. This only works with transparent background color in t
|
||||||
|
|
||||||
`-fake-background`
|
`-fake-background`
|
||||||
|
|
||||||
Select what to use as background for fake transparency. This can be 'background' or 'screenshot'
|
Select what to use as background for fake transparency. This can be 'background', 'screenshot' or a path to an image
|
||||||
|
file (currently only supports png).
|
||||||
|
|
||||||
### Debug
|
### Debug
|
||||||
|
|
||||||
|
|
|
@ -936,7 +936,7 @@ Enable fake transparency\. This only works with transparent background color in
|
||||||
\fB\-fake\-background\fR
|
\fB\-fake\-background\fR
|
||||||
.
|
.
|
||||||
.P
|
.P
|
||||||
Select what to use as background for fake transparency\. This can be \'background\' or \'screenshot\'
|
Select what to use as background for fake transparency\. This can be \'background\', \'screenshot\' or a path to an image file (currently only supports png)\.
|
||||||
.
|
.
|
||||||
.SS "Debug"
|
.SS "Debug"
|
||||||
\fB\-no\-config\fR
|
\fB\-no\-config\fR
|
||||||
|
|
|
@ -76,6 +76,7 @@ struct
|
||||||
xcb_window_t main_window;
|
xcb_window_t main_window;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
cairo_surface_t *fake_bg;
|
cairo_surface_t *fake_bg;
|
||||||
|
int fake_bgrel;
|
||||||
cairo_t *draw;
|
cairo_t *draw;
|
||||||
MenuFlags flags;
|
MenuFlags flags;
|
||||||
GQueue views;
|
GQueue views;
|
||||||
|
@ -86,6 +87,7 @@ struct
|
||||||
.main_window = XCB_WINDOW_NONE,
|
.main_window = XCB_WINDOW_NONE,
|
||||||
.surface = NULL,
|
.surface = NULL,
|
||||||
.fake_bg = NULL,
|
.fake_bg = NULL,
|
||||||
|
.fake_bgrel = FALSE,
|
||||||
.draw = NULL,
|
.draw = NULL,
|
||||||
.flags = MENU_NORMAL,
|
.flags = MENU_NORMAL,
|
||||||
.views = G_QUEUE_INIT,
|
.views = G_QUEUE_INIT,
|
||||||
|
@ -532,13 +534,30 @@ static void rofi_view_setup_fake_transparency ( void )
|
||||||
else if ( g_strcmp0 ( config.fake_background, "background" ) == 0 ) {
|
else if ( g_strcmp0 ( config.fake_background, "background" ) == 0 ) {
|
||||||
s = x11_helper_get_bg_surface ();
|
s = x11_helper_get_bg_surface ();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
char *fpath = rofi_expand_path ( config.fake_background );
|
||||||
|
s = cairo_image_surface_create_from_png ( fpath );
|
||||||
|
CacheState.fake_bgrel = TRUE;
|
||||||
|
g_free ( fpath );
|
||||||
|
}
|
||||||
if ( s != NULL ) {
|
if ( s != NULL ) {
|
||||||
CacheState.fake_bg = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, CacheState.mon.w, CacheState.mon.h );
|
if ( cairo_surface_status ( s ) != CAIRO_STATUS_SUCCESS ) {
|
||||||
cairo_t *dr = cairo_create ( CacheState.fake_bg );
|
cairo_surface_destroy ( s );
|
||||||
cairo_set_source_surface ( dr, s, -CacheState.mon.x, -CacheState.mon.y );
|
s = NULL;
|
||||||
cairo_paint ( dr );
|
}
|
||||||
cairo_destroy ( dr );
|
else {
|
||||||
cairo_surface_destroy ( s );
|
CacheState.fake_bg = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, CacheState.mon.w, CacheState.mon.h );
|
||||||
|
cairo_t *dr = cairo_create ( CacheState.fake_bg );
|
||||||
|
if ( CacheState.fake_bgrel ) {
|
||||||
|
cairo_set_source_surface ( dr, s, 0, 0 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cairo_set_source_surface ( dr, s, -CacheState.mon.x, -CacheState.mon.y );
|
||||||
|
}
|
||||||
|
cairo_paint ( dr );
|
||||||
|
cairo_destroy ( dr );
|
||||||
|
cairo_surface_destroy ( s );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TICK_N ( "Fake transparency" );
|
TICK_N ( "Fake transparency" );
|
||||||
}
|
}
|
||||||
|
@ -954,9 +973,14 @@ void rofi_view_update ( RofiViewState *state )
|
||||||
cairo_set_operator ( d, CAIRO_OPERATOR_SOURCE );
|
cairo_set_operator ( d, CAIRO_OPERATOR_SOURCE );
|
||||||
if ( config.fake_transparency ) {
|
if ( config.fake_transparency ) {
|
||||||
if ( CacheState.fake_bg != NULL ) {
|
if ( CacheState.fake_bg != NULL ) {
|
||||||
cairo_set_source_surface ( d, CacheState.fake_bg,
|
if ( CacheState.fake_bgrel ) {
|
||||||
-(double) ( CacheState.x - CacheState.mon.x ),
|
cairo_set_source_surface ( d, CacheState.fake_bg, 0.0, 0.0 );
|
||||||
-(double) ( CacheState.y - CacheState.mon.y ) );
|
}
|
||||||
|
else {
|
||||||
|
cairo_set_source_surface ( d, CacheState.fake_bg,
|
||||||
|
-(double) ( CacheState.x - CacheState.mon.x ),
|
||||||
|
-(double) ( CacheState.y - CacheState.mon.y ) );
|
||||||
|
}
|
||||||
cairo_paint ( d );
|
cairo_paint ( d );
|
||||||
cairo_set_operator ( d, CAIRO_OPERATOR_OVER );
|
cairo_set_operator ( d, CAIRO_OPERATOR_OVER );
|
||||||
color_background ( d );
|
color_background ( d );
|
||||||
|
|
Loading…
Reference in a new issue