Ver código fonte

add config.*

Martin Duquesnoy 13 anos atrás
pai
commit
0be08c6a4a
7 arquivos alterados com 111 adições e 4 exclusões
  1. 17 0
      wmfs2/src/client.c
  2. 2 0
      wmfs2/src/client.h
  3. 10 0
      wmfs2/src/config.c
  4. 21 0
      wmfs2/src/config.h
  5. 34 0
      wmfs2/src/event.c
  6. 18 0
      wmfs2/src/wmfs.c
  7. 9 4
      wmfs2/src/wmfs.h

+ 17 - 0
wmfs2/src/client.c

@@ -28,6 +28,17 @@ client_configure(Client *c)
      XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ev);
 }
 
+Client*
+client_gb_win(Window *w)
+{
+     Client *c = SLIST_FIRST(&W->h.client);
+
+     while(c && c->win != w)
+          c = SLIST_NEXT(c, next);
+
+     return c;
+}
+
 /** Map a client
  * \param c Client pointer
  */
@@ -46,6 +57,12 @@ client_unmap(Client *c)
      XUnmapWindow(W->dpy, c->win);
 }
 
+void
+client_focus(Client *c)
+{
+
+}
+
 /** Close a client
  * \param c Client pointer
 */

+ 2 - 0
wmfs2/src/client.h

@@ -21,8 +21,10 @@ typedef struct Client
 } Client;
 
 void client_configure(Client *c);
+Client *client_gb_win(Window *w);
 void client_map(Client *c);
 void client_unmap(Client *c);
+void client_focus(Client *c);
 void client_close(Client *c);
 Client *client_new(Window w, XWindowAttributes *wa);
 void client_remove(Client *c);

+ 10 - 0
wmfs2/src/config.c

@@ -0,0 +1,10 @@
+/*
+ *  wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
+ *  For license, see COPYING.
+ */
+
+void
+config_init(void)
+{
+
+}

+ 21 - 0
wmfs2/src/config.h

@@ -0,0 +1,21 @@
+/*
+ *  wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
+ *  For license, see COPYING.
+ */
+
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include "wmfs.h"
+
+typedef struct Keybind
+{
+     unsigned int mod;
+     KeySym keysym;
+     void (*func)(Uicb);
+     Uicb cmd;
+     SLIST_ENTRY(Keybind) next;
+} Keybind;
+
+#endif /* CONFIG_H */

+ 34 - 0
wmfs2/src/event.c

@@ -7,6 +7,40 @@
 #include "util.h"
 #include "wmfs.h"
 
+#define EVDPY(e) (e)->xany.display
+
+static void
+event_enternotify(XEvent *e)
+{
+     XCrossingEvent *ev = &e->xcrossing;
+     Client *c;
+     int n;
+
+     if((ev->mode != NotifyNormal || ev->detail == NotifyInferior)
+               && ev->window != W->root)
+          return;
+
+     if((c = client_gb_win(ev->window)))
+          client_focus(c);
+}
+
+static void
+event_maprequest(XEvent *e)
+{
+     XMapRequestEvent *ev = &e->xmaprequest;
+     XWindowAttributes at;
+
+     /* Which windows to manage */
+     if(!XGetWindowAttributes(EVDPY(e), ev->window, &at)
+               || at.overried_redirect
+               || client_gb_win(ev->window))
+          return;
+
+     (Client*)client_new(ev->window, at);
+}
+
+
+
 static void
 event_dummy(XEvent *e)
 {

+ 18 - 0
wmfs2/src/wmfs.c

@@ -108,6 +108,24 @@ wmfs_xinit(void)
 
 }
 
+void
+wmfs_grab_keys(void)
+{
+     KeyCode c;
+     Keybind *k;
+
+     XUngrabKey(W->dpy, AnyKey, AnyModifier, W->root);
+
+     FOREACH(k, &W->h.keybind, next)
+          if((c = XKeysymToKeycode(dpy, k->keysym)))
+          {
+               XGrabKey(W->dpy, c, k->mod, W->root, True, GrabModeAsync, GrabModeAsync);
+               XGrabKey(W->dpy, c, k->mod | LockMask, W->root, True, GrabModeAsync, GrabModeAsync);
+               XGrabKey(W->dpy, c, k->mod | numlockmask, W->root, True, GrabModeAsync, GrabModeAsync);
+               XGrabKey(W->dpy, c, k->mod | LockMask | numlockmask, W->root, True, GrabModeAsync, GrabModeAsync);
+          }
+}
+
 static void
 wmfs_loop(void)
 {

+ 9 - 4
wmfs2/src/wmfs.h

@@ -24,10 +24,14 @@
 /* Local */
 #include "screen.h"
 #include "client.h"
+#include "config.h"
 
-#define ButtonMask   (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
-#define MouseMask    (ButtonMask | PointerMotionMask)
-#define KeyMask      (KeyPressMask | KeyReleaseMask)
+#define ButtonMask (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
+#define MouseMask  (ButtonMask | PointerMotionMask)
+#define KeyMask    (KeyPressMask | KeyReleaseMask)
+
+typedef unsigned int Flags;
+typedef const char* Uicb;
 
 typedef struct
 {
@@ -55,6 +59,7 @@ typedef struct
      {
           SLIST_HEAD(, Screen) screen;
           SLIST_HEAD(, Client) client;
+          SLIST_HEAD(, Keybind) keybind;
      } h;
 
      /*
@@ -65,9 +70,9 @@ typedef struct
 
 } Wmfs;
 
-
 int wmfs_error_handler(Display *d, XErrorEvent *event);
 int wmfs_error_handler_dummy(Display *d, XErrorEvent *event);
+void wmfs_grab_keys(void);
 void wmfs_quit(void);
 
 /* Single global variable */