summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/mate-screensaver-preferences.ui2
-rw-r--r--savers/floaters.c5
-rw-r--r--savers/gs-theme-engine.c33
-rw-r--r--src/gs-window-x11.c110
-rw-r--r--src/mate-screensaver-preferences.c39
5 files changed, 85 insertions, 104 deletions
diff --git a/data/mate-screensaver-preferences.ui b/data/mate-screensaver-preferences.ui
index b948d89..cd3855b 100644
--- a/data/mate-screensaver-preferences.ui
+++ b/data/mate-screensaver-preferences.ui
@@ -137,6 +137,7 @@
<child>
<object class="GtkDrawingArea" id="fullscreen_preview_area">
<property name="visible">True</property>
+ <property name="app_paintable">True</property>
<property name="can_focus">False</property>
</object>
<packing>
@@ -316,6 +317,7 @@
</child>
<child>
<object class="GtkDrawingArea" id="preview_area">
+ <property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
</object>
diff --git a/savers/floaters.c b/savers/floaters.c
index b9291dc..fc83fae 100644
--- a/savers/floaters.c
+++ b/savers/floaters.c
@@ -1050,8 +1050,9 @@ screen_saver_update_state (ScreenSaver *screen_saver,
screen_saver_floater_update_state (screen_saver, floater, time);
- if (gtk_widget_get_realized (screen_saver->drawing_area)
- && (floater->bounds.width > 0) && (floater->bounds.height > 0))
+ if (screen_saver->drawing_area != NULL &&
+ gtk_widget_get_realized (screen_saver->drawing_area) &&
+ (floater->bounds.width > 0) && (floater->bounds.height > 0))
{
gint size;
size = CLAMP ((int) (FLOATER_MAX_SIZE * floater->scale),
diff --git a/savers/gs-theme-engine.c b/savers/gs-theme-engine.c
index 42097df..84c3682 100644
--- a/savers/gs-theme-engine.c
+++ b/savers/gs-theme-engine.c
@@ -107,34 +107,15 @@ gs_theme_engine_get_property (GObject *object,
}
}
-static void
-gs_theme_engine_clear (GtkWidget *widget)
-{
- GdkRGBA color = { 0.0, 0.0, 0.0, 1.0 };
- GtkStateFlags state;
-
- g_return_if_fail (GS_IS_THEME_ENGINE (widget));
-
- if (! gtk_widget_get_visible (widget))
- {
- return;
- }
-
- state = gtk_widget_get_state_flags (widget);
- gtk_widget_override_background_color (widget, state, &color);
- gdk_window_set_background_rgba (gtk_widget_get_window (widget), &color);
- gdk_flush ();
-}
-
static gboolean
-gs_theme_engine_real_map_event (GtkWidget *widget,
- GdkEventAny *event)
+gs_theme_engine_real_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- gboolean handled = FALSE;
-
- gs_theme_engine_clear (widget);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
- return handled;
+ return FALSE;
}
static void
@@ -149,7 +130,7 @@ gs_theme_engine_class_init (GSThemeEngineClass *klass)
object_class->get_property = gs_theme_engine_get_property;
object_class->set_property = gs_theme_engine_set_property;
- widget_class->map_event = gs_theme_engine_real_map_event;
+ widget_class->draw = gs_theme_engine_real_draw;
g_type_class_add_private (klass, sizeof (GSThemeEnginePrivate));
}
diff --git a/src/gs-window-x11.c b/src/gs-window-x11.c
index 87eac00..4054e74 100644
--- a/src/gs-window-x11.c
+++ b/src/gs-window-x11.c
@@ -251,17 +251,6 @@ widget_clear_all_children (GtkWidget *widget)
gdk_error_trap_pop_ignored ();
}
-static void
-gs_window_reset_background_surface (GSWindow *window)
-{
- cairo_pattern_t *pattern;
- pattern = cairo_pattern_create_for_surface (window->priv->background_surface);
- gdk_window_set_background_pattern (gtk_widget_get_window (GTK_WIDGET (window)),
- pattern);
- cairo_pattern_destroy (pattern);
- gtk_widget_queue_draw (GTK_WIDGET (window));
-}
-
void
gs_window_set_background_surface (GSWindow *window,
cairo_surface_t *surface)
@@ -272,68 +261,40 @@ gs_window_set_background_surface (GSWindow *window,
{
cairo_surface_destroy (window->priv->background_surface);
}
+ window->priv->background_surface = NULL;
if (surface != NULL)
{
window->priv->background_surface = cairo_surface_reference (surface);
- gs_window_reset_background_surface (window);
}
+
+ gtk_widget_queue_draw (GTK_WIDGET (window));
}
-static void
-gs_window_clear_to_background_surface (GSWindow *window)
+void
+gs_window_clear (GSWindow *window)
{
g_return_if_fail (GS_IS_WINDOW (window));
- if (! gtk_widget_get_visible (GTK_WIDGET (window)))
- {
- return;
- }
+ gs_debug ("Clearing widgets");
- if (window->priv->background_surface == NULL)
+ if (gtk_widget_get_realized (GTK_WIDGET (window)))
{
- /* don't allow null surfaces */
- return;
+ gtk_widget_queue_draw (GTK_WIDGET (window));
+ /* If a screensaver theme adds child windows
+ we need to clear them too */
+ widget_clear_all_children (GTK_WIDGET (window));
}
- gs_debug ("Clearing window to background pixmap");
-
- gs_window_reset_background_surface (window);
-}
-
-static void
-clear_widget (GtkWidget *widget)
-{
- GdkRGBA rgba = { 0.0, 0.0, 0.0, 1.0 };
- GtkStateFlags state;
-
- if (!gtk_widget_get_realized (widget))
+ if (gtk_widget_get_realized (window->priv->drawing_area))
{
- return;
+ gtk_widget_queue_draw (window->priv->drawing_area);
+ widget_clear_all_children (window->priv->drawing_area);
}
- gs_debug ("Clearing widget");
-
- state = gtk_widget_get_state_flags (widget);
- gtk_widget_override_background_color (widget, state, &rgba);
- gdk_window_set_background_rgba (gtk_widget_get_window (widget), &rgba);
- gtk_widget_queue_draw (GTK_WIDGET (widget));
-
- /* If a screensaver theme adds child windows we need to clear them too */
- widget_clear_all_children (widget);
-
gdk_flush ();
}
-void
-gs_window_clear (GSWindow *window)
-{
- g_return_if_fail (GS_IS_WINDOW (window));
-
- clear_widget (GTK_WIDGET (window));
- clear_widget (window->priv->drawing_area);
-}
-
static cairo_region_t *
get_outside_region (GSWindow *window)
{
@@ -831,6 +792,27 @@ window_select_shape_events (GSWindow *window)
#endif
}
+static gboolean
+gs_window_real_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GSWindow *window = GS_WINDOW (widget);
+ cairo_surface_t *bg_surface = window->priv->background_surface;
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ if (bg_surface != NULL)
+ {
+ cairo_set_source_surface (cr, bg_surface, 0, 0);
+ }
+ else
+ {
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ }
+ cairo_paint (cr);
+
+ return FALSE;
+}
+
static void
gs_window_real_show (GtkWidget *widget)
{
@@ -1738,7 +1720,7 @@ popup_dialog (GSWindow *window)
gtk_widget_hide (window->priv->drawing_area);
- gs_window_clear_to_background_surface (window);
+ gtk_widget_queue_draw (GTK_WIDGET (window));
set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)), FALSE);
window->priv->dialog_quit_requested = FALSE;
@@ -2334,6 +2316,7 @@ gs_window_class_init (GSWindowClass *klass)
widget_class->show = gs_window_real_show;
widget_class->hide = gs_window_real_hide;
+ widget_class->draw = gs_window_real_draw;
widget_class->realize = gs_window_real_realize;
widget_class->unrealize = gs_window_real_unrealize;
widget_class->key_press_event = gs_window_real_key_press_event;
@@ -2454,13 +2437,15 @@ create_info_bar (GSWindow *window)
gtk_box_pack_end (GTK_BOX (window->priv->vbox), window->priv->info_bar, FALSE, FALSE, 0);
}
-static void
-on_drawing_area_realized (GtkWidget *drawing_area)
+static gboolean
+on_drawing_area_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
- gdk_window_set_background_rgba (gtk_widget_get_window (drawing_area),
- &black);
+ return FALSE;
}
static void
@@ -2504,10 +2489,11 @@ gs_window_init (GSWindow *window)
window->priv->drawing_area = gtk_drawing_area_new ();
gtk_widget_show (window->priv->drawing_area);
gtk_widget_set_app_paintable (window->priv->drawing_area, TRUE);
- gtk_box_pack_start (GTK_BOX (window->priv->vbox), window->priv->drawing_area, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (window->priv->vbox),
+ window->priv->drawing_area, TRUE, TRUE, 0);
g_signal_connect (window->priv->drawing_area,
- "realize",
- G_CALLBACK (on_drawing_area_realized),
+ "draw",
+ G_CALLBACK (on_drawing_area_draw),
NULL);
create_info_bar (window);
diff --git a/src/mate-screensaver-preferences.c b/src/mate-screensaver-preferences.c
index 0de7d59..7fd498c 100644
--- a/src/mate-screensaver-preferences.c
+++ b/src/mate-screensaver-preferences.c
@@ -297,15 +297,6 @@ config_set_lock (gboolean lock)
}
static void
-preview_clear (GtkWidget *widget)
-{
- GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
-
- gdk_window_set_background_rgba (gtk_widget_get_window (widget), &black);
- gtk_widget_queue_draw (widget);
-}
-
-static void
job_set_theme (GSJob *job,
const char *theme)
{
@@ -328,6 +319,21 @@ job_set_theme (GSJob *job,
}
}
+static gboolean
+preview_on_draw (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer data)
+{
+ if (job == NULL || !gs_job_is_running (job))
+ {
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
+ }
+
+ return FALSE;
+}
+
static void
preview_set_theme (GtkWidget *widget,
const char *theme,
@@ -341,7 +347,7 @@ preview_set_theme (GtkWidget *widget,
gs_job_stop (job);
}
- preview_clear (widget);
+ gtk_widget_queue_draw (widget);
label = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_theme_label"));
markup = g_markup_printf_escaped ("<i>%s</i>", name);
@@ -1161,7 +1167,7 @@ fullscreen_preview_cancelled_cb (GtkWidget *button,
gs_job_set_widget (job, preview_area);
fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area"));
- preview_clear (fullscreen_preview_area);
+ gtk_widget_queue_draw (fullscreen_preview_area);
fullscreen_preview_window = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_window"));
gtk_widget_hide (fullscreen_preview_window);
@@ -1191,7 +1197,7 @@ fullscreen_preview_start_cb (GtkWidget *widget,
gtk_widget_grab_focus (fullscreen_preview_window);
fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area"));
- preview_clear (fullscreen_preview_area);
+ gtk_widget_queue_draw (fullscreen_preview_area);
gs_job_set_widget (job, fullscreen_preview_area);
}
@@ -1452,6 +1458,7 @@ init_capplet (void)
GtkWidget *preview_button;
GtkWidget *gpm_button;
GtkWidget *fullscreen_preview_window;
+ GtkWidget *fullscreen_preview_area;
GtkWidget *fullscreen_preview_previous;
GtkWidget *fullscreen_preview_next;
GtkWidget *fullscreen_preview_close;
@@ -1500,7 +1507,7 @@ init_capplet (void)
preview_button = GTK_WIDGET (gtk_builder_get_object (builder, "preview_button"));
gpm_button = GTK_WIDGET (gtk_builder_get_object (builder, "gpm_button"));
fullscreen_preview_window = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_window"));
- GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area"));
+ fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area"));
fullscreen_preview_close = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_close"));
fullscreen_preview_previous = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_previous_button"));
fullscreen_preview_next = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_next_button"));
@@ -1568,6 +1575,10 @@ init_capplet (void)
gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-desktop-screensaver");
gtk_window_set_icon_name (GTK_WINDOW (fullscreen_preview_window), "screensaver");
+ g_signal_connect (fullscreen_preview_area,
+ "draw", G_CALLBACK (preview_on_draw),
+ NULL);
+
gtk_drag_dest_set (dialog, GTK_DEST_DEFAULT_ALL,
drop_types, G_N_ELEMENTS (drop_types),
GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE);
@@ -1590,7 +1601,7 @@ init_capplet (void)
g_strfreev (list);
}
- preview_clear (preview);
+ g_signal_connect (preview, "draw", G_CALLBACK (preview_on_draw), NULL);
gs_job_set_widget (job, preview);
if (check_is_root_user ())