diff --git a/config.def.h b/config.def.h index 5df0e03..acd6497 100644 --- a/config.def.h +++ b/config.def.h @@ -1,17 +1,17 @@ #include "keyconf.h" -OPTIONS { - [CACHE] = DEFAULT, - [HOMEPAGE] = DEFAULT, +static const char *options[] = { + [CACHE] = DEFAULT, /* DEFAULT = "~/.cache/rose" */ + [HOMEPAGE] = DEFAULT, /* DEFAULT = "https://duckduckgo.com" */ }; -APPERANCE { - [HEIGHT] = DEFAULT, - [WIDTH] = DEFAULT, +static int appearance[] = { + [HEIGHT] = DEFAULT, /* DEFAULT = 720 */ + [WIDTH] = DEFAULT, /* DEFAULT = 1280 */ [DARKMODE] = TRUE }; -KEYBINDS { +static const Key keys[] = { { MODKEY, GDK_KEY_h, goback }, { MODKEY, GDK_KEY_l, goforward }, { MODKEY, GDK_KEY_y, copy_url }, diff --git a/keyconf.h b/keyconf.h index ab7b80b..2b11dcc 100644 --- a/keyconf.h +++ b/keyconf.h @@ -18,9 +18,12 @@ #define DARKMODE 2 #define SCROLLBARS 3 +<<<<<<< HEAD #define KEYBINDS static Key keys[] #define APPERANCE static int appearance[] #define OPTIONS static char *options[] +======= +>>>>>>> 1d622de7971b8439866dfb2873d0b33004437431 typedef struct { unsigned modkey; diff --git a/makefile b/makefile index 34aabd1..b5fe0e4 100644 --- a/makefile +++ b/makefile @@ -26,7 +26,12 @@ rose: strip ./rose debug: +<<<<<<< HEAD $(CC) -fPIC -o rose *.c $(CFLAGS) $(LIBS) -Wall -Wextra +======= + $(CC) -fPIC -o rose *.c $(CFLAGS) $(LIBS) $(OPTIONS) -Wall -Wextra \ + -Wno-unused-variable +>>>>>>> 1d622de7971b8439866dfb2873d0b33004437431 config.h: [ -f "$@" ] || cp config.def.h $@ @@ -47,5 +52,5 @@ clean-all: clean flags: echo $(CFLAGS) | sed 's/ /\n/g' > compile_flags.txt -.PHONY: all clean clean-all install uninstall flags config.h -.SILENT: all clean clean-all install uninstall flags config.h +.PHONY: all rose clean clean-all install uninstall flags config.h +.SILENT: all rose clean clean-all install uninstall flags config.h diff --git a/rose.c b/rose.c index ed9980a..f0d759e 100644 --- a/rose.c +++ b/rose.c @@ -3,14 +3,18 @@ #define MSGBUFSZ 8 #define LENGTH(x) (sizeof(x) / sizeof(x[0])) -guint xid; +Display *glob_dpy; /* defined in rose.h */ + +static guint glob_xid; +static Atom glob_atoms[AtomLast]; + void setatom(int a, const char *v) { - XChangeProperty(dpy, xid, - atoms[a], atoms[AtomUTF8], 8, PropModeReplace, + XChangeProperty(glob_dpy, glob_xid, + glob_atoms[a], glob_atoms[AtomUTF8], 8, PropModeReplace, (unsigned char *)v, strlen(v) + 1); - XSync(dpy, False); + XSync(glob_dpy, False); } const char* getatom(int a) @@ -21,9 +25,9 @@ const char* getatom(int a) unsigned long ldummy; unsigned char *p = NULL; - XSync(dpy, False); - XGetWindowProperty(dpy, xid, - atoms[a], 0L, BUFSIZ, False, atoms[AtomUTF8], + XSync(glob_dpy, False); + XGetWindowProperty(glob_dpy, glob_xid, + glob_atoms[a], 0L, BUFSIZ, False, glob_atoms[AtomUTF8], &adummy, &idummy, &ldummy, &ldummy, &p); if (p) strncpy(buf, (char *)p, LENGTH(buf) - 1); @@ -36,14 +40,14 @@ const char* getatom(int a) static void setup() { - if (!(dpy = XOpenDisplay(NULL))) { + if (!(glob_dpy = XOpenDisplay(NULL))) { puts("Can't open default display"); exit(1); } - atoms[AtomFind] = XInternAtom(dpy, "_ROSE_FIND", False); - atoms[AtomGo] = XInternAtom(dpy, "_ROSE_GO", False); - atoms[AtomUri] = XInternAtom(dpy, "_ROSE_URI", False); + glob_atoms[AtomFind] = XInternAtom(glob_dpy, "_ROSE_FIND", False); + glob_atoms[AtomGo] = XInternAtom(glob_dpy, "_ROSE_GO", False); + glob_atoms[AtomUri] = XInternAtom(glob_dpy, "_ROSE_URI", False); } static void run(GtkApplication *app) @@ -56,7 +60,7 @@ static void run(GtkApplication *app) if (!options[HOMEPAGE]) options[HOMEPAGE] = "https://duckduckgo.com"; - xid = rose_window_show(app, window, options[HOMEPAGE]); + glob_xid = rose_window_show(app, window, options[HOMEPAGE]); } int main(int argc, char **argv) diff --git a/rose.h b/rose.h index 99ea26c..8a56410 100644 --- a/rose.h +++ b/rose.h @@ -5,18 +5,23 @@ #include "config.h" #include +#include #include #include -#include -#include -#include #include -#include -#include #include +#include +#include + +enum { + AtomFind, + AtomGo, + AtomUri, + AtomUTF8, + AtomLast +}; + +extern Display *glob_dpy; /* declared in rose.c */ -enum { AtomFind, AtomGo, AtomUri, AtomUTF8, AtomLast }; -static Atom atoms[AtomLast]; -static Display *dpy; const char* getatom(int a); void setatom(int a, const char *v); diff --git a/webview.h b/webview.h index 983e57a..8a4db61 100644 --- a/webview.h +++ b/webview.h @@ -5,8 +5,6 @@ #include #include -G_BEGIN_DECLS - #define ROSE_TYPE_WEBVIEW rose_webview_get_type() G_DECLARE_FINAL_TYPE(RoseWebView, rose_webview, ROSE, WEBVIEW, WebKitWebView) diff --git a/window.c b/window.c index c1050d5..15693a7 100644 --- a/window.c +++ b/window.c @@ -38,6 +38,8 @@ static gboolean key_press_callback(RoseWindow *window, guint keycode, GdkModifierType state) { + (void) keycode; + for (int i = 0; i < LENGTH(keys); i++) { if (keys[i].modkey == state && keys[i].keycod == keyval) { @@ -74,8 +76,8 @@ static gboolean key_press_callback(RoseWindow *window, case search: { int id = fork(); if (id == 0) { - if (dpy) - close(ConnectionNumber(dpy)); + if (glob_dpy) + close(ConnectionNumber(glob_dpy)); setsid(); char* argument_list[] = { "/bin/sh", "-c", "dmenu_rose", NULL}; execvp("/bin/sh", argument_list); @@ -92,8 +94,8 @@ static gboolean key_press_callback(RoseWindow *window, case find: { int id = fork(); if (id == 0) { - if (dpy) - close(ConnectionNumber(dpy)); + if (glob_dpy) + close(ConnectionNumber(glob_dpy)); setsid(); char* argument_list[] = { "/bin/sh", "-c", "dmenu_rose\tfind", NULL}; execvp("/bin/sh", argument_list); @@ -206,6 +208,7 @@ static void rose_window_init(RoseWindow *window) static void destroy() { + (void) window; exit(0); } diff --git a/window.h b/window.h index 33e29f6..0207aeb 100644 --- a/window.h +++ b/window.h @@ -5,8 +5,6 @@ #include #include -G_BEGIN_DECLS - #define ROSE_TYPE_WINDOW rose_window_get_type() G_DECLARE_FINAL_TYPE(RoseWindow, rose_window, ROSE, WINDOW, GtkApplicationWindow) @@ -19,5 +17,3 @@ void rose_window_set_webview(RoseWindow *window, GtkWidget *webview); GActionGroup* rose_window_get_action_group(RoseWindow *window, const char *prefix); - -G_END_DECLS