From 05da63ff9188d78a8a2acba926dedc88f384b657 Mon Sep 17 00:00:00 2001 From: Eric Wertz Date: Wed, 22 Jun 2016 16:43:53 -0400 Subject: [PATCH] Fixed theming and added initial keygrabbing and wnck support --- Makefile | 2 +- eric_window.h | 7 +++---- main.c | 39 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 1f3f16d..742ca1e 100644 --- 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 diff --git a/eric_window.h b/eric_window.h index 8d4065a..16e5b26 100644 --- a/eric_window.h +++ b/eric_window.h @@ -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 2aad11f..016342b 100644 --- a/main.c +++ b/main.c @@ -1,13 +1,48 @@ +#include +#include + +#define WNCK_I_KNOW_THIS_IS_UNSTABLE +#include + #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; } -- 2.47.0