From: Michael D. Lowis Date: Tue, 23 May 2023 02:41:07 +0000 (-0400) Subject: reenabled keyboard shortcuts and dragging of floating windows X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=434af9df7802ee5e3f17f62e203d3b1e8dfe2966;p=proto%2Faos.git reenabled keyboard shortcuts and dragging of floating windows --- diff --git a/bin/winmgr/anvil.h b/bin/winmgr/anvil.h index bbac50e..eceebd5 100644 --- a/bin/winmgr/anvil.h +++ b/bin/winmgr/anvil.h @@ -114,7 +114,8 @@ struct Client { struct Column { int width; - Client* clients; + int nclients; + Client clients[MAX_COLUMN_CLIENTS]; }; struct Workspace { @@ -148,9 +149,10 @@ typedef struct { Arg arg; } Key; -/* anvil.c */ +/* winmgr.c */ extern XConf X; +/* event.c */ void Event_Map(Window w, XWindowAttributes* attr); void Event_Unmap(Window w, Window parent); void Event_Destroy(Window w); @@ -159,11 +161,13 @@ void Event_Activate(Window w); void Event_PropertyChange(Window w); void Event_Enter(Window w); void Event_Redraw(Window w); -void Event_ButtonPress(Window w, int win_x, int win_y, int root_x, int root_y); -void Event_ButtonRelease(Window w); -void Event_ButtonMotion(Window w); +void Event_ButtonPress(Window w, XButtonEvent* ev); +void Event_ButtonRelease(Window w, XButtonEvent* ev); +void Event_ButtonMotion(Window w, XMotionEvent* ev); void Event_KeyPress(Window w); +/* client.c */ +extern Client* Focused; void Client_InitExistingWindows(void); Client* Client_Find(Window win); Client* Client_Add(Window win, XWindowAttributes* attr); @@ -178,21 +182,22 @@ void Client_Resize(Client* c, int xdiff, int ydiff); void Client_Show(Client* c, int show); void Client_Close(Client* c); - +/* mons.c */ +extern Monitor Monitors[MAX_MONITORS]; +void Monitors_Init(void); void Monitors_Place(Client* c); +/* mouse.c */ void Mouse_ToCorner(Client* client); void Mouse_Down(XButtonEvent* ev, Client* client); void Mouse_Up(XButtonEvent* ev, Client* client); void Mouse_Drag(XMotionEvent* ev, Client* client); +/* keys.c */ +void Keys_Init(void); void Keys_Run(XKeyEvent* ev); - - - - /* list.c */ int list_length(void* list); void* list_del(void* list, void* node); @@ -203,59 +208,52 @@ void* list_last(void* list); #define LIST_FOR_EACH_UNTIL(val,list,cond) \ for (val = list; (val != NULL) && !(cond); val = val->next) -/* keys.c */ -void keys_init(void); -void keys_run(XKeyEvent* ev); - -/* mons.c */ -extern Monitor Monitors[MAX_MONITORS]; - -void mons_init(void); -void mons_delclient(Location* loc); -void mons_activate(Window win); - -void mons_layer(Monitor* mon); -void mons_addclient(Client* c); -void mons_togglefloat(Location* loc); -int mons_find(Window win, Location* loc); -void mons_place(Client* c); -void mons_wspace(int i); -void mons_towspace(Client* c, int i); -void mons_raise(Monitor* mon, Client* c); -void mons_lower(Monitor* mon, Client* c); -void mons_colsplit(void); -void mons_coljoin(void); -void mons_coladjust(Monitor* mon, Column* col, int wdiff); -void mons_tilemove(Location* loc, int hdiff); - -/* client.c */ -extern Client* Focused; -void client_initall(void); -Client* client_add(Window win, XWindowAttributes* attr); -void client_draw(Client* c); -void client_adjust(Client* c); -void client_move(Client* c, int xdiff, int ydiff); -void client_resize(Client* c, int xdiff, int ydiff); -void client_close(Client* c); -void client_focus(Client* c); -void client_show(Client* c, int show); -void client_readprops(Client* c); -void client_shade(Client* c); -void client_setshade(Client* c, int shade); - -/* mouse.c */ -void mouse_down(XButtonEvent* ev, Location* loc); -void mouse_up(XButtonEvent* ev, Location* loc); -void mouse_drag(XMotionEvent* ev, Location* loc); -void mouse_tocorner(Client* c); -void mouse_totitle(Client* c); -void mouse_get(int* ptrx, int* ptry); - -/* tile.c */ -void tile_add(Location* loc); -void tile_del(Location* loc); -void tile_set(Location* loc); -void tile_addheight(Location* loc, int amount); +///* mons.c */ +//void mons_init(void); +//void mons_delclient(Location* loc); +//void mons_activate(Window win); +//void mons_layer(Monitor* mon); +//void mons_addclient(Client* c); +//void mons_togglefloat(Location* loc); +//int mons_find(Window win, Location* loc); +//void mons_place(Client* c); +//void mons_wspace(int i); +//void mons_towspace(Client* c, int i); +//void mons_raise(Monitor* mon, Client* c); +//void mons_lower(Monitor* mon, Client* c); +//void mons_colsplit(void); +//void mons_coljoin(void); +//void mons_coladjust(Monitor* mon, Column* col, int wdiff); +//void mons_tilemove(Location* loc, int hdiff); + +///* client.c */ +//extern Client* Focused; +//void client_initall(void); +//Client* client_add(Window win, XWindowAttributes* attr); +//void client_draw(Client* c); +//void client_adjust(Client* c); +//void client_move(Client* c, int xdiff, int ydiff); +//void client_resize(Client* c, int xdiff, int ydiff); +//void client_close(Client* c); +//void client_focus(Client* c); +//void client_show(Client* c, int show); +//void client_readprops(Client* c); +//void client_shade(Client* c); +//void client_setshade(Client* c, int shade); + +///* mouse.c */ +//void mouse_down(XButtonEvent* ev, Location* loc); +//void mouse_up(XButtonEvent* ev, Location* loc); +//void mouse_drag(XMotionEvent* ev, Location* loc); +//void mouse_tocorner(Client* c); +//void mouse_totitle(Client* c); +//void mouse_get(int* ptrx, int* ptry); + +///* tile.c */ +//void tile_add(Location* loc); +//void tile_del(Location* loc); +//void tile_set(Location* loc); +//void tile_addheight(Location* loc, int amount); /* error.c */ extern int (*error_default)(Display* disp, XErrorEvent* ev); diff --git a/bin/winmgr/event.c b/bin/winmgr/event.c index 42dead5..e2653d4 100644 --- a/bin/winmgr/event.c +++ b/bin/winmgr/event.c @@ -93,24 +93,24 @@ void Event_Redraw(Window w) } } -void Event_ButtonPress(Window w, int win_x, int win_y, int root_x, int root_y) +void Event_ButtonPress(Window w, XButtonEvent* ev) { Client* client = Client_Find(w); if (client && (client->frame == w)) { - if (win_y < MIN_HEIGHT) + if (ev->y < MIN_HEIGHT) { X.edge = E_TOP; } - else if (root_y > (client->y + client->h - BORDER_WIDTH)) + else if (ev->y_root > (client->y + client->h - BORDER_WIDTH)) { X.edge = E_BOTTOM; } - else if (win_x < BORDER_WIDTH) + else if (ev->x < BORDER_WIDTH) { X.edge = E_LEFT; } - else if (root_x > (client->x + client->w - BORDER_WIDTH)) + else if (ev->x_root > (client->x + client->w - BORDER_WIDTH)) { X.edge = E_RIGHT; } @@ -118,27 +118,27 @@ void Event_ButtonPress(Window w, int win_x, int win_y, int root_x, int root_y) { X.edge = E_NONE; } -// Mouse_Down(ev, client); + Mouse_Down(ev, client); } } -void Event_ButtonRelease(Window w) +void Event_ButtonRelease(Window w, XButtonEvent* ev) { Client* client = Client_Find(w); if (client && (client->frame == w)) { -// Mouse_Up(ev, client); + Mouse_Up(ev, client); } X.mode = M_IDLE; XUngrabPointer(X.disp, CurrentTime); } -void Event_ButtonMotion(Window w) +void Event_ButtonMotion(Window w, XMotionEvent* ev) { Client* client = Client_Find(w); if (client && (client->frame == w)) { -// Mouse_Drag(ev, client); + Mouse_Drag(ev, client); } } diff --git a/bin/winmgr/keys.c b/bin/winmgr/keys.c index 67bb215..d076ea3 100644 --- a/bin/winmgr/keys.c +++ b/bin/winmgr/keys.c @@ -1,14 +1,10 @@ #include "anvil.h" #include -static char* wmcmd[] = { "anvil", NULL }; +static char* wmcmd[] = { "winmgr", NULL }; static char* pickexec[] = { "pickexec", NULL }; static char* terminal[] = { "st", NULL }; static char* locker[] = { "slock", NULL }; -static char* new_note[] = { "j", "note", NULL }; -static char* new_task[] = { "j", "task", NULL }; -static char* new_journal[] = { "j", "journal", NULL }; -static char* fetchsel[] = { "fetch", NULL, NULL }; static void restart(Arg* arg) { @@ -29,12 +25,14 @@ static void quit(Arg* arg) static void set_workspace(Arg* arg) { - mons_wspace(arg->i); + (void)arg; +// mons_wspace(arg->i); } static void to_workspace(Arg* arg) { - mons_towspace(Focused, arg->i); + (void)arg; +// mons_towspace(Focused, arg->i); } static void runcmd(Arg *arg) @@ -61,23 +59,23 @@ static void killwin(Arg *arg) static void coljoin(Arg *arg) { (void)arg; - mons_coljoin(); +// mons_coljoin(); } static void colsplit(Arg *arg) { (void)arg; - mons_colsplit(); +// mons_colsplit(); } static void togfloat(Arg *arg) { (void)arg; - Location loc; - if (Focused && mons_find(Focused->win, &loc)) - { - mons_togglefloat(&loc); - } +// Location loc; +// if (Focused && mons_find(Focused->win, &loc)) +// { +// mons_togglefloat(&loc); +// } } static Key keys[] = { @@ -91,11 +89,11 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_c, killwin, { 0 } }, { MODKEY|ShiftMask, XK_f, togfloat, { 0 } }, - /* Jarvis-specific shortcuts */ - { MODKEY, XK_n, runcmd, { .cmd = new_note } }, - { MODKEY, XK_t, runcmd, { .cmd = new_task } }, - { MODKEY, XK_j, runcmd, { .cmd = new_journal } }, - { MODKEY, XK_f, runcmd, { .cmd = fetchsel } }, +// /* Jarvis-specific shortcuts */ +// { MODKEY, XK_n, runcmd, { .cmd = new_note } }, +// { MODKEY, XK_t, runcmd, { .cmd = new_task } }, +// { MODKEY, XK_j, runcmd, { .cmd = new_journal } }, +// { MODKEY, XK_f, runcmd, { .cmd = fetchsel } }, { MODKEY, XK_1, set_workspace, { .i = 0 } }, { MODKEY, XK_2, set_workspace, { .i = 1 } }, @@ -120,7 +118,7 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_0, to_workspace, { .i = 9 } }, }; -void keys_init(void) +void Keys_Init(void) { KeyCode code; for (unsigned int i = 0; i < sizeof(keys)/sizeof(keys[0]); i++) @@ -132,7 +130,7 @@ void keys_init(void) } } -void keys_run(XKeyEvent* ev) +void Keys_Run(XKeyEvent* ev) { KeySym keysym = XkbKeycodeToKeysym(X.disp, ev->keycode, 0, 0); for (unsigned int i = 0; i < sizeof(keys)/sizeof(keys[0]); i++) @@ -144,7 +142,3 @@ void keys_run(XKeyEvent* ev) } } } - -void Keys_Run(XKeyEvent* ev) -{ -} diff --git a/bin/winmgr/mons.c b/bin/winmgr/mons.c index 4fdb7c5..ec3ca9c 100644 --- a/bin/winmgr/mons.c +++ b/bin/winmgr/mons.c @@ -1,14 +1,11 @@ #include "anvil.h" #include -int PtrX = 0, PtrY = 0; +//int PtrX = 0, PtrY = 0; Monitor Monitors[MAX_MONITORS]; -void Monitors_Place(Client* c) -{} - -void mons_init(void) +void Monitors_Init(void) { int nmons; check( XineramaIsActive(X.disp), "Xinerama extension is required"); @@ -32,53 +29,58 @@ void mons_init(void) xfree(mons); } -int mons_find(Window win, Location* loc) -{ - return 0; -} - -/* adds a new client to the most appropriate monitor */ -void mons_addclient(Client* c) -{} - -void mons_delclient(Location* loc) -{} - -void mons_layer(Monitor* mon) -{} - -void mons_togglefloat(Location* loc) -{} - -/* find the best monitor to own the window by calculating the overlap */ -void mons_place(Client* c) +void Monitors_Place(Client* c) { - (void)c; } -void mons_wspace(int wsid) -{} - -void mons_towspace(Client* c, int wsid) -{} - -void mons_raise(Monitor* mon, Client* c) -{} - -void mons_lower(Monitor* mon, Client* c) -{} - -void mons_colsplit(void) -{} - -void mons_coljoin(void) -{} - -void mons_coladjust(Monitor* mon, Column* col, int wdiff) -{} - -void mons_tilemove(Location* loc, int hdiff) -{} - -void mons_activate(Window win) -{} +// +//int mons_find(Window win, Location* loc) +//{ +// return 0; +//} +// +///* adds a new client to the most appropriate monitor */ +//void mons_addclient(Client* c) +//{} +// +//void mons_delclient(Location* loc) +//{} +// +//void mons_layer(Monitor* mon) +//{} +// +//void mons_togglefloat(Location* loc) +//{} +// +///* find the best monitor to own the window by calculating the overlap */ +//void mons_place(Client* c) +//{ +// (void)c; +//} +// +//void mons_wspace(int wsid) +//{} +// +//void mons_towspace(Client* c, int wsid) +//{} +// +//void mons_raise(Monitor* mon, Client* c) +//{} +// +//void mons_lower(Monitor* mon, Client* c) +//{} +// +//void mons_colsplit(void) +//{} +// +//void mons_coljoin(void) +//{} +// +//void mons_coladjust(Monitor* mon, Column* col, int wdiff) +//{} +// +//void mons_tilemove(Location* loc, int hdiff) +//{} +// +//void mons_activate(Window win) +//{} diff --git a/bin/winmgr/winmgr.c b/bin/winmgr/winmgr.c index ec3ad8b..f91a4ef 100644 --- a/bin/winmgr/winmgr.c +++ b/bin/winmgr/winmgr.c @@ -98,19 +98,13 @@ static void xbtnpress(XEvent* e) GrabModeAsync, GrabModeAsync, None, X.csr_move, CurrentTime); X.start_x = ev->x_root, X.start_y = ev->y_root; X.last_x = ev->x_root, X.last_y = ev->y_root; - Event_ButtonPress( - ev->window, - ev->x, - ev->y, - ev->x_root, - ev->y_root - ); + Event_ButtonPress(ev->window, ev); } static void xbtnrelease(XEvent* e) { XButtonEvent* ev = &(e->xbutton); - Event_ButtonRelease(ev->window); + Event_ButtonRelease(ev->window, ev); } static void xbtnmotion(XEvent* e) @@ -118,7 +112,7 @@ static void xbtnmotion(XEvent* e) /* make sure we get just the latest event */ XMotionEvent *ev = &e->xmotion; while (XCheckTypedWindowEvent(X.disp, ev->window, ev->type, e)); - Event_ButtonMotion(ev->window); + Event_ButtonMotion(ev->window, ev); X.last_x = ev->x_root, X.last_y = ev->y_root; } @@ -184,9 +178,9 @@ int main(void) check_for_wm(); init_cursors(); init_font(); - mons_init(); + Monitors_Init(); Client_InitExistingWindows(); - keys_init(); + Keys_Init(); /* setup event handlers */ X.eventfns[ButtonPress] = xbtnpress;