Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Untypedef struct item
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
49a6583
..
050b858
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-6,7
+6,7
@@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
-#include <
unistd
.h>
+#include <
time
.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
@@
-28,14
+28,13
@@
/* enums */
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
/* enums */
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
-typedef struct Item Item;
-struct Item {
+struct item {
char *text;
char *text;
-
I
tem *left, *right;
+
struct i
tem *left, *right;
bool out;
};
bool out;
};
-static void appenditem(
Item *, Item **, I
tem **);
+static void appenditem(
struct item *, struct item **, struct i
tem **);
static void calcoffsets(void);
static char *cistrstr(const char *, const char *);
static void cleanup(void);
static void calcoffsets(void);
static char *cistrstr(const char *, const char *);
static void cleanup(void);
@@
-56,9
+55,9
@@
static int bh, mw, mh;
static int sw, sh; /* X display screen geometry width, height */
static int inputw, promptw;
static size_t cursor;
static int sw, sh; /* X display screen geometry width, height */
static int inputw, promptw;
static size_t cursor;
-static
I
tem *items = NULL;
-static
I
tem *matches, *matchend;
-static
I
tem *prev, *curr, *next, *sel;
+static
struct i
tem *items = NULL;
+static
struct i
tem *matches, *matchend;
+static
struct i
tem *prev, *curr, *next, *sel;
static int mon = -1, screen;
static Atom clip, utf8;
static int mon = -1, screen;
static Atom clip, utf8;
@@
-75,7
+74,7
@@
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
static char *(*fstrstr)(const char *, const char *) = strstr;
static void
static char *(*fstrstr)(const char *, const char *) = strstr;
static void
-appenditem(
Item *item, Item **list, I
tem **last)
+appenditem(
struct item *item, struct item **list, struct i
tem **last)
{
if (*last)
(*last)->right = item;
{
if (*last)
(*last)->right = item;
@@
-135,7
+134,7
@@
static void
drawmenu(void)
{
int curpos;
drawmenu(void)
{
int curpos;
-
I
tem *item;
+
struct i
tem *item;
int x = 0, y = 0, h = bh, w;
drw_setscheme(drw, &scheme[SchemeNorm]);
int x = 0, y = 0, h = bh, w;
drw_setscheme(drw, &scheme[SchemeNorm]);
@@
-203,6
+202,7
@@
drawmenu(void)
static void
grabkeyboard(void)
{
static void
grabkeyboard(void)
{
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
int i;
/* try to grab keyboard, we may have to wait for another process to ungrab */
int i;
/* try to grab keyboard, we may have to wait for another process to ungrab */
@@
-210,7
+210,7
@@
grabkeyboard(void)
if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True,
GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
return;
if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True,
GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
return;
-
usleep(1000
);
+
nanosleep(&ts, NULL
);
}
die("cannot grab keyboard\n");
}
}
die("cannot grab keyboard\n");
}
@@
-407,7
+407,7
@@
match(void)
char buf[sizeof text], *s;
int i, tokc = 0;
size_t len;
char buf[sizeof text], *s;
int i, tokc = 0;
size_t len;
-
I
tem *item, *lprefix, *lsubstr, *prefixend, *substrend;
+
struct i
tem *item, *lprefix, *lsubstr, *prefixend, *substrend;
strcpy(buf, text);
/* separate input text into tokens to be matched individually */
strcpy(buf, text);
/* separate input text into tokens to be matched individually */