mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Merge branch 'linux' of https://github.com/chneukirchen/cwm into linux
This commit is contained in:
commit
8e49590e9d
5
calmwm.c
5
calmwm.c
@ -25,6 +25,7 @@
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -62,6 +63,10 @@ main(int argc, char **argv)
|
||||
char *display_name = NULL;
|
||||
int ch;
|
||||
|
||||
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||
warnx("no locale support");
|
||||
mbtowc(NULL, NULL, MB_CUR_MAX);
|
||||
|
||||
while ((ch = getopt(argc, argv, "c:d:")) != -1) {
|
||||
switch (ch) {
|
||||
case 'c':
|
||||
|
2
calmwm.h
2
calmwm.h
@ -351,7 +351,7 @@ struct client_ctx *client_new(Window, struct screen_ctx *, int);
|
||||
void client_ptrsave(struct client_ctx *);
|
||||
void client_ptrwarp(struct client_ctx *);
|
||||
void client_raise(struct client_ctx *);
|
||||
void client_resize(struct client_ctx *);
|
||||
void client_resize(struct client_ctx *, int);
|
||||
void client_send_delete(struct client_ctx *);
|
||||
void client_setactive(struct client_ctx *, int);
|
||||
void client_setname(struct client_ctx *);
|
||||
|
13
client.c
13
client.c
@ -306,7 +306,7 @@ client_maximize(struct client_ctx *cc)
|
||||
cc->flags |= CLIENT_MAXIMIZED;
|
||||
|
||||
resize:
|
||||
client_resize(cc);
|
||||
client_resize(cc, 0);
|
||||
}
|
||||
|
||||
void
|
||||
@ -355,7 +355,7 @@ client_vertmaximize(struct client_ctx *cc)
|
||||
cc->flags |= CLIENT_VMAXIMIZED;
|
||||
|
||||
resize:
|
||||
client_resize(cc);
|
||||
client_resize(cc, 0);
|
||||
}
|
||||
|
||||
void
|
||||
@ -404,12 +404,17 @@ client_horizmaximize(struct client_ctx *cc)
|
||||
cc->flags |= CLIENT_HMAXIMIZED;
|
||||
|
||||
resize:
|
||||
client_resize(cc);
|
||||
client_resize(cc, 0);
|
||||
}
|
||||
|
||||
void
|
||||
client_resize(struct client_ctx *cc)
|
||||
client_resize(struct client_ctx *cc, int reset)
|
||||
{
|
||||
if (reset) {
|
||||
cc->flags &= ~CLIENT_MAXIMIZED;
|
||||
cc->bwidth = Conf.bwidth;
|
||||
}
|
||||
|
||||
client_draw_border(cc);
|
||||
|
||||
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
|
||||
|
16
group.c
16
group.c
@ -512,18 +512,12 @@ group_update_names(struct screen_ctx *sc)
|
||||
{
|
||||
char **strings, *p;
|
||||
unsigned char *prop_ret;
|
||||
Atom type_ret;
|
||||
int format_ret, i = 0, nstrings = 0, n = 0, setnames = 0;
|
||||
unsigned long bytes_after, num_ret;
|
||||
int i = 0, j = 0, nstrings = 0, n = 0, setnames = 0;
|
||||
|
||||
if (XGetWindowProperty(X_Dpy, sc->rootwin,
|
||||
ewmh[_NET_DESKTOP_NAMES].atom, 0, 0xffffff, False,
|
||||
cwmh[UTF8_STRING].atom, &type_ret, &format_ret,
|
||||
&num_ret, &bytes_after, &prop_ret) == Success &&
|
||||
prop_ret != NULL && format_ret == 8) {
|
||||
/* failure, just set defaults */
|
||||
prop_ret[num_ret - 1] = '\0'; /* paranoia */
|
||||
while (i < num_ret) {
|
||||
if ((j = xu_getprop(sc->rootwin, ewmh[_NET_DESKTOP_NAMES].atom,
|
||||
cwmh[UTF8_STRING].atom, 0xffffff, (u_char **)&prop_ret)) > 0) {
|
||||
prop_ret[j - 1] = '\0'; /* paranoia */
|
||||
while (i < j) {
|
||||
if (prop_ret[i++] == '\0')
|
||||
nstrings++;
|
||||
}
|
||||
|
2
kbfunc.c
2
kbfunc.c
@ -119,7 +119,7 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
||||
cc->geom.h = 1;
|
||||
if ((cc->geom.w += mx) < 1)
|
||||
cc->geom.w = 1;
|
||||
client_resize(cc);
|
||||
client_resize(cc, 1);
|
||||
|
||||
/* Make sure the pointer stays within the window. */
|
||||
xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y);
|
||||
|
40
menu.c
40
menu.c
@ -68,7 +68,7 @@ static void menu_draw(struct screen_ctx *, struct menu_ctx *,
|
||||
struct menu_q *, struct menu_q *);
|
||||
static int menu_calc_entry(struct screen_ctx *, struct menu_ctx *,
|
||||
int, int);
|
||||
static int menu_keycode(KeyCode, u_int, enum ctltype *,
|
||||
static int menu_keycode(XKeyEvent *, enum ctltype *,
|
||||
char *);
|
||||
|
||||
void
|
||||
@ -208,16 +208,22 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
{
|
||||
struct menu *mi;
|
||||
enum ctltype ctl;
|
||||
char chr;
|
||||
char chr[32];
|
||||
size_t len;
|
||||
int clen, i;
|
||||
wchar_t wc;
|
||||
|
||||
if (menu_keycode(e->xkey.keycode, e->xkey.state, &ctl, &chr) < 0)
|
||||
if (menu_keycode(&e->xkey, &ctl, chr) < 0)
|
||||
return (NULL);
|
||||
|
||||
switch (ctl) {
|
||||
case CTL_ERASEONE:
|
||||
if ((len = strlen(mc->searchstr)) > 0) {
|
||||
mc->searchstr[len - 1] = '\0';
|
||||
clen = 1;
|
||||
while (mbtowc(&wc, &mc->searchstr[len-clen], MB_CUR_MAX) == -1)
|
||||
clen++;
|
||||
for (i = 1; i <= clen; i++)
|
||||
mc->searchstr[len - i] = '\0';
|
||||
mc->changed = 1;
|
||||
}
|
||||
break;
|
||||
@ -267,13 +273,9 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
break;
|
||||
}
|
||||
|
||||
if (chr != '\0') {
|
||||
char str[2];
|
||||
|
||||
str[0] = chr;
|
||||
str[1] = '\0';
|
||||
if (chr[0] != '\0') {
|
||||
mc->changed = 1;
|
||||
(void)strlcat(mc->searchstr, str, sizeof(mc->searchstr));
|
||||
(void)strlcat(mc->searchstr, chr, sizeof(mc->searchstr));
|
||||
}
|
||||
|
||||
mc->noresult = 0;
|
||||
@ -459,14 +461,16 @@ menu_calc_entry(struct screen_ctx *sc, struct menu_ctx *mc, int x, int y)
|
||||
}
|
||||
|
||||
static int
|
||||
menu_keycode(KeyCode kc, u_int state, enum ctltype *ctl, char *chr)
|
||||
menu_keycode(XKeyEvent *ev, enum ctltype *ctl, char *chr)
|
||||
{
|
||||
int ks;
|
||||
KeySym ks;
|
||||
u_int state = ev->state;
|
||||
|
||||
*ctl = CTL_NONE;
|
||||
*chr = '\0';
|
||||
chr[0] = '\0';
|
||||
|
||||
ks = XkbKeycodeToKeysym(X_Dpy, kc, 0, (state & ShiftMask) ? 1 : 0);
|
||||
ks = XkbKeycodeToKeysym(X_Dpy, ev->keycode, 0,
|
||||
(state & ShiftMask) ? 1 : 0);
|
||||
|
||||
/* Look for control characters. */
|
||||
switch (ks) {
|
||||
@ -532,14 +536,8 @@ menu_keycode(KeyCode kc, u_int state, enum ctltype *ctl, char *chr)
|
||||
if (*ctl != CTL_NONE)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* For regular characters, only (part of, actually) Latin 1
|
||||
* for now.
|
||||
*/
|
||||
if (ks < 0x20 || ks > 0x07e)
|
||||
if (XLookupString(ev, chr, 32, &ks, NULL) < 0)
|
||||
return (-1);
|
||||
|
||||
*chr = (char)ks;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -110,12 +110,12 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
|
||||
/* don't resize more than 60 times / second */
|
||||
if ((ev.xmotion.time - ltime) > (1000 / 60)) {
|
||||
ltime = ev.xmotion.time;
|
||||
client_resize(cc);
|
||||
client_resize(cc, 1);
|
||||
}
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (ltime)
|
||||
client_resize(cc);
|
||||
client_resize(cc, 1);
|
||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||
XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
|
||||
xu_ptr_ungrab();
|
||||
|
Loading…
Reference in New Issue
Block a user