rose+window: Fix warnings & global variables
This commit is contained in:
parent
63f277ae46
commit
58932060cc
14
config.def.h
14
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 },
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
#define DARKMODE 2
|
||||
#define SCROLLBARS 3
|
||||
|
||||
#define KEYBINDS static inline Key keys[]
|
||||
#define APPERANCE static inline int appearance[]
|
||||
#define OPTIONS static inline char *options[]
|
||||
|
||||
typedef struct {
|
||||
unsigned modkey;
|
||||
|
|
15
rose.c
15
rose.c
|
@ -3,13 +3,16 @@
|
|||
#define MSGBUFSZ 8
|
||||
#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
static Display *glob_dpy;
|
||||
Display *glob_dpy; /* defined in rose.h */
|
||||
|
||||
static guint glob_xid;
|
||||
static Atom glob_atoms[AtomLast];
|
||||
|
||||
|
||||
void setatom(int a, const char *v)
|
||||
{
|
||||
XChangeProperty(glob_dpy, glob_xid,
|
||||
atoms[a], atoms[AtomUTF8], 8, PropModeReplace,
|
||||
glob_atoms[a], glob_atoms[AtomUTF8], 8, PropModeReplace,
|
||||
(unsigned char *)v, strlen(v) + 1);
|
||||
XSync(glob_dpy, False);
|
||||
}
|
||||
|
@ -24,7 +27,7 @@ const char* getatom(int a)
|
|||
|
||||
XSync(glob_dpy, False);
|
||||
XGetWindowProperty(glob_dpy, glob_xid,
|
||||
atoms[a], 0L, BUFSIZ, False, atoms[AtomUTF8],
|
||||
glob_atoms[a], 0L, BUFSIZ, False, glob_atoms[AtomUTF8],
|
||||
&adummy, &idummy, &ldummy, &ldummy, &p);
|
||||
if (p)
|
||||
strncpy(buf, (char *)p, LENGTH(buf) - 1);
|
||||
|
@ -42,9 +45,9 @@ static void setup()
|
|||
exit(1);
|
||||
}
|
||||
|
||||
atoms[AtomFind] = XInternAtom(glob_dpy, "_ROSE_FIND", False);
|
||||
atoms[AtomGo] = XInternAtom(glob_dpy, "_ROSE_GO", False);
|
||||
atoms[AtomUri] = XInternAtom(glob_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)
|
||||
|
|
20
rose.h
20
rose.h
|
@ -5,17 +5,23 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/x11/gdkx.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <gdk/x11/gdkx.h>
|
||||
#include <webkit2/webkit2.h>
|
||||
#include <stdlib.h>
|
||||
#include <webkit2/webkit2.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
enum {
|
||||
AtomFind,
|
||||
AtomGo,
|
||||
AtomUri,
|
||||
AtomUTF8,
|
||||
AtomLast
|
||||
};
|
||||
|
||||
extern Display *glob_dpy; /* declared in rose.c */
|
||||
|
||||
enum { AtomFind, AtomGo, AtomUri, AtomUTF8, AtomLast };
|
||||
static Atom atoms[AtomLast];
|
||||
const char* getatom(int a);
|
||||
void setatom(int a, const char *v);
|
||||
|
|
11
window.c
11
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);
|
||||
|
@ -91,8 +93,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);
|
||||
|
@ -205,6 +207,7 @@ static void rose_window_init(RoseWindow *window)
|
|||
|
||||
static void destroy(RoseWindow *window)
|
||||
{
|
||||
(void) window;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user