]> Eric's Git Repo - ericdock.git/commitdiff
Fixed theming and added initial keygrabbing and wnck support
authorEric Wertz <eric@debian>
Wed, 22 Jun 2016 20:43:53 +0000 (16:43 -0400)
committerEric Wertz <eric@debian>
Wed, 22 Jun 2016 20:43:53 +0000 (16:43 -0400)
Makefile
eric_window.h
main.c

index 1f3f16d2903a3d28ea1ffd4fb50538af461e8d54..742ca1ed85b652d90a74a6e90003374710e452f0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,2 @@
 ericwindow-test: main.c
-       gcc -o ericwindow-test `pkg-config --cflags --libs gtk+-3.0` main.c
+       gcc -o ericwindow-test -lX11 `pkg-config --cflags --libs gtk+-3.0 libwnck-3.0` main.c
index 8d4065af17c9e09a3187490b97c262b0f39f748d..16e5b263663bea7eed437d87f229a2ed40147a06 100644 (file)
@@ -95,8 +95,8 @@ eric_window* eric_window_create( int width, int height, char* title )
 
     gtk_widget_set_app_paintable( w->window, TRUE );
 
-    g_signal_connect( G_OBJECT( w->window ), "draw", G_CALLBACK(eric_window_draw), &w );
-    g_signal_connect( G_OBJECT( w->window ), "screen-changed", G_CALLBACK(eric_window_screen_changed), &w );
+    g_signal_connect( G_OBJECT( w->window ), "draw", G_CALLBACK(eric_window_draw), (gpointer)w );
+    g_signal_connect( G_OBJECT( w->window ), "screen-changed", G_CALLBACK(eric_window_screen_changed), (gpointer)w );
        g_signal_connect( G_OBJECT( w->window ), "delete-event", gtk_main_quit, NULL );
 
     eric_window_screen_changed( w->window, NULL, NULL );
@@ -115,9 +115,8 @@ eric_window* eric_window_create( int width, int height, char* title )
         gsettings = g_settings_new ( "org.gnome.desktop.background" );
     }
 
-    g_signal_connect_data( gsettings, "changed", G_CALLBACK( eric_window_gsettings_value_changed ), NULL, 0, 0 );
+    g_signal_connect_data( gsettings, "changed", G_CALLBACK( eric_window_gsettings_value_changed ), (gpointer)w, 0, 0 );
     gdk_rgba_parse( &w->background_color, g_settings_get_string( gsettings, "primary-color" ) );
-    printf( "COLOR: %s\n", g_settings_get_string( gsettings, "primary-color" ) );
 
     return w;
 }
diff --git a/main.c b/main.c
index 2aad11f4cc2eaacc53cae4c2bfd2e7ecfe19c62c..016342bcef7c8962a9eb535e05b066a3698c0e13 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,13 +1,48 @@
+#include <gdk/gdkx.h>
+#include <X11/Xlib.h>
+
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
+
 #include "eric_window.h"
 
+GdkFilterReturn handle_x11_event( GdkXEvent *xevent, GdkEvent *event, gpointer data )
+{
+    XEvent* xev = (XEvent*)xevent;
+    if( xev->type == KeyPress )
+    {
+        printf( "Got a key press event!\n" );
+    }
+
+    return GDK_FILTER_CONTINUE;
+}
+
 int main( int argc, char* argv[] )
 {
     gtk_init( &argc, &argv );
 
-    eric_window* w = eric_window_create( 640, 480, "Test Eric Window So Kawaii" );
+    eric_window* w = eric_window_create( 640, 480, "" );
+    gtk_window_set_type_hint( GTK_WINDOW( w->window ), GDK_WINDOW_TYPE_HINT_DOCK );
 
     gtk_widget_show_all( w->window );
-    gtk_main();
 
+    Display* dpy = GDK_DISPLAY_XDISPLAY( gdk_display_get_default() );
+    Window xwin = RootWindow( dpy, DefaultScreen( dpy ) );
+    XGrabKey( dpy, AnyKey, ControlMask, xwin, True, GrabModeAsync, GrabModeAsync );
+
+    gdk_window_add_filter( NULL, handle_x11_event, NULL );
+
+    WnckScreen* screen;
+    GList* window_list;
+    screen = wnck_screen_get_default();
+    wnck_screen_force_update( screen );
+
+    for( window_list = wnck_screen_get_windows( screen ); window_list != NULL; window_list = window_list->next )
+    {
+        WnckWindow* window = WNCK_WINDOW( window_list->data );
+        printf( "%s%s\n", wnck_window_get_name( window ), wnck_class_group_get_name( wnck_window_get_class_group( window ) ) );
+    }
+
+    gtk_main();
     return 0;
 }