xkjxj
This commit is contained in:
parent
689e5c2d64
commit
2e1a1d51cf
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
SRC = client.c dev.c draw.c event.c main.c util.c
|
SRC = client.c event.c main.c util.c
|
||||||
OBJ = ${SRC:.c=.o}
|
OBJ = ${SRC:.c=.o}
|
||||||
MAN1 = dumbwm.1
|
MAN1 = dumbwm.1
|
||||||
BIN = dumbwm
|
BIN = dumbwm
|
||||||
|
|
23
client.c
23
client.c
|
@ -52,9 +52,9 @@ max(Arg *arg)
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
sel->x = sx;
|
sel->x = sx;
|
||||||
sel->y = sy + bh;
|
sel->y = sy ;
|
||||||
sel->w = sw - 2 * sel->border;
|
sel->w = sw - 2 * sel->border;
|
||||||
sel->h = sh - 2 * sel->border - bh;
|
sel->h = sh - 2 * sel->border;
|
||||||
craise(sel);
|
craise(sel);
|
||||||
resize(sel, False);
|
resize(sel, False);
|
||||||
}
|
}
|
||||||
|
@ -107,9 +107,9 @@ tiling(Arg *arg)
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
if(n > 1)
|
if(n > 1)
|
||||||
h = (sh - bh) / (n - 1);
|
h = (sh ) / (n - 1);
|
||||||
else
|
else
|
||||||
h = sh - bh;
|
h = sh;
|
||||||
|
|
||||||
for(i = 0, c = clients; c; c = c->next) {
|
for(i = 0, c = clients; c; c = c->next) {
|
||||||
if(c->floating) {
|
if(c->floating) {
|
||||||
|
@ -119,19 +119,19 @@ tiling(Arg *arg)
|
||||||
}
|
}
|
||||||
if(n == 1) {
|
if(n == 1) {
|
||||||
c->x = sx;
|
c->x = sx;
|
||||||
c->y = sy + bh;
|
c->y = sy ;
|
||||||
c->w = sw - 2 * c->border;
|
c->w = sw - 2 * c->border;
|
||||||
c->h = sh - 2 * c->border - bh;
|
c->h = sh - 2 * c->border ;
|
||||||
}
|
}
|
||||||
else if(i == 0) {
|
else if(i == 0) {
|
||||||
c->x = sx;
|
c->x = sx;
|
||||||
c->y = sy + bh;
|
c->y = sy ;
|
||||||
c->w = mw - 2 * c->border;
|
c->w = mw - 2 * c->border;
|
||||||
c->h = sh - 2 * c->border - bh;
|
c->h = sh - 2 * c->border ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c->x = sx + mw;
|
c->x = sx + mw;
|
||||||
c->y = sy + (i - 1) * h + bh;
|
c->y = sy + (i - 1) * h ;
|
||||||
c->w = w - 2 * c->border;
|
c->w = w - 2 * c->border;
|
||||||
c->h = h - 2 * c->border;
|
c->h = h - 2 * c->border;
|
||||||
}
|
}
|
||||||
|
@ -289,12 +289,9 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
c->win = w;
|
c->win = w;
|
||||||
c->tx = c->x = wa->x;
|
c->tx = c->x = wa->x;
|
||||||
c->ty = c->y = wa->y;
|
c->ty = c->y = wa->y;
|
||||||
if(c->y < bh)
|
|
||||||
c->ty = c->y += bh;
|
|
||||||
c->tw = c->w = wa->width;
|
c->tw = c->w = wa->width;
|
||||||
c->h = wa->height;
|
c->h = wa->height;
|
||||||
c->th = bh;
|
c->border = 0;
|
||||||
c->border = 1;
|
|
||||||
c->proto = win_proto(c->win);
|
c->proto = win_proto(c->win);
|
||||||
update_size(c);
|
update_size(c);
|
||||||
XSelectInput(dpy, c->win,
|
XSelectInput(dpy, c->win,
|
||||||
|
|
123
dev.c
123
dev.c
|
@ -1,123 +0,0 @@
|
||||||
/*
|
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "dumbwm.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <X11/keysym.h>
|
|
||||||
|
|
||||||
/********** CUSTOMIZE **********/
|
|
||||||
|
|
||||||
|
|
||||||
static Key key[] = {
|
|
||||||
/* modifier key function arguments */
|
|
||||||
{ Mod1Mask|ShiftMask, XK_q, quit, { 0 } },
|
|
||||||
};
|
|
||||||
|
|
||||||
/********** CUSTOMIZE **********/
|
|
||||||
|
|
||||||
void
|
|
||||||
update_keys(void)
|
|
||||||
{
|
|
||||||
static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0;
|
|
||||||
unsigned int i;
|
|
||||||
KeyCode code;
|
|
||||||
|
|
||||||
for(i = 0; i < len; i++) {
|
|
||||||
code = XKeysymToKeycode(dpy, key[i].keysym);
|
|
||||||
XUngrabKey(dpy, code, key[i].mod, root);
|
|
||||||
XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
keypress(XEvent *e)
|
|
||||||
{
|
|
||||||
XKeyEvent *ev = &e->xkey;
|
|
||||||
static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0;
|
|
||||||
unsigned int i;
|
|
||||||
KeySym keysym;
|
|
||||||
|
|
||||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
|
||||||
for(i = 0; i < len; i++)
|
|
||||||
if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
|
|
||||||
if(key[i].func)
|
|
||||||
key[i].func(&key[i].arg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ButtonMask (ButtonPressMask | ButtonReleaseMask)
|
|
||||||
#define MouseMask (ButtonMask | PointerMotionMask)
|
|
||||||
|
|
||||||
void
|
|
||||||
mresize(Client *c)
|
|
||||||
{
|
|
||||||
XEvent ev;
|
|
||||||
int ocx, ocy;
|
|
||||||
|
|
||||||
ocx = c->x;
|
|
||||||
ocy = c->y;
|
|
||||||
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
|
||||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
|
||||||
return;
|
|
||||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
|
|
||||||
for(;;) {
|
|
||||||
XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
|
|
||||||
switch(ev.type) {
|
|
||||||
default: break;
|
|
||||||
case Expose:
|
|
||||||
handler[Expose](&ev);
|
|
||||||
break;
|
|
||||||
case MotionNotify:
|
|
||||||
XFlush(dpy);
|
|
||||||
c->w = abs(ocx - ev.xmotion.x);
|
|
||||||
c->h = abs(ocy - ev.xmotion.y);
|
|
||||||
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
|
||||||
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
|
|
||||||
resize(c, True);
|
|
||||||
break;
|
|
||||||
case ButtonRelease:
|
|
||||||
XUngrabPointer(dpy, CurrentTime);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
mmove(Client *c)
|
|
||||||
{
|
|
||||||
XEvent ev;
|
|
||||||
int x1, y1, ocx, ocy, di;
|
|
||||||
unsigned int dui;
|
|
||||||
Window dummy;
|
|
||||||
|
|
||||||
ocx = c->x;
|
|
||||||
ocy = c->y;
|
|
||||||
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
|
||||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
|
||||||
return;
|
|
||||||
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
|
||||||
for(;;) {
|
|
||||||
XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
|
|
||||||
switch (ev.type) {
|
|
||||||
default: break;
|
|
||||||
case Expose:
|
|
||||||
handler[Expose](&ev);
|
|
||||||
break;
|
|
||||||
case MotionNotify:
|
|
||||||
XFlush(dpy);
|
|
||||||
c->x = ocx + (ev.xmotion.x - x1);
|
|
||||||
c->y = ocy + (ev.xmotion.y - y1);
|
|
||||||
resize(c, False);
|
|
||||||
break;
|
|
||||||
case ButtonRelease:
|
|
||||||
XUngrabPointer(dpy, CurrentTime);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
41
draw.c
41
draw.c
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <X11/Xlocale.h>
|
|
||||||
|
|
||||||
#include "dumbwm.h"
|
|
||||||
|
|
||||||
static void
|
|
||||||
drawborder(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
drawtext(const char *text, Bool invert, Bool border)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long
|
|
||||||
initcolor(const char *colstr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
textnw(char *text, unsigned int len)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
textw(char *text)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
initfont(const char *fontstr)
|
|
||||||
{
|
|
||||||
}
|
|
37
event.c
37
event.c
|
@ -7,7 +7,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <X11/keysym.h>
|
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
#include "dumbwm.h"
|
#include "dumbwm.h"
|
||||||
|
@ -19,51 +18,21 @@ static void destroynotify(XEvent *e);
|
||||||
static void enternotify(XEvent *e);
|
static void enternotify(XEvent *e);
|
||||||
static void leavenotify(XEvent *e);
|
static void leavenotify(XEvent *e);
|
||||||
static void expose(XEvent *e);
|
static void expose(XEvent *e);
|
||||||
static void keymapnotify(XEvent *e);
|
|
||||||
static void maprequest(XEvent *e);
|
static void maprequest(XEvent *e);
|
||||||
static void propertynotify(XEvent *e);
|
static void propertynotify(XEvent *e);
|
||||||
static void unmapnotify(XEvent *e);
|
static void unmapnotify(XEvent *e);
|
||||||
|
|
||||||
void (*handler[LASTEvent]) (XEvent *) = {
|
void (*handler[LASTEvent]) (XEvent *) = {
|
||||||
[ButtonPress] = buttonpress,
|
|
||||||
[ConfigureRequest] = configurerequest,
|
[ConfigureRequest] = configurerequest,
|
||||||
[DestroyNotify] = destroynotify,
|
[DestroyNotify] = destroynotify,
|
||||||
[EnterNotify] = enternotify,
|
[EnterNotify] = enternotify,
|
||||||
[LeaveNotify] = leavenotify,
|
[LeaveNotify] = leavenotify,
|
||||||
[Expose] = expose,
|
[Expose] = expose,
|
||||||
[KeyPress] = keypress,
|
|
||||||
[KeymapNotify] = keymapnotify,
|
|
||||||
[MapRequest] = maprequest,
|
[MapRequest] = maprequest,
|
||||||
[PropertyNotify] = propertynotify,
|
[PropertyNotify] = propertynotify,
|
||||||
[UnmapNotify] = unmapnotify
|
[UnmapNotify] = unmapnotify
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
|
||||||
buttonpress(XEvent *e)
|
|
||||||
{
|
|
||||||
XButtonPressedEvent *ev = &e->xbutton;
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
if(barwin == ev->window)
|
|
||||||
barclick(ev);
|
|
||||||
else if((c = getclient(ev->window))) {
|
|
||||||
craise(c);
|
|
||||||
switch(ev->button) {
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case Button1:
|
|
||||||
mmove(c);
|
|
||||||
break;
|
|
||||||
case Button2:
|
|
||||||
lower(c);
|
|
||||||
break;
|
|
||||||
case Button3:
|
|
||||||
mresize(c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
configurerequest(XEvent *e)
|
configurerequest(XEvent *e)
|
||||||
{
|
{
|
||||||
|
@ -143,12 +112,6 @@ expose(XEvent *e)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
keymapnotify(XEvent *e)
|
|
||||||
{
|
|
||||||
update_keys();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
maprequest(XEvent *e)
|
maprequest(XEvent *e)
|
||||||
{
|
{
|
||||||
|
|
21
main.c
21
main.c
|
@ -23,17 +23,16 @@
|
||||||
|
|
||||||
/* X structs */
|
/* X structs */
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
Window root, barwin;
|
Window root;
|
||||||
Atom wm_atom[WMLast], net_atom[NetLast];
|
Atom wm_atom[WMLast], net_atom[NetLast];
|
||||||
Cursor cursor[CurLast];
|
Cursor cursor[CurLast];
|
||||||
Bool running = True;
|
Bool running = True;
|
||||||
Bool issel;
|
Bool issel;
|
||||||
|
|
||||||
int tsel = Tdev; /* default tag */
|
int tsel = Tdev; /* default tag */
|
||||||
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
int screen, sx, sy, sw, sh, mw;
|
||||||
char stext[1024];
|
char stext[1024];
|
||||||
|
|
||||||
DC dc = {0};
|
|
||||||
Client *clients = NULL;
|
Client *clients = NULL;
|
||||||
Client *sel = NULL;
|
Client *sel = NULL;
|
||||||
|
|
||||||
|
@ -233,13 +232,8 @@ main(int argc, char *argv[])
|
||||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||||
|
|
||||||
update_keys();
|
|
||||||
|
|
||||||
/* style */
|
/* style */
|
||||||
dc.bg = initcolor(BGCOLOR);
|
|
||||||
dc.fg = initcolor(FGCOLOR);
|
|
||||||
dc.border = initcolor(BORDERCOLOR);
|
|
||||||
initfont(FONT);
|
|
||||||
|
|
||||||
sx = sy = 0;
|
sx = sy = 0;
|
||||||
sw = DisplayWidth(dpy, screen);
|
sw = DisplayWidth(dpy, screen);
|
||||||
|
@ -250,17 +244,6 @@ main(int argc, char *argv[])
|
||||||
wa.background_pixmap = ParentRelative;
|
wa.background_pixmap = ParentRelative;
|
||||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||||
|
|
||||||
bx = by = 0;
|
|
||||||
bw = sw;
|
|
||||||
dc.h = bh = dc.font.height + 4;
|
|
||||||
barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
|
|
||||||
CopyFromParent, DefaultVisual(dpy, screen),
|
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
|
||||||
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
|
||||||
XMapRaised(dpy, barwin);
|
|
||||||
|
|
||||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
|
||||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
|
||||||
|
|
||||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue