summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 07afff3)
raw | patch | inline | side by side (parent: 07afff3)
author | Eric Wertz <ericdwertz@gmail.com> | |
Mon, 10 Oct 2016 21:04:32 +0000 (17:04 -0400) | ||
committer | Eric Wertz <ericdwertz@gmail.com> | |
Mon, 10 Oct 2016 21:04:32 +0000 (17:04 -0400) |
main.c | patch | blob | history |
index b238756c2a442775a2db7ed18572b5524507149b..1d665e2d2eb9dee5f105512690728b30f77d2f8f 100644 (file)
--- a/main.c
+++ b/main.c
#include <stdio.h>
#include <string.h>
+#include <time.h>
+
typedef struct
{
GtkWidget* window;
GSettings* gsettings;
+long old_ns;
+#define FADEIN_TIME 5.0f
+#define FADEOUT_TIME 0.25f
const GLchar* vertSource = "varying vec2 vTexCoord;"
"varying vec4 vColor;"
render_gl( &lock_windows[i] );
}
+ struct timespec tp;
+ clock_gettime( CLOCK_MONOTONIC, &tp );
+ int nanodiff = tp.tv_nsec - old_ns;
+
+ float dt = (float)nanodiff/1.0e9f;
+ if( dt < 0.0f ) dt += 1.0f;
+
+ old_ns = tp.tv_nsec;
+
if( transition_direction > 0.0f )
{
- transition_alpha += 0.0016f;
+ transition_alpha += dt / FADEIN_TIME;
return ( transition_alpha < 1.0 );
}
else
{
- transition_alpha -= 0.0128f;
+ transition_alpha -= dt / FADEOUT_TIME;
for( i = 0; i < mons; i++ )
gtk_window_set_opacity( GTK_WINDOW( lock_windows[i].window ), transition_alpha );
@@ -474,6 +488,10 @@ gboolean key_press_event( GtkWidget* widget, GdkEventKey* event, gpointer user )
if( event->keyval == GDK_KEY_Escape )
{
transition_direction = -1.0f;
+
+ struct timespec tp;
+ clock_gettime( CLOCK_MONOTONIC, &tp );
+ old_ns = tp.tv_nsec;
g_timeout_add( 16, animation_timer, NULL );
}
}
for( i = 0; i< mons; i++ )
gtk_widget_show_all( lock_windows[i].window );
+ //Kick off the animation timer
+ struct timespec tp;
+ clock_gettime( CLOCK_MONOTONIC, &tp );
+ old_ns = tp.tv_nsec;
g_timeout_add( 16, animation_timer, NULL );
grab_keys();