tear out more stuff
This commit is contained in:
parent
12325c692d
commit
742839139e
@ -168,41 +168,10 @@ drawmenu(void)
|
|||||||
drw_map(drw, win, 0, 0, mw, mh);
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
grabfocus(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
|
|
||||||
Window focuswin;
|
|
||||||
int i, revertwin;
|
|
||||||
|
|
||||||
for (i = 0; i < 100; ++i) {
|
|
||||||
XGetInputFocus(dpy, &focuswin, &revertwin);
|
|
||||||
if (focuswin == win)
|
|
||||||
return;
|
|
||||||
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
|
||||||
nanosleep(&ts, NULL);
|
|
||||||
}
|
|
||||||
die("cannot grab focus");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grabkeyboard(void)
|
grabkeyboard(void)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (embed)
|
|
||||||
return;
|
|
||||||
/* try to grab keyboard, we may have to wait for another process to ungrab */
|
|
||||||
for (i = 0; i < 1000; i++) {
|
|
||||||
if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, GrabModeAsync,
|
|
||||||
GrabModeAsync, CurrentTime) == GrabSuccess)
|
|
||||||
return;
|
|
||||||
nanosleep(&ts, NULL);
|
|
||||||
}
|
|
||||||
die("cannot grab keyboard");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -363,11 +332,6 @@ run(void)
|
|||||||
if (ev.xexpose.count == 0)
|
if (ev.xexpose.count == 0)
|
||||||
drw_map(drw, win, 0, 0, mw, mh);
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
break;
|
break;
|
||||||
case FocusIn:
|
|
||||||
/* regrab focus from parent window */
|
|
||||||
if (ev.xfocus.window != win)
|
|
||||||
grabfocus();
|
|
||||||
break;
|
|
||||||
case SelectionNotify:
|
case SelectionNotify:
|
||||||
if (ev.xselection.property == utf8)
|
if (ev.xselection.property == utf8)
|
||||||
paste();
|
paste();
|
||||||
@ -474,7 +438,6 @@ setup(void)
|
|||||||
XSelectInput(dpy, dws[i], FocusChangeMask);
|
XSelectInput(dpy, dws[i], FocusChangeMask);
|
||||||
XFree(dws);
|
XFree(dws);
|
||||||
}
|
}
|
||||||
grabfocus();
|
|
||||||
}
|
}
|
||||||
drw_resize(drw, mw, mh);
|
drw_resize(drw, mw, mh);
|
||||||
drawmenu();
|
drawmenu();
|
||||||
@ -544,13 +507,8 @@ main(int argc, char *argv[])
|
|||||||
die("pledge");
|
die("pledge");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fast && !isatty(0)) {
|
|
||||||
grabkeyboard();
|
|
||||||
readstdin();
|
readstdin();
|
||||||
} else {
|
|
||||||
readstdin();
|
|
||||||
grabkeyboard();
|
|
||||||
}
|
|
||||||
setup();
|
setup();
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user