diff --git a/config.h b/config.h index 1566f0b..bbb8019 100644 --- a/config.h +++ b/config.h @@ -8,8 +8,9 @@ static const char *homepage = "https://duckduckgo.com"; #define MODKEY GDK_CONTROL_MASK static Key keys[] = { - { MODKEY, GDK_KEY_h, goback }, - { MODKEY, GDK_KEY_l, goforward }, - { MODKEY, GDK_KEY_y, copy_url }, - { MODKEY, GDK_KEY_p, paste_url } + { MODKEY, GDK_KEY_h, goback }, + { MODKEY, GDK_KEY_l, goforward }, + { MODKEY, GDK_KEY_y, copy_url }, + { MODKEY, GDK_KEY_p, paste_url }, + { 0, GDK_KEY_F11, fullscreen } }; diff --git a/keyconf.h b/keyconf.h index a435972..afa8c7f 100644 --- a/keyconf.h +++ b/keyconf.h @@ -3,6 +3,8 @@ #include #include +#define NONE 4 + typedef struct { unsigned modkey; unsigned keycod; @@ -13,5 +15,6 @@ enum { goback, goforward, copy_url, - paste_url + paste_url, + fullscreen }; diff --git a/rose b/rose deleted file mode 100755 index 10ea547..0000000 Binary files a/rose and /dev/null differ diff --git a/rose.c b/rose.c index f0d63e0..9898830 100644 --- a/rose.c +++ b/rose.c @@ -30,7 +30,7 @@ int main(int argc, char **argv) argv++; argc--; } - GtkApplication *app = gtk_application_new("org.gtk.rose", G_APPLICATION_FLAGS_NONE); + GtkApplication *app = gtk_application_new("org.gtk.rose", G_APPLICATION_NON_UNIQUE); g_signal_connect(app, "activate", G_CALLBACK(run), NULL); g_application_run(G_APPLICATION(app), argc, argv); } diff --git a/window.c b/window.c index 167f006..4e35a3c 100644 --- a/window.c +++ b/window.c @@ -33,38 +33,43 @@ static void read_clipboard(GObject *object, ); } -static gboolean key_press_callback(WebKitWebView *webview, +static gboolean key_press_callback(RoseWindow *window, guint keyval, guint keycode, GdkModifierType state) { - if (state & GDK_CONTROL_MASK) { for (int i = 0; i < LENGTH(keys); i++) { - if (keys[i].modkey == GDK_CONTROL_MASK + if (keys[i].modkey == state && keys[i].keycod == keyval) { switch (keys[i].funcid) { case goback: - webkit_web_view_go_back(webview); + webkit_web_view_go_back(window->webview); break; case goforward: - webkit_web_view_go_forward(webview); + webkit_web_view_go_forward(window->webview); break; case copy_url: { GdkDisplay *dpy = gdk_display_get_default(); gdk_clipboard_set_text( gdk_display_get_clipboard(dpy), - webkit_web_view_get_uri(webview) + webkit_web_view_get_uri(window->webview) ); } break; case paste_url: { GdkDisplay *dpy = gdk_display_get_default(); GdkClipboard *clipboard = gdk_display_get_clipboard(dpy); - gdk_clipboard_read_text_async(clipboard, NULL, read_clipboard, webview); + gdk_clipboard_read_text_async(clipboard, NULL, read_clipboard, window->webview); } break; + case fullscreen: + if (gtk_window_is_fullscreen(window->window)) + gtk_window_unfullscreen(GTK_WINDOW(window->window)); + else + gtk_window_fullscreen(GTK_WINDOW(window->window)); + break; } } } - } + return GDK_EVENT_PROPAGATE; } @@ -91,12 +96,13 @@ static void rose_window_init(RoseWindow *window) void rose_window_show(RoseWindow *window) { GtkWidget *w = gtk_window_new(); + window->window = GTK_WINDOW(w); gtk_window_set_child(GTK_WINDOW(w), GTK_WIDGET(window->webview)); /* Keyboard shortcuts */ GtkEventController *controller; controller = gtk_event_controller_key_new(); - g_signal_connect_swapped(controller, "key-pressed", G_CALLBACK(key_press_callback), window->webview); + g_signal_connect_swapped(controller, "key-pressed", G_CALLBACK(key_press_callback), window); gtk_widget_add_controller(GTK_WIDGET(w), controller); gtk_widget_show(w);