From b0f9f5f421436dd29bb8c51ae12dbfcf5277e058 Mon Sep 17 00:00:00 2001 From: fenze Date: Tue, 10 May 2022 20:28:39 +0200 Subject: [PATCH] Add fullscreen function --- config.h | 9 +++++---- keyconf.h | 5 ++++- rose | Bin 23120 -> 0 bytes rose.c | 2 +- window.c | 24 +++++++++++++++--------- 5 files changed, 25 insertions(+), 15 deletions(-) delete mode 100755 rose 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 10ea5476a3b861fbd2284ed2e01d0467074ce73c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23120 zcmeHP4Rl+@m40^YkdVYNkbs+nMg$WK#g3ieG?2Qn;v~pmzzrs(Bt()W*;XP;T1n1d zIpAWT5ysSIS(d_fH*G1)a{A-b?XrPV)?jderEK7|X=qCcf8o6p*c51*LW%bK=0_SU z*4dx4XV30gkI%e2-<^AB?%bI-Gk%))Zd~26rnsoc(qWSId5fsFQgRwqM(b570n%tK zvu5Br&zfsZ1}+gincpZ0a%DJBJeE#T{7InHt6*XrI#04uhYZ?6QtA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2n}%PQPuuD+5xCf!Syt{Y!*hAc?n11DAD^bI$f#IVR@*n} zj^g5fpc<5?xXWsVO+SLjGmvefEV9~|RUTncBL8Qg$B=)i%3p;_i;J5?ZI$4Ch**U_ z;vooC7wtk_K3$cSLe@O^p%!v|pp=9CE6ZFf%c@|=sf$7iMi18StoG1fMfFt>f z*F5A6A-6k@%j@#!&y%ue;4xaQ+1mClK)L6Jo zn+PoX zOJs3aQgk9rcwoW<6CRlG!2ewj==YWM`$=5V84mNLF@nZLJZWs;nR$3&9$uD*oAa#LVLBIdSeGG%nFOksN&NUa|_s26a(u1YEs&BD@HmaA0R5w^2mEZwxhL2T&JiyJs zeIEmkX^aV~8oc-++1L`vpvs%2pmK-!4wYc3hH8G5szA5nfYRdua|T^M&I^h5fF(q6 zs8V423?as&;{xk(g&)%e{+!Ckp(%m2pQP6R{8fKfF2ClbF3DM==sHC^6y2)mt%}~Q z=mUyAtmvqs`xQN;=ut%{pJj<~x}pmeU8?9BMb|0Xq3BjcZ&mbeMITV~VMRw3-LL2& zMUN^vd4Z~5(S?dGRdkJ_>lE!!bgQDbDtfn~4=DPuqN9rLSM-pgM-`oXwyIyzg^Dg! zbd93x6zx!StD?6mdbgqvDEhFXql)fV^pK)Q6`jltHp1zOE>u)s=GIC9*3tuMjcZa-PLFj5EHN5^r!Vjycq0=bX-yII1))-2} zrAAaB3&V@e79War^Ai#OJ%RIF5n{0_F8}+4dY;v_QPvDN{3PC))cVUN$y`lcrZCca zp404wNSuVI_17zXO%52>E)x*Y)di_zQwe@UN1E5 zLOw&jzU0bp3etyKU#};c9%JJWNa#CVzn<6EfJc+HzFwa+)$0*NM9BC572tC2*ZO+C z*YqK!r|s8rnr=Wo*Ak8OdZKBg($BYFv8~NW(3e_YuV-~xT9_~Tq7webview); 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);