Skip to content

Commit

Permalink
wallpaper mode Transparent UNSTABLE #269
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnorantGuru committed Apr 2, 2013
1 parent 738522e commit 5e4e148
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 2 deletions.
3 changes: 3 additions & 0 deletions data/ui/prefdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
<row>
<col id="0" translatable="yes">Zoom</col>
</row>
<row>
<col id="0" translatable="yes">Transparent</col>
</row>
</data>
</object>
<object class="GtkListStore" id="modelsu">
Expand Down
3 changes: 3 additions & 0 deletions data/ui/prefdlg2.ui
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
<row>
<col id="0" translatable="yes">Zoom</col>
</row>
<row>
<col id="0" translatable="yes">Transparent</col>
</row>
</data>
</object>
<object class="GtkListStore" id="modelsu">
Expand Down
37 changes: 37 additions & 0 deletions src/desktop/desktop-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,43 @@ void desktop_window_set_background( DesktopWindow* win, GdkPixbuf* src_pix, DWBg
gdk_window_set_back_pixmap( gtk_widget_get_window( ((GtkWidget*)win) ), pixmap, FALSE );
#endif
}
else if ( type == DW_BG_TRANSPARENT )
{
int dest_w = gdk_screen_get_width(
gtk_widget_get_screen( (GtkWidget*)win ) );
int dest_h = gdk_screen_get_height(
gtk_widget_get_screen( (GtkWidget*)win ) );
#if GTK_CHECK_VERSION (3, 0, 0)
pixmap = XCreatePixmap(xdisplay, xroot, dest_w, dest_h, depth);
surface = cairo_xlib_surface_create (xdisplay, pixmap, xvisual,
dest_w, dest_h);
cr = cairo_create ( surface );
#else
// set rgba colormap for GTK2
gtk_widget_set_default_colormap( gdk_screen_get_rgba_colormap(
gtk_widget_get_screen( (GtkWidget*)win ) ) );

pixmap = gdk_pixmap_new( gtk_widget_get_window( ((GtkWidget*)win) ),
dest_w, dest_h, -1 );
cr = gdk_cairo_create ( pixmap );
#endif
cairo_save( cr );
cairo_set_operator( cr, CAIRO_OPERATOR_SOURCE );
cairo_set_source_rgba( cr, 0.0, 0.0, 0.0, 0.0 );
cairo_rectangle( cr, 0, 0, dest_w, dest_h );
cairo_paint( cr );
cairo_restore( cr );

// free
#if GTK_CHECK_VERSION (3, 0, 0)
XFreePixmap ( xdisplay, pixmap );
pixmap = 0;
#else
g_object_unref( pixmap );
pixmap = NULL;
#endif
cairo_destroy ( cr );
}
else
gdk_window_set_background( gtk_widget_get_window( ((GtkWidget*)win) ), &win->bg );

Expand Down
1 change: 1 addition & 0 deletions src/desktop/desktop-window.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef enum {
DW_BG_STRETCH,
DW_BG_CENTER,
DW_BG_ZOOM,
DW_BG_TRANSPARENT
}DWBgType;

typedef enum {
Expand Down
8 changes: 7 additions & 1 deletion src/desktop/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ void fm_desktop_update_wallpaper()
GdkPixbuf* pix;
int i;

if( app_settings.show_wallpaper && app_settings.wallpaper )
if ( app_settings.show_wallpaper &&
app_settings.wallpaper_mode == WPM_TRANSPARENT )
{
type = DW_BG_TRANSPARENT;
pix = NULL;
}
else if( app_settings.show_wallpaper && app_settings.wallpaper )
{
switch( app_settings.wallpaper_mode )
{
Expand Down
3 changes: 2 additions & 1 deletion src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ typedef enum {
WPM_FULL,
WPM_CENTER,
WPM_TILE,
WPM_ZOOM
WPM_ZOOM,
WPM_TRANSPARENT
}WallpaperMode;

typedef struct
Expand Down

0 comments on commit 5e4e148

Please sign in to comment.