Xinqi Bao's Git
projects
/
dmenu.git
/ commitdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d9c2456
)
updated to new libdraw
author
Connor Lane Smith <
[email protected]
>
Fri, 2 Jul 2010 04:50:19 +0000
(
05:50
+0100)
committer
Connor Lane Smith <
[email protected]
>
Fri, 2 Jul 2010 04:50:19 +0000
(
05:50
+0100)
dinput.c
patch
|
blob
|
history
dmenu.c
patch
|
blob
|
history
diff --git
a/dinput.c
b/dinput.c
index
4c90cd7
..
0d0adeb
100644
(file)
--- a/
dinput.c
+++ b/
dinput.c
@@
-21,9
+21,8
@@
/* forward declarations */
static void cleanup(void);
/* forward declarations */
static void cleanup(void);
-static void drawcursor(void);
static void drawinput(void);
static void drawinput(void);
-static
Bool
grabkeyboard(void);
+static
void
grabkeyboard(void);
static void kpress(XKeyEvent *e);
static void run(void);
static void setup(void);
static void kpress(XKeyEvent *e);
static void run(void);
static void setup(void);
@@
-35,7
+34,7
@@
static char *prompt = NULL;
static char text[4096];
static int promptw = 0;
static int screen;
static char text[4096];
static int promptw = 0;
static int screen;
-static
unsigned in
t cursor = 0;
+static
size_
t cursor = 0;
static unsigned int numlockmask = 0;
static unsigned int mw, mh;
static unsigned long normcol[ColLast];
static unsigned int numlockmask = 0;
static unsigned int mw, mh;
static unsigned long normcol[ColLast];
@@
-53,16
+52,6
@@
cleanup(void) {
XCloseDisplay(dpy);
}
XCloseDisplay(dpy);
}
-void
-drawcursor(void) {
- XRectangle r = { dc.x, dc.y + 2, 1, dc.font.height - 2 };
-
- r.x += textnw(&dc, text, cursor) + dc.font.height / 2;
-
- XSetForeground(dpy, dc.gc, normcol[ColFG]);
- XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
-}
-
void
drawinput(void)
{
void
drawinput(void)
{
@@
-70,30
+59,30
@@
drawinput(void)
dc.y = 0;
dc.w = mw;
dc.h = mh;
dc.y = 0;
dc.w = mw;
dc.h = mh;
- drawtext(&dc, NULL, normcol
, False
);
+ drawtext(&dc, NULL, normcol);
/* print prompt? */
if(prompt) {
dc.w = promptw;
/* print prompt? */
if(prompt) {
dc.w = promptw;
- drawtext(&dc, prompt, selcol
, False
);
+ drawtext(&dc, prompt, selcol);
dc.x += dc.w;
}
dc.w = mw - dc.x;
dc.x += dc.w;
}
dc.w = mw - dc.x;
- drawtext(&dc,
*text ? text : NULL, normcol, False
);
- drawcursor();
-
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0
);
+ drawtext(&dc,
text, normcol
);
+ drawcursor(
&dc, text, cursor, normcol
);
+
commitdraw(&dc, win
);
}
}
-Bool
+void
grabkeyboard(void) {
unsigned int len;
for(len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
== GrabSuccess)
grabkeyboard(void) {
unsigned int len;
for(len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
== GrabSuccess)
-
break
;
+
return
;
usleep(1000);
}
usleep(1000);
}
-
return len > 0
;
+
exit(EXIT_FAILURE)
;
}
void
}
void
diff --git
a/dmenu.c
b/dmenu.c
index
2cc2cad
..
c612dbe
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-162,25
+162,25
@@
drawmenu(void) {
dc.y = 0;
dc.w = mw;
dc.h = mh;
dc.y = 0;
dc.w = mw;
dc.h = mh;
- drawtext(&dc, NULL, normcol
, False
);
+ drawtext(&dc, NULL, normcol);
dc.h = dc.font.height + 2;
dc.y = topbar ? 0 : mh - dc.h;
/* print prompt? */
if(prompt) {
dc.w = promptw;
dc.h = dc.font.height + 2;
dc.y = topbar ? 0 : mh - dc.h;
/* print prompt? */
if(prompt) {
dc.w = promptw;
- drawtext(&dc, prompt, selcol
, False
);
+ drawtext(&dc, prompt, selcol);
dc.x += dc.w;
}
dc.w = mw - dc.x;
/* print command */
if(cmdw && item && lines == 0)
dc.w = cmdw;
dc.x += dc.w;
}
dc.w = mw - dc.x;
/* print command */
if(cmdw && item && lines == 0)
dc.w = cmdw;
- drawtext(&dc,
*text ? text : NULL, normcol, False
);
+ drawtext(&dc,
text, normcol
);
if(lines > 0)
drawmenuv();
else if(curr)
drawmenuh();
if(lines > 0)
drawmenuv();
else if(curr)
drawmenuh();
-
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0
);
+
commitdraw(&dc, win
);
}
void
}
void
@@
-189,16
+189,16
@@
drawmenuh(void) {
dc.x += cmdw;
dc.w = spaceitem;
dc.x += cmdw;
dc.w = spaceitem;
- drawtext(&dc, curr->left ? "<" : NULL, normcol
, False
);
+ drawtext(&dc, curr->left ? "<" : NULL, normcol);
dc.x += dc.w;
for(i = curr; i != next; i = i->right) {
dc.w = MIN(textw(&dc, i->text), mw / 3);
dc.x += dc.w;
for(i = curr; i != next; i = i->right) {
dc.w = MIN(textw(&dc, i->text), mw / 3);
- drawtext(&dc, i->text, (sel == i) ? selcol : normcol
, False
);
+ drawtext(&dc, i->text, (sel == i) ? selcol : normcol);
dc.x += dc.w;
}
dc.w = spaceitem;
dc.x = mw - dc.w;
dc.x += dc.w;
}
dc.w = spaceitem;
dc.x = mw - dc.w;
- drawtext(&dc, next ? ">" : NULL, normcol
, False
);
+ drawtext(&dc, next ? ">" : NULL, normcol);
}
void
}
void
@@
-209,7
+209,7
@@
drawmenuv(void) {
dc.y = topbar ? dc.h : 0;
dc.w = mw - dc.x;
for(i = curr; i != next; i = i->right) {
dc.y = topbar ? dc.h : 0;
dc.w = mw - dc.x;
for(i = curr; i != next; i = i->right) {
- drawtext(&dc, i->text, (sel == i) ? selcol : normcol
, False
);
+ drawtext(&dc, i->text, (sel == i) ? selcol : normcol);
dc.y += dc.h;
}
if(!XGetWindowAttributes(dpy, win, &wa))
dc.y += dc.h;
}
if(!XGetWindowAttributes(dpy, win, &wa))
@@
-224,11
+224,10
@@
grabkeyboard(void) {
for(len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
== GrabSuccess)
for(len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
== GrabSuccess)
-
break
;
+
return
;
usleep(1000);
}
usleep(1000);
}
- if(!len)
- exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
void
}
void