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