misc cleanup
This commit is contained in:
1
action.c
1
action.c
@@ -146,6 +146,7 @@ void action_rollback(void *data, int num, client *cli)
|
||||
}
|
||||
}
|
||||
client_free(c);
|
||||
c = NULL;
|
||||
}
|
||||
if (a)
|
||||
{
|
||||
|
||||
16
setup.c
16
setup.c
@@ -25,16 +25,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
long left, right, top, bottom,
|
||||
ly1, ly2, ry1, ry3,
|
||||
tx1, tx2, bx1, bx2;
|
||||
// _NET_WM_STRUT_PARTIAL
|
||||
long left, right, top, bottom, ly1, ly2, ry1, ry3, tx1, tx2, bx1, bx2;
|
||||
} wm_strut;
|
||||
|
||||
void setup()
|
||||
{
|
||||
int i, j; client *c; monitor *m;
|
||||
wm_strut struts; memset(&struts, 0, sizeof(wm_strut));
|
||||
|
||||
int screen_w = WidthOfScreen(DefaultScreenOfDisplay(display));
|
||||
int screen_h = HeightOfScreen(DefaultScreenOfDisplay(display));
|
||||
|
||||
@@ -67,6 +64,7 @@ void setup()
|
||||
|
||||
for_monitors(j, m)
|
||||
{
|
||||
// convert _NET_WM_STRUT to _PARTIAL
|
||||
if (v1)
|
||||
{
|
||||
strut.ly1 = m->y; strut.ly2 = m->y + m->h;
|
||||
@@ -126,6 +124,7 @@ void setup()
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// normal wide screen
|
||||
int width_spot1 = (double)w / 100 * MIN(90, MAX(10, SPOT1_WIDTH_PCT));
|
||||
int height_spot2 = (double)h / 100 * MIN(90, MAX(10, SPOT2_HEIGHT_PCT));
|
||||
for_spots(j)
|
||||
@@ -161,10 +160,9 @@ void setup()
|
||||
|
||||
// figure out NumlockMask
|
||||
XModifierKeymap *modmap = XGetModifierMapping(display);
|
||||
for (i = 0; i < 8; i++)
|
||||
for (j = 0; j < (int)modmap->max_keypermod; j++)
|
||||
if (modmap->modifiermap[i*modmap->max_keypermod+j] == XKeysymToKeycode(display, XK_Num_Lock))
|
||||
{ NumlockMask = (1<<i); break; }
|
||||
for (i = 0; i < 8; i++) for (j = 0; j < (int)modmap->max_keypermod; j++)
|
||||
if (modmap->modifiermap[i*modmap->max_keypermod+j] == XKeysymToKeycode(display, XK_Num_Lock))
|
||||
{ NumlockMask = (1<<i); break; }
|
||||
XFreeModifiermap(modmap);
|
||||
|
||||
// process config.h key bindings
|
||||
|
||||
38
spot.c
38
spot.c
@@ -24,39 +24,34 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#define SPOT_BUFF 1024
|
||||
|
||||
void spot_update_bar(int spot, int mon)
|
||||
{
|
||||
int i, n = 0; client *o, *c = NULL;
|
||||
int i, n = 0, len = 0; client *o, *c = NULL;
|
||||
char *title = alloca(SPOT_BUFF); *title = 0;
|
||||
monitor *m = &monitors[mon];
|
||||
|
||||
char *title = calloc(1024, sizeof(char));
|
||||
int len = 0, lim = 1024;
|
||||
|
||||
for_windows(i, o) if (o->manage && o->spot == spot && o->monitor == mon)
|
||||
{
|
||||
if (!c) c = o;
|
||||
char *name = NULL;
|
||||
char *name = NULL, *tmp = NULL;
|
||||
if (!(name = window_get_text_prop(o->window, atoms[_NET_WM_NAME])))
|
||||
{
|
||||
char *tmp;
|
||||
if (XFetchName(display, o->window, &tmp))
|
||||
{
|
||||
name = strdup(tmp);
|
||||
XFree(tmp);
|
||||
}
|
||||
}
|
||||
if (name)
|
||||
{
|
||||
if (TITLE_ELLIPSIS && strlen(name) > TITLE_ELLIPSIS)
|
||||
if (TITLE_ELLIPSIS > 0 && strlen(name) > TITLE_ELLIPSIS)
|
||||
{
|
||||
name = realloc(name, strlen(name)+4);
|
||||
strcpy(name+TITLE_ELLIPSIS, "...");
|
||||
}
|
||||
len += snprintf(title+len, MAX(0, lim-len), " [%d] %s ", n++, name);
|
||||
len += snprintf(title+len, MAX(0, SPOT_BUFF-len), " [%d] %s ", n++, name);
|
||||
free(name);
|
||||
}
|
||||
if (tmp) XFree(tmp);
|
||||
}
|
||||
if (c && !c->full && title && m->bars[spot])
|
||||
if (c && !c->full && *title && m->bars[spot])
|
||||
{
|
||||
int focus = c->window == current || (spot == current_spot && mon == current_mon);
|
||||
char *color = focus && c->window == current ? TITLE_FOCUS : TITLE_BLUR;
|
||||
@@ -69,27 +64,22 @@ void spot_update_bar(int spot, int mon)
|
||||
else
|
||||
if (m->bars[spot])
|
||||
textbox_hide(m->bars[spot]);
|
||||
free(title);
|
||||
}
|
||||
|
||||
void update_bars()
|
||||
{
|
||||
int i, j; monitor *m;
|
||||
for_monitors(i, m) for_spots(j)
|
||||
spot_update_bar(j, i);
|
||||
for_monitors(i, m) for_spots(j) spot_update_bar(j, i);
|
||||
}
|
||||
|
||||
Window spot_focus_top_window(int spot, int mon, Window except)
|
||||
{
|
||||
int i; client *c;
|
||||
for_windows(i, c)
|
||||
for_windows(i, c) if (c->window != except && c->manage && c->spot == spot && c->monitor == mon)
|
||||
{
|
||||
if (c->window != except && c->manage && c->spot == spot && c->monitor == mon)
|
||||
{
|
||||
client_raise_family(c);
|
||||
client_set_focus(c);
|
||||
return c->window;
|
||||
}
|
||||
client_raise_family(c);
|
||||
client_set_focus(c);
|
||||
return c->window;
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
73
textbox.c
73
textbox.c
@@ -34,8 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
typedef struct {
|
||||
unsigned long flags;
|
||||
Window window, parent;
|
||||
short x, y, w, h;
|
||||
short cursor;
|
||||
short x, y, w, h, cursor;
|
||||
XftFont *font;
|
||||
XftColor color_fg, color_bg;
|
||||
char *text, *prompt;
|
||||
@@ -180,7 +179,6 @@ void textbox_draw(textbox *tb)
|
||||
int text_len = strlen(text);
|
||||
int length = text_len;
|
||||
int line_height = tb->font->ascent + tb->font->descent;
|
||||
int line_width = 0;
|
||||
|
||||
int cursor_x = 0;
|
||||
int cursor_offset = 0;
|
||||
@@ -208,7 +206,7 @@ void textbox_draw(textbox *tb)
|
||||
|
||||
// calc full input text width
|
||||
XftTextExtents8(display, tb->font, (unsigned char*)line, length, &extents);
|
||||
line_width = extents.width;
|
||||
int line_width = extents.width;
|
||||
|
||||
int x = 0, y = tb->font->ascent;
|
||||
if (tb->flags & TB_RIGHT) x = tb->w - line_width;
|
||||
@@ -315,60 +313,29 @@ void textbox_cursor_bkspc(textbox *tb)
|
||||
// -1 = handled and return pressed (finished)
|
||||
int textbox_keypress(textbox *tb, XEvent *ev)
|
||||
{
|
||||
KeySym key; Status stat;
|
||||
char pad[32]; int len;
|
||||
|
||||
if (!(tb->flags & TB_EDITABLE)) return 0;
|
||||
|
||||
len = XmbLookupString(tb->xic, &ev->xkey, pad, sizeof(pad), &key, &stat);
|
||||
KeySym key; Status stat; char pad[32];
|
||||
|
||||
int len = XmbLookupString(tb->xic, &ev->xkey, pad, sizeof(pad), &key, &stat);
|
||||
pad[len] = 0;
|
||||
|
||||
if (key == XK_Left)
|
||||
switch (key)
|
||||
{
|
||||
textbox_cursor_dec(tb);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
if (key == XK_Right)
|
||||
{
|
||||
textbox_cursor_inc(tb);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
if (key == XK_Home)
|
||||
{
|
||||
textbox_cursor_home(tb);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
if (key == XK_End)
|
||||
{
|
||||
textbox_cursor_end(tb);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
if (key == XK_Delete)
|
||||
{
|
||||
textbox_cursor_del(tb);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
if (key == XK_BackSpace)
|
||||
{
|
||||
textbox_cursor_bkspc(tb);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
if (key == XK_Return)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
if (!iscntrl(*pad))
|
||||
{
|
||||
textbox_insert(tb, tb->cursor, pad);
|
||||
textbox_cursor_inc(tb);
|
||||
return 1;
|
||||
case XK_Left : textbox_cursor_dec(tb); return 1;
|
||||
case XK_Right : textbox_cursor_inc(tb); return 1;
|
||||
case XK_Home : textbox_cursor_home(tb); return 1;
|
||||
case XK_End : textbox_cursor_end(tb); return 1;
|
||||
case XK_Delete : textbox_cursor_del(tb); return 1;
|
||||
case XK_BackSpace : textbox_cursor_bkspc(tb); return 1;
|
||||
case XK_Return : return -1;
|
||||
default:
|
||||
if (!iscntrl(*pad))
|
||||
{
|
||||
textbox_insert(tb, tb->cursor, pad);
|
||||
textbox_cursor_inc(tb);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user