]> git.mdlowis.com Git - proto/aos.git/commitdiff
reenabled keyboard shortcuts and dragging of floating windows
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 23 May 2023 02:41:07 +0000 (22:41 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 23 May 2023 02:41:07 +0000 (22:41 -0400)
bin/winmgr/anvil.h
bin/winmgr/event.c
bin/winmgr/keys.c
bin/winmgr/mons.c
bin/winmgr/winmgr.c

index bbac50eb83df0faa561404a3ed537b3e465851eb..eceebd58fcdcae0bb10e34203ddb2c40f69bf1ca 100644 (file)
@@ -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);
index 42dead5f4a31729294767bddfeb867bbace6423b..e2653d46af2b30bc88a3b11b4b28ae5f0303eba7 100644 (file)
@@ -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);
     }
 }
 
index 67bb215ad68290ec26a4be71fa7e2e6e06eeb0de..d076ea3baed1a876d332c2a6618173d70952fcb3 100644 (file)
@@ -1,14 +1,10 @@
 #include "anvil.h"
 #include <unistd.h>
 
-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)
-{
-}
index 4fdb7c5cede34cffb6169e9f414fe593098afe16..ec3ca9c8f498684c632f229ce6e8f1a5ebdf9573 100644 (file)
@@ -1,14 +1,11 @@
 #include "anvil.h"
 #include <math.h>
 
-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)
+//{}
index ec3ad8b95eb5d6ea86a113d06a0ae0a5759dbe6b..f91a4ef2d5ea867057ea0ba2d3600eabb2c9a38c 100644 (file)
@@ -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;