summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-01-25 18:27:17 +0100
committerJavier <dev.git@javispedro.com>2015-01-25 18:27:17 +0100
commit9e57caac16b1541336b6d2ce76e8ac8edf55474f (patch)
treeab501e8069ba8fe996b521fcb42089d03af6936c
parent8fa634fea02fc11527fa75b57b61645acc17087d (diff)
downloadmdock-9e57caac16b1541336b6d2ce76e8ac8edf55474f.tar.gz
mdock-9e57caac16b1541336b6d2ce76e8ac8edf55474f.zip
delay taking screenshots of windows
-rw-r--r--libmdock/mdock-item-window-selector.c2
-rw-r--r--libmdock/mdock-window.c28
-rw-r--r--libmdock/mdock-window.h1
-rw-r--r--libmdock/thumbnailer.c6
4 files changed, 30 insertions, 7 deletions
diff --git a/libmdock/mdock-item-window-selector.c b/libmdock/mdock-item-window-selector.c
index 7e5b1ca..0930f1d 100644
--- a/libmdock/mdock-item-window-selector.c
+++ b/libmdock/mdock-item-window-selector.c
@@ -243,7 +243,7 @@ void mdock_item_window_selector_set_active_window(MDockItemWindowSelector *self,
g_return_if_fail(iter);
MDockWindow *dwin = g_sequence_get(iter);
- mdock_window_update_screenshot(dwin);
+ mdock_window_schedule_screenshot(dwin);
}
MDockItemWindowSelector *
diff --git a/libmdock/mdock-window.c b/libmdock/mdock-window.c
index 9a21cde..7690ce6 100644
--- a/libmdock/mdock-window.c
+++ b/libmdock/mdock-window.c
@@ -3,6 +3,8 @@
#define MDOCK_WINDOW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), MDOCK_TYPE_WINDOW, MDockWindowPrivate))
+#define SCREENSHOT_DELAY 100
+
struct _MDockWindowPrivate
{
GtkTable *table;
@@ -10,6 +12,7 @@ struct _MDockWindowPrivate
GtkLabel *title;
GtkWidget *close_btn;
GtkImage *img;
+ guint screenshot_timeout;
gboolean preligth : 1;
gboolean selected : 1;
};
@@ -43,6 +46,16 @@ static void update_state(MDockWindow *self)
}
}
+static gboolean screenshot_delay_timeout(gpointer user_data)
+{
+ MDockWindow *self = MDOCK_WINDOW(user_data);
+ if (wnck_window_is_active(self->window)) {
+ mdock_window_update_screenshot(self);
+ }
+ self->priv->screenshot_timeout = 0;
+ return G_SOURCE_REMOVE;
+}
+
static gboolean mdock_window_enter_notify(GtkWidget *widget, GdkEventCrossing *event)
{
MDockWindow *self = MDOCK_WINDOW(widget);
@@ -136,6 +149,11 @@ static void mdock_window_constructed(GObject *object)
static void mdock_window_dispose(GObject *object)
{
+ MDockWindow *self = MDOCK_WINDOW(self);
+ if (self->priv->screenshot_timeout) {
+ g_source_remove(self->priv->screenshot_timeout);
+ self->priv->screenshot_timeout = 0;
+ }
G_OBJECT_CLASS(mdock_window_parent_class)->dispose(object);
}
@@ -187,6 +205,16 @@ void mdock_window_update_screenshot(MDockWindow *self)
thumbnailer_get_thumbnail(self->window), NULL);
}
+void mdock_window_schedule_screenshot(MDockWindow *self)
+{
+ g_return_if_fail(self->window);
+ if (!self->priv->screenshot_timeout) {
+ self->priv->screenshot_timeout = gtk_timeout_add(SCREENSHOT_DELAY,
+ screenshot_delay_timeout,
+ self);
+ }
+}
+
MDockWindow *mdock_window_new(WnckWindow *window)
{
return g_object_new(MDOCK_TYPE_WINDOW, "window", window, NULL);
diff --git a/libmdock/mdock-window.h b/libmdock/mdock-window.h
index c044ea1..218e40f 100644
--- a/libmdock/mdock-window.h
+++ b/libmdock/mdock-window.h
@@ -32,6 +32,7 @@ struct _MDockWindowClass {
GType mdock_window_get_type(void) G_GNUC_CONST;
void mdock_window_update_screenshot(MDockWindow *window);
+void mdock_window_schedule_screenshot(MDockWindow *window);
MDockWindow *mdock_window_new(WnckWindow *window);
diff --git a/libmdock/thumbnailer.c b/libmdock/thumbnailer.c
index e07ba80..7687caa 100644
--- a/libmdock/thumbnailer.c
+++ b/libmdock/thumbnailer.c
@@ -44,12 +44,6 @@ static void thumbnail_data_destroy(ThumbnailData *tdata)
g_slice_free(ThumbnailData, tdata);
}
-static void thumbnail_size(WnckWindow *window, int *thumb_w, int *thumb_h)
-{
- int win_x, win_y, win_w, win_h;
-
-}
-
void thumbnailer_enable_for_window(WnckWindow *window)
{
g_object_set_qdata_full(G_OBJECT(window),