add ewmh, compile now
This commit is contained in:
parent
6886a6902a
commit
3da9117a8b
@ -25,11 +25,12 @@ client_configure(Client *c)
|
|||||||
ev.border_width = 0;
|
ev.border_width = 0;
|
||||||
ev.override_redirect = 0;
|
ev.override_redirect = 0;
|
||||||
|
|
||||||
XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ev);
|
XSendEvent(W->dpy, c->win, False, StructureNotifyMask, (XEvent *)&ev);
|
||||||
|
XSync(W->dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client*
|
Client*
|
||||||
client_gb_win(Window *w)
|
client_gb_win(Window w)
|
||||||
{
|
{
|
||||||
Client *c = SLIST_FIRST(&W->h.client);
|
Client *c = SLIST_FIRST(&W->h.client);
|
||||||
|
|
||||||
@ -63,6 +64,27 @@ client_focus(Client *c)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get a client name
|
||||||
|
* \param c Client pointer
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
client_get_name(Client *c)
|
||||||
|
{
|
||||||
|
Atom rt;
|
||||||
|
int rf;
|
||||||
|
unsigned long ir, il;
|
||||||
|
|
||||||
|
/* This one instead XFetchName for utf8 name support */
|
||||||
|
if(XGetWindowProperty(W->dpy, c->win, ATOM("_NET_WM_NAME"), 0, 4096,
|
||||||
|
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, (unsigned char**)&c->title) != Success)
|
||||||
|
XGetWindowProperty(W->dpy, c->win, ATOM("WM_NAME"), 0, 4096,
|
||||||
|
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, (unsigned char**)&c->title);
|
||||||
|
|
||||||
|
/* Still no title... */
|
||||||
|
if(!c->title)
|
||||||
|
XFetchName(W->dpy, c->win, &(c->title));
|
||||||
|
}
|
||||||
|
|
||||||
/** Close a client
|
/** Close a client
|
||||||
* \param c Client pointer
|
* \param c Client pointer
|
||||||
*/
|
*/
|
||||||
@ -124,10 +146,17 @@ client_new(Window w, XWindowAttributes *wa)
|
|||||||
|
|
||||||
/* X window attributes */
|
/* X window attributes */
|
||||||
at.event_mask = PropertyChangeMask;
|
at.event_mask = PropertyChangeMask;
|
||||||
XChangeWindowAttributes(dpy, w, CWEventMask, &at);
|
XChangeWindowAttributes(W->dpy, c->win, CWEventMask, &at);
|
||||||
|
|
||||||
/* Attach */
|
/* Attach */
|
||||||
SLIST_INSERT(&W->h.client, c, Client, next);
|
SLIST_INSERT_HEAD(&W->h.client, c, next);
|
||||||
|
|
||||||
|
client_map(c);
|
||||||
|
|
||||||
|
XMoveResizeWindow(W->dpy, c->win, c->geo.x, c->geo.y, c->geo.w, c->geo.h);
|
||||||
|
XRaiseWindow(W->dpy, w);
|
||||||
|
|
||||||
|
client_configure(c);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -151,5 +180,5 @@ client_remove(Client *c)
|
|||||||
void
|
void
|
||||||
client_free(void)
|
client_free(void)
|
||||||
{
|
{
|
||||||
FREE_LIST(W->client);
|
FREE_LIST(Client, W->h.client);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,21 +7,9 @@
|
|||||||
#define CLIENT_H
|
#define CLIENT_H
|
||||||
|
|
||||||
#include "wmfs.h"
|
#include "wmfs.h"
|
||||||
#include "tag.h"
|
|
||||||
#include "screen.h"
|
|
||||||
|
|
||||||
typedef struct Client
|
|
||||||
{
|
|
||||||
Tag *tag;
|
|
||||||
Screen *screen;
|
|
||||||
Geo *geo;
|
|
||||||
Flags flags;
|
|
||||||
Window win;
|
|
||||||
SLIST_ENTRY(Client) next;
|
|
||||||
} Client;
|
|
||||||
|
|
||||||
void client_configure(Client *c);
|
void client_configure(Client *c);
|
||||||
Client *client_gb_win(Window *w);
|
Client *client_gb_win(Window w);
|
||||||
void client_map(Client *c);
|
void client_map(Client *c);
|
||||||
void client_unmap(Client *c);
|
void client_unmap(Client *c);
|
||||||
void client_focus(Client *c);
|
void client_focus(Client *c);
|
||||||
|
|||||||
0
wmfs2/src/config.c
Normal file → Executable file
0
wmfs2/src/config.c
Normal file → Executable file
9
wmfs2/src/config.h
Normal file → Executable file
9
wmfs2/src/config.h
Normal file → Executable file
@ -9,13 +9,4 @@
|
|||||||
|
|
||||||
#include "wmfs.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 */
|
#endif /* CONFIG_H */
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "wmfs.h"
|
#include "wmfs.h"
|
||||||
|
#include "client.h"
|
||||||
|
|
||||||
#define EVDPY(e) (e)->xany.display
|
#define EVDPY(e) (e)->xany.display
|
||||||
|
|
||||||
@ -24,6 +25,40 @@ event_enternotify(XEvent *e)
|
|||||||
client_focus(c);
|
client_focus(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
event_configureevent(XEvent *e)
|
||||||
|
{
|
||||||
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||||
|
XWindowChanges wc;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
if((c = client_gb_win(ev->window)))
|
||||||
|
{
|
||||||
|
if(ev->value_mask & CWX)
|
||||||
|
c->geo.x = ev->x;
|
||||||
|
if(ev->value_mask & CWY)
|
||||||
|
c->geo.y = ev->y;
|
||||||
|
if(ev->value_mask & CWWidth)
|
||||||
|
c->geo.w = ev->width;
|
||||||
|
if(ev->value_mask & CWHeight)
|
||||||
|
c->geo.h = ev->height;
|
||||||
|
|
||||||
|
client_configure(c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wc.x = ev->x;
|
||||||
|
wc.y = ev->y;
|
||||||
|
wc.width = ev->width;
|
||||||
|
wc.height = ev->height;
|
||||||
|
wc.border_width = ev->border_width;
|
||||||
|
wc.sibling = ev->above;
|
||||||
|
wc.stack_mode = ev->detail;
|
||||||
|
|
||||||
|
XConfigureWindow(EVDPY(e), ev->window, ev->value_mask, &wc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
event_destroynotify(XEvent *e)
|
event_destroynotify(XEvent *e)
|
||||||
{
|
{
|
||||||
@ -31,7 +66,7 @@ event_destroynotify(XEvent *e)
|
|||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
if((c = client_gb_win(ev->window)))
|
if((c = client_gb_win(ev->window)))
|
||||||
client_unmanage(c);
|
client_remove(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -51,11 +86,11 @@ event_maprequest(XEvent *e)
|
|||||||
|
|
||||||
/* Which windows to manage */
|
/* Which windows to manage */
|
||||||
if(!XGetWindowAttributes(EVDPY(e), ev->window, &at)
|
if(!XGetWindowAttributes(EVDPY(e), ev->window, &at)
|
||||||
|| at.overried_redirect
|
|| at.override_redirect)
|
||||||
|| client_gb_win(ev->window))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(Client*)client_new(ev->window, at);
|
if(!client_gb_win(ev->window))
|
||||||
|
(Client*)client_new(ev->window, &at);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -137,9 +172,9 @@ event_keypress(XEvent *e)
|
|||||||
Keybind *k;
|
Keybind *k;
|
||||||
Flags m = ~(W->numlockmask | LockMask);
|
Flags m = ~(W->numlockmask | LockMask);
|
||||||
|
|
||||||
keysym = XKeycodeToKeysym(EVDPY, (KeyCode)ev->keycode, 0);
|
keysym = XKeycodeToKeysym(EVDPY(e), (KeyCode)ev->keycode, 0);
|
||||||
|
|
||||||
SLIST_FOREACH(k, W->h.keybind, next)
|
SLIST_FOREACH(k, &W->h.keybind, next)
|
||||||
if(k->keysym == keysym && (k->mod & m) == (ev->state & m))
|
if(k->keysym == keysym && (k->mod & m) == (ev->state & m))
|
||||||
if(k->func)
|
if(k->func)
|
||||||
k->func(k->cmd);
|
k->func(k->cmd);
|
||||||
@ -157,6 +192,7 @@ event_expose(XEvent *e)
|
|||||||
static void
|
static void
|
||||||
event_dummy(XEvent *e)
|
event_dummy(XEvent *e)
|
||||||
{
|
{
|
||||||
|
printf("%d\n", e->type);
|
||||||
(void)e;
|
(void)e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,9 +204,9 @@ event_init(void)
|
|||||||
while(i--)
|
while(i--)
|
||||||
event_handle[i] = event_dummy;
|
event_handle[i] = event_dummy;
|
||||||
|
|
||||||
event_handle[ButtonPress] = event_buttonpress;
|
/*event_handle[ButtonPress] = event_buttonpress;*/
|
||||||
/*event_handle[ClientMessage] = event_clientmessageevent;*/
|
/*event_handle[ClientMessage] = event_clientmessageevent;*/
|
||||||
/*event_handle[ConfigureRequest] = event_configureevent;*/
|
event_handle[ConfigureRequest] = event_configureevent;
|
||||||
event_handle[DestroyNotify] = event_destroynotify;
|
event_handle[DestroyNotify] = event_destroynotify;
|
||||||
event_handle[EnterNotify] = event_enternotify;
|
event_handle[EnterNotify] = event_enternotify;
|
||||||
event_handle[Expose] = event_expose;
|
event_handle[Expose] = event_expose;
|
||||||
|
|||||||
@ -6,12 +6,14 @@
|
|||||||
#ifndef EVENT_H
|
#ifndef EVENT_H
|
||||||
#define EVENT_H
|
#define EVENT_H
|
||||||
|
|
||||||
|
#include "wmfs.h"
|
||||||
|
|
||||||
#define MAX_EV 256
|
#define MAX_EV 256
|
||||||
|
|
||||||
#define HANDLE_EVENT(e) event_handle[(e)->type](e);
|
#define HANDLE_EVENT(e) event_handle[(e)->type](e);
|
||||||
|
|
||||||
void event_init(void);
|
void event_init(void);
|
||||||
|
|
||||||
void (*event_handle)(XEvent*)[MAX_EV];
|
void (*event_handle[MAX_EV])(XEvent*);
|
||||||
|
|
||||||
#endif /* EVENT_H */
|
#endif /* EVENT_H */
|
||||||
|
|||||||
94
wmfs2/src/ewmh.c
Executable file
94
wmfs2/src/ewmh.c
Executable file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
|
||||||
|
* For license, see COPYING.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
|
#include "ewmh.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
ewmh_init(void)
|
||||||
|
{
|
||||||
|
int b = 1;
|
||||||
|
|
||||||
|
W->net_atom = xcalloc(net_last, sizeof(Atom));
|
||||||
|
|
||||||
|
/* EWMH hints */
|
||||||
|
W->net_atom[net_supported] = ATOM("_NET_SUPPORTED");
|
||||||
|
W->net_atom[net_client_list] = ATOM("_NET_CLIENT_LIST");
|
||||||
|
W->net_atom[net_frame_extents] = ATOM("_NET_FRAME_EXTENTS");
|
||||||
|
W->net_atom[net_number_of_desktops] = ATOM("_NET_NUMBER_OF_DESKTOPS");
|
||||||
|
W->net_atom[net_current_desktop] = ATOM("_NET_CURRENT_DESKTOP");
|
||||||
|
W->net_atom[net_desktop_names] = ATOM("_NET_DESKTOP_NAMES");
|
||||||
|
W->net_atom[net_desktop_geometry] = ATOM("_NET_DESKTOP_GEOMETRY");
|
||||||
|
W->net_atom[net_active_window] = ATOM("_NET_ACTIVE_WINDOW");
|
||||||
|
W->net_atom[net_close_window] = ATOM("_NET_CLOSE_WINDOW");
|
||||||
|
W->net_atom[net_wm_name] = ATOM("_NET_WM_NAME");
|
||||||
|
W->net_atom[net_wm_pid] = ATOM("_NET_WM_PID");
|
||||||
|
W->net_atom[net_wm_desktop] = ATOM("_NET_WM_DESKTOP");
|
||||||
|
W->net_atom[net_showing_desktop] = ATOM("_NET_SHOWING_DESKTOP");
|
||||||
|
W->net_atom[net_wm_icon_name] = ATOM("_NET_WM_ICON_NAME");
|
||||||
|
W->net_atom[net_wm_window_type] = ATOM("_NET_WM_WINDOW_TYPE");
|
||||||
|
W->net_atom[net_supporting_wm_check] = ATOM("_NET_SUPPORTING_WM_CHECK");
|
||||||
|
W->net_atom[net_wm_window_opacity] = ATOM("_NET_WM_WINDOW_OPACITY");
|
||||||
|
W->net_atom[net_wm_window_type_normal] = ATOM("_NET_WM_WINDOW_TYPE_NORMAL");
|
||||||
|
W->net_atom[net_wm_window_type_dock] = ATOM("_NET_WM_WINDOW_TYPE_DOCK");
|
||||||
|
W->net_atom[net_wm_window_type_splash] = ATOM("_NET_WM_WINDOW_TYPE_SPLASH");
|
||||||
|
W->net_atom[net_wm_window_type_dialog] = ATOM("_NET_WM_WINDOW_TYPE_DIALOG");
|
||||||
|
W->net_atom[net_wm_icon] = ATOM("_NET_WM_ICON");
|
||||||
|
W->net_atom[net_wm_state] = ATOM("_NET_WM_STATE");
|
||||||
|
W->net_atom[net_wm_state_fullscreen] = ATOM("_NET_WM_STATE_FULLSCREEN");
|
||||||
|
W->net_atom[net_wm_state_sticky] = ATOM("_NET_WM_STATE_STICKY");
|
||||||
|
W->net_atom[net_wm_state_demands_attention] = ATOM("_NET_WM_STATE_DEMANDS_ATTENTION");
|
||||||
|
W->net_atom[net_wm_system_tray_opcode] = ATOM("_NET_SYSTEM_TRAY_OPCODE");
|
||||||
|
W->net_atom[net_system_tray_message_data] = ATOM("_NET_SYSTEM_TRAY_MESSAGE_DATA");
|
||||||
|
W->net_atom[net_system_tray_visual] = ATOM("_NET_SYSTEM_TRAY_VISUAL");
|
||||||
|
W->net_atom[net_system_tray_orientation] = ATOM("_NET_SYSTEM_TRAY_ORIENTATION");
|
||||||
|
W->net_atom[xembed] = ATOM("_XEMBED");
|
||||||
|
W->net_atom[xembedinfo] = ATOM("_XEMBED_INFO");
|
||||||
|
W->net_atom[manager] = ATOM("MANAGER");
|
||||||
|
W->net_atom[utf8_string] = ATOM("UTF8_STRING");
|
||||||
|
|
||||||
|
/* WMFS hints */
|
||||||
|
W->net_atom[wmfs_running] = ATOM("_WMFS_RUNNING");
|
||||||
|
W->net_atom[wmfs_update_hints] = ATOM("_WMFS_UPDATE_HINTS");
|
||||||
|
W->net_atom[wmfs_set_screen] = ATOM("_WMFS_SET_SCREEN");
|
||||||
|
W->net_atom[wmfs_screen_count] = ATOM("_WMFS_SCREEN_COUNT");
|
||||||
|
W->net_atom[wmfs_current_tag] = ATOM("_WMFS_CURRENT_TAG");
|
||||||
|
W->net_atom[wmfs_tag_list] = ATOM("_WMFS_TAG_LIST");
|
||||||
|
W->net_atom[wmfs_current_screen] = ATOM("_WMFS_CURRENT_SCREEN");
|
||||||
|
W->net_atom[wmfs_current_layout] = ATOM("_WMFS_CURRENT_LAYOUT");
|
||||||
|
W->net_atom[wmfs_mwfact] = ATOM("_WMFS_MWFACT");
|
||||||
|
W->net_atom[wmfs_nmaster] = ATOM("_WMFS_NMASTER");
|
||||||
|
W->net_atom[wmfs_function] = ATOM("_WMFS_FUNCTION");
|
||||||
|
W->net_atom[wmfs_cmd] = ATOM("_WMFS_CMD");
|
||||||
|
W->net_atom[wmfs_font] = ATOM("_WMFS_FONT");
|
||||||
|
|
||||||
|
XChangeProperty(W->dpy, W->root, W->net_atom[net_supported], XA_ATOM, 32,
|
||||||
|
PropModeReplace, (unsigned char*)W->net_atom, net_last);
|
||||||
|
|
||||||
|
XChangeProperty(W->dpy, W->root, W->net_atom[wmfs_running], XA_CARDINAL, 32,
|
||||||
|
PropModeReplace, (unsigned char*)&b, 1);
|
||||||
|
|
||||||
|
/* Set _NET_SUPPORTING_WM_CHECK */
|
||||||
|
XChangeProperty(W->dpy, W->root, W->net_atom[net_supporting_wm_check], XA_WINDOW, 32,
|
||||||
|
PropModeReplace, (unsigned char*)&W->root, 1);
|
||||||
|
/*
|
||||||
|
XChangeProperty(W->dpy, W->root, W->net_atom[net_wm_name], W->net_atom[utf8_string], 8,
|
||||||
|
PropModeReplace, (unsigned char*)&rootn, strlen(rootn));
|
||||||
|
|
||||||
|
XChangeProperty(W->dpy, W->root, ATOM("WM_CLASS"), XA_STRING, 8,
|
||||||
|
PropModeReplace, (unsigned char*)&class, strlen(class));
|
||||||
|
|
||||||
|
* Set _NET_WM_PID
|
||||||
|
XChangeProperty(W->dpy, W->root, W->net_atom[net_wm_pid], XA_CARDINAL, 32,
|
||||||
|
PropModeReplace, (unsigned char*)&pid, 1);
|
||||||
|
|
||||||
|
* Set _NET_SHOWING_DESKTOP
|
||||||
|
XChangeProperty(W->dpy, W->root, W->net_atom[net_showing_desktop], XA_CARDINAL, 32,
|
||||||
|
PropModeReplace, (unsigned char*)&showing_desk, 1);
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
70
wmfs2/src/ewmh.h
Executable file
70
wmfs2/src/ewmh.h
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
|
||||||
|
* For license, see COPYING.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef EWMH_H
|
||||||
|
#define EWMH_H
|
||||||
|
|
||||||
|
#include "wmfs.h"
|
||||||
|
|
||||||
|
/* Ewmh hints list */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
net_supported,
|
||||||
|
net_wm_name,
|
||||||
|
net_client_list,
|
||||||
|
net_frame_extents,
|
||||||
|
net_number_of_desktops,
|
||||||
|
net_current_desktop,
|
||||||
|
net_desktop_names,
|
||||||
|
net_desktop_geometry,
|
||||||
|
net_active_window,
|
||||||
|
net_close_window,
|
||||||
|
net_wm_icon_name,
|
||||||
|
net_wm_window_type,
|
||||||
|
net_wm_pid,
|
||||||
|
net_showing_desktop,
|
||||||
|
net_supporting_wm_check,
|
||||||
|
net_wm_window_opacity,
|
||||||
|
net_wm_window_type_normal,
|
||||||
|
net_wm_window_type_dock,
|
||||||
|
net_wm_window_type_splash,
|
||||||
|
net_wm_window_type_dialog,
|
||||||
|
net_wm_desktop,
|
||||||
|
net_wm_icon,
|
||||||
|
net_wm_state,
|
||||||
|
net_wm_state_fullscreen,
|
||||||
|
net_wm_state_sticky,
|
||||||
|
net_wm_state_demands_attention,
|
||||||
|
net_wm_system_tray_opcode,
|
||||||
|
net_system_tray_message_data,
|
||||||
|
net_system_tray_s,
|
||||||
|
net_system_tray_visual,
|
||||||
|
net_system_tray_orientation,
|
||||||
|
xembed,
|
||||||
|
xembedinfo,
|
||||||
|
manager,
|
||||||
|
utf8_string,
|
||||||
|
/* WMFS HINTS */
|
||||||
|
wmfs_running,
|
||||||
|
wmfs_update_hints,
|
||||||
|
wmfs_current_tag,
|
||||||
|
wmfs_current_screen,
|
||||||
|
wmfs_current_layout,
|
||||||
|
wmfs_tag_list,
|
||||||
|
wmfs_mwfact,
|
||||||
|
wmfs_nmaster,
|
||||||
|
wmfs_set_screen,
|
||||||
|
wmfs_screen_count,
|
||||||
|
wmfs_function,
|
||||||
|
wmfs_cmd,
|
||||||
|
wmfs_font,
|
||||||
|
wmfs_statustext,
|
||||||
|
net_last
|
||||||
|
};
|
||||||
|
|
||||||
|
void ewmh_init(void);
|
||||||
|
|
||||||
|
#endif /* EWMH_H */
|
||||||
@ -6,17 +6,17 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static Screen*
|
static Scr33n*
|
||||||
screen_new(Geo g)
|
screen_new(Geo *g)
|
||||||
{
|
{
|
||||||
Screen *s = xcalloc(1, sizeof(Screen));
|
Scr33n *s = xcalloc(1, sizeof(Scr33n));
|
||||||
|
|
||||||
s->geo = g;
|
s->geo = *g;
|
||||||
s->seltag = NULL;
|
s->seltag = NULL;
|
||||||
|
|
||||||
SLIST_INIT(&s->tags);
|
SLIST_INIT(&s->tags);
|
||||||
|
|
||||||
SLIST_INSERT_HEAD(s, &W->h.screen, Screen, next);
|
SLIST_INSERT_HEAD(&W->h.screen, s, next);
|
||||||
|
|
||||||
W->screen = s;
|
W->screen = s;
|
||||||
|
|
||||||
@ -35,11 +35,11 @@ screen_init(void)
|
|||||||
|
|
||||||
SLIST_INIT(&W->h.screen);
|
SLIST_INIT(&W->h.screen);
|
||||||
|
|
||||||
screen_new(g);
|
screen_new(&g);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_free(void)
|
screen_free(void)
|
||||||
{
|
{
|
||||||
FREE_LIST(Screen, W->h.screen);
|
FREE_LIST(Scr33n, W->h.screen);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,19 +3,10 @@
|
|||||||
* For license, see COPYING.
|
* For license, see COPYING.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "wmfs.h"
|
|
||||||
#include "tag.h"
|
|
||||||
|
|
||||||
#ifndef SCREEN_H
|
#ifndef SCREEN_H
|
||||||
#define SCREEN_H
|
#define SCREEN_H
|
||||||
|
|
||||||
typedef struct Screen
|
#include "wmfs.h"
|
||||||
{
|
|
||||||
Geo geo;
|
|
||||||
Tag *seltag;
|
|
||||||
SLIST_HEAD(, Tag) tags;
|
|
||||||
SLIST_ENTRY(Screen) next;
|
|
||||||
} Screen;
|
|
||||||
|
|
||||||
void screen_init(void);
|
void screen_init(void);
|
||||||
void screen_free(void);
|
void screen_free(void);
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
Tag*
|
Tag*
|
||||||
tag_new(Screen *s, const char *name)
|
tag_new(Scr33n *s, char *name)
|
||||||
{
|
{
|
||||||
Tag *t;
|
Tag *t;
|
||||||
|
|
||||||
@ -18,13 +18,13 @@ tag_new(Screen *s, const char *name)
|
|||||||
t->flags = 0;
|
t->flags = 0;
|
||||||
t->sel = NULL;
|
t->sel = NULL;
|
||||||
|
|
||||||
SLIST_INSERT_HEAD(t, &s->tags, Tag, next);
|
SLIST_INSERT_HEAD(&s->tags, t, next);
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tag_screen(Screen *s, Tag *t)
|
tag_screen(Scr33n *s, Tag *t)
|
||||||
{
|
{
|
||||||
s->seltag = t;
|
s->seltag = t;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ tag_screen(Screen *s, Tag *t)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tag_free(Screen *s)
|
tag_free(Scr33n *s)
|
||||||
{
|
{
|
||||||
LIST_FREE(s->tags);
|
FREE_LIST(Tag, s->tags);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,16 +7,10 @@
|
|||||||
#define TAG_H
|
#define TAG_H
|
||||||
|
|
||||||
#include "wmfs.h"
|
#include "wmfs.h"
|
||||||
#include "screen.h"
|
|
||||||
#include "client.h"
|
|
||||||
|
|
||||||
typedef struct Tag
|
Tag *tag_new(Scr33n *s, char *name);
|
||||||
{
|
void tag_screen(Scr33n *s, Tag *t);
|
||||||
char *name;
|
void tag_free(Scr33n *s);
|
||||||
Screen *screen;
|
|
||||||
Flags flags;
|
|
||||||
Client *sel;
|
|
||||||
SLIST_ENTRY(Tag) next;
|
|
||||||
} Tag;
|
|
||||||
|
|
||||||
#endif /* TAG_H */
|
#endif /* TAG_H */
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
* For license, see COPYING.
|
* For license, see COPYING.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "wmfs.h"
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
/** malloc with error support and size_t overflow protection
|
/** malloc with error support and size_t overflow protection
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
#ifndef UTIL_H
|
#ifndef UTIL_H
|
||||||
#define UTIL_H
|
#define UTIL_H
|
||||||
|
|
||||||
|
#include "wmfs.h"
|
||||||
|
|
||||||
/* Todo FREE_LIST(type, head, function_remove) */
|
/* Todo FREE_LIST(type, head, function_remove) */
|
||||||
#define FREE_LIST(type, head) \
|
#define FREE_LIST(type, head) \
|
||||||
do { \
|
do { \
|
||||||
@ -17,6 +19,8 @@
|
|||||||
} \
|
} \
|
||||||
} while(/* CONSTCOND */ 0);
|
} while(/* CONSTCOND */ 0);
|
||||||
|
|
||||||
|
#define ATOM(a) XInternAtom(W->dpy, (a), False)
|
||||||
|
|
||||||
void *xmalloc(size_t nmemb, size_t size);
|
void *xmalloc(size_t nmemb, size_t size);
|
||||||
void *xcalloc(size_t nmemb, size_t size);
|
void *xcalloc(size_t nmemb, size_t size);
|
||||||
pid_t spawn(const char *format, ...);
|
pid_t spawn(const char *format, ...);
|
||||||
|
|||||||
105
wmfs2/src/wmfs.c
105
wmfs2/src/wmfs.c
@ -3,6 +3,9 @@
|
|||||||
* For license, see COPYING.
|
* For license, see COPYING.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
#include <X11/cursorfont.h>
|
||||||
|
|
||||||
#include "wmfs.h"
|
#include "wmfs.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
|
||||||
@ -68,11 +71,14 @@ wmfs_xinit(void)
|
|||||||
W->gc = DefaultGC(W->dpy, W->xscreen);
|
W->gc = DefaultGC(W->dpy, W->xscreen);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Root window
|
* Root window/cursor
|
||||||
*/
|
*/
|
||||||
W->root = RootWindow(dpy, W->xscreen);
|
W->root = RootWindow(W->dpy, W->xscreen);
|
||||||
|
|
||||||
at.event_mask = KeyMask | ButtonMask | MouseMask | PropertyChangeMask
|
at.event_mask = KeyMask | ButtonMask | MouseMask | PropertyChangeMask
|
||||||
| SubstructureRedirectMask | SubstructureNotifyMask | StructureNotifyMask;
|
| SubstructureRedirectMask | SubstructureNotifyMask | StructureNotifyMask;
|
||||||
|
at.cursor = XCreateFontCursor(W->dpy, XC_left_ptr);
|
||||||
|
|
||||||
XChangeWindowAttributes(W->dpy, W->root, CWEventMask | CWCursor, &at);
|
XChangeWindowAttributes(W->dpy, W->root, CWEventMask | CWCursor, &at);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -85,9 +91,9 @@ wmfs_xinit(void)
|
|||||||
XExtentsOfFontSet(W->font.fontset);
|
XExtentsOfFontSet(W->font.fontset);
|
||||||
XFontsOfFontSet(W->font.fontset, &xfs, &names);
|
XFontsOfFontSet(W->font.fontset, &xfs, &names);
|
||||||
|
|
||||||
font.as = xfs[0]->max_bounds.ascent;
|
W->font.as = xfs[0]->max_bounds.ascent;
|
||||||
font.de = xfs[0]->max_bounds.descent;
|
W->font.de = xfs[0]->max_bounds.descent;
|
||||||
font.width = xfs[0]->max_bounds.width;
|
W->font.width = xfs[0]->max_bounds.width;
|
||||||
|
|
||||||
W->font.height = W->font.as + W->font.de;
|
W->font.height = W->font.as + W->font.de;
|
||||||
|
|
||||||
@ -116,16 +122,80 @@ wmfs_grab_keys(void)
|
|||||||
|
|
||||||
XUngrabKey(W->dpy, AnyKey, AnyModifier, W->root);
|
XUngrabKey(W->dpy, AnyKey, AnyModifier, W->root);
|
||||||
|
|
||||||
FOREACH(k, &W->h.keybind, next)
|
SLIST_FOREACH(k, &W->h.keybind, next)
|
||||||
if((c = XKeysymToKeycode(dpy, k->keysym)))
|
if((c = XKeysymToKeycode(W->dpy, k->keysym)))
|
||||||
{
|
{
|
||||||
XGrabKey(W->dpy, c, k->mod, W->root, True, GrabModeAsync, GrabModeAsync);
|
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 | LockMask, W->root, True, GrabModeAsync, GrabModeAsync);
|
||||||
XGrabKey(W->dpy, c, k->mod | numlockmask, W->root, True, GrabModeAsync, GrabModeAsync);
|
XGrabKey(W->dpy, c, k->mod | W->numlockmask, W->root, True, GrabModeAsync, GrabModeAsync);
|
||||||
XGrabKey(W->dpy, c, k->mod | LockMask | numlockmask, W->root, True, GrabModeAsync, GrabModeAsync);
|
XGrabKey(W->dpy, c, k->mod | LockMask | W->numlockmask, W->root, True, GrabModeAsync, GrabModeAsync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Scan if there are windows on X
|
||||||
|
* for manage it
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
wmfs_scan(void)
|
||||||
|
{
|
||||||
|
int i, n;
|
||||||
|
XWindowAttributes wa;
|
||||||
|
Window usl, usl2, *w = NULL;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Atom rt;
|
||||||
|
int s, rf, tag = -1, screen = -1, flags = -1, i;
|
||||||
|
ulong ir, il;
|
||||||
|
uchar *ret;
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(XQueryTree(W->dpy, W->root, &usl, &usl2, &w, &n))
|
||||||
|
for(i = n - 1; i != -1; --i)
|
||||||
|
{
|
||||||
|
XGetWindowAttributes(W->dpy, w[i], &wa);
|
||||||
|
|
||||||
|
if(!wa.override_redirect && wa.map_state == IsViewable)
|
||||||
|
{/*
|
||||||
|
if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_TAG"), 0, 32,
|
||||||
|
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
|
||||||
|
{
|
||||||
|
tag = *ret;
|
||||||
|
XFree(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_SCREEN"), 0, 32,
|
||||||
|
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
|
||||||
|
{
|
||||||
|
screen = *ret;
|
||||||
|
XFree(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_FLAGS"), 0, 32,
|
||||||
|
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
|
||||||
|
{
|
||||||
|
flags = *ret;
|
||||||
|
XFree(ret);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*c = */ client_new(w[i], &wa);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(tag != -1)
|
||||||
|
c->tag = tag;
|
||||||
|
if(screen != -1)
|
||||||
|
c->screen = screen;
|
||||||
|
if(flags != -1)
|
||||||
|
c->flags = flags;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XFree(w);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wmfs_loop(void)
|
wmfs_loop(void)
|
||||||
{
|
{
|
||||||
@ -134,10 +204,9 @@ wmfs_loop(void)
|
|||||||
W->running = true;
|
W->running = true;
|
||||||
|
|
||||||
while(W->running)
|
while(W->running)
|
||||||
while(XPending(W->dpy))
|
|
||||||
{
|
{
|
||||||
XNextEvent(W->dpy, &ev);
|
XNextEvent(W->dpy, &ev);
|
||||||
HANDLE_EVENT(&e);
|
HANDLE_EVENT(&ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,6 +216,9 @@ wmfs_init(void)
|
|||||||
/* X init */
|
/* X init */
|
||||||
wmfs_xinit();
|
wmfs_xinit();
|
||||||
|
|
||||||
|
/* EWMH init */
|
||||||
|
ewmh_init();
|
||||||
|
|
||||||
/* Event init */
|
/* Event init */
|
||||||
event_init();
|
event_init();
|
||||||
|
|
||||||
@ -161,12 +233,14 @@ wmfs_quit(void)
|
|||||||
W->running = false;
|
W->running = false;
|
||||||
|
|
||||||
/* X stuffs */
|
/* X stuffs */
|
||||||
XCloseDisplay(W->dpy);
|
XFreeGC(W->dpy, W->gc);
|
||||||
XFreeGC(W->gc);
|
XFreeFontSet(W->dpy, W->font.fontset);
|
||||||
XFreeFontSet(dpy, W->font.fontset);
|
|
||||||
|
|
||||||
screen_free();
|
screen_free();
|
||||||
|
|
||||||
|
XCloseDisplay(W->dpy);
|
||||||
|
|
||||||
|
free(W->net_atom);
|
||||||
free(W);
|
free(W);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +248,7 @@ wmfs_quit(void)
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
W = xcalloc(1, sizeof(Wmfs));
|
W = (struct Wmfs*)xcalloc(1, sizeof(struct Wmfs));
|
||||||
|
|
||||||
/* Get X display */
|
/* Get X display */
|
||||||
if(!(W->dpy = XOpenDisplay(NULL)))
|
if(!(W->dpy = XOpenDisplay(NULL)))
|
||||||
@ -187,6 +261,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Core */
|
/* Core */
|
||||||
wmfs_init();
|
wmfs_init();
|
||||||
|
wmfs_scan();
|
||||||
|
|
||||||
wmfs_loop();
|
wmfs_loop();
|
||||||
|
|
||||||
|
|||||||
@ -22,9 +22,6 @@
|
|||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
/* Local */
|
/* Local */
|
||||||
#include "screen.h"
|
|
||||||
#include "client.h"
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#define ButtonMask (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
|
#define ButtonMask (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
|
||||||
#define MouseMask (ButtonMask | PointerMotionMask)
|
#define MouseMask (ButtonMask | PointerMotionMask)
|
||||||
@ -33,12 +30,63 @@
|
|||||||
typedef unsigned int Flags;
|
typedef unsigned int Flags;
|
||||||
typedef const char* Uicb;
|
typedef const char* Uicb;
|
||||||
|
|
||||||
typedef struct
|
/*
|
||||||
|
* Structures
|
||||||
|
*/
|
||||||
|
typedef struct Geo Geo;
|
||||||
|
typedef struct Scr33n Scr33n;
|
||||||
|
typedef struct Tag Tag;
|
||||||
|
typedef struct Client Client;
|
||||||
|
typedef struct Keybind Keybind;
|
||||||
|
|
||||||
|
struct Geo
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
} Geo;
|
};
|
||||||
|
|
||||||
typedef struct
|
/* Screen */
|
||||||
|
struct Scr33n
|
||||||
|
{
|
||||||
|
Geo geo;
|
||||||
|
Tag *seltag;
|
||||||
|
SLIST_HEAD(, Tag) tags;
|
||||||
|
SLIST_ENTRY(Scr33n) next;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Tag */
|
||||||
|
struct Tag
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
Scr33n *screen;
|
||||||
|
Flags flags;
|
||||||
|
Client *sel;
|
||||||
|
SLIST_ENTRY(Tag) next;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Client */
|
||||||
|
struct Client
|
||||||
|
{
|
||||||
|
Tag *tag;
|
||||||
|
Scr33n *screen;
|
||||||
|
Geo geo;
|
||||||
|
Flags flags;
|
||||||
|
char *title;
|
||||||
|
Window win;
|
||||||
|
SLIST_ENTRY(Client) next;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Config */
|
||||||
|
struct Keybind
|
||||||
|
{
|
||||||
|
unsigned int mod;
|
||||||
|
KeySym keysym;
|
||||||
|
void (*func)(Uicb);
|
||||||
|
Uicb cmd;
|
||||||
|
SLIST_ENTRY(Keybind) next;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Global struct */
|
||||||
|
struct Wmfs
|
||||||
{
|
{
|
||||||
/* X11 stuffs */
|
/* X11 stuffs */
|
||||||
bool running;
|
bool running;
|
||||||
@ -47,6 +95,7 @@ typedef struct
|
|||||||
int xscreen;
|
int xscreen;
|
||||||
Flags numlockmask;
|
Flags numlockmask;
|
||||||
GC gc;
|
GC gc;
|
||||||
|
Atom *net_atom;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@ -57,7 +106,7 @@ typedef struct
|
|||||||
/* Lists heads */
|
/* Lists heads */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
SLIST_HEAD(, Screen) screen;
|
SLIST_HEAD(, Scr33n) screen;
|
||||||
SLIST_HEAD(, Client) client;
|
SLIST_HEAD(, Client) client;
|
||||||
SLIST_HEAD(, Keybind) keybind;
|
SLIST_HEAD(, Keybind) keybind;
|
||||||
} h;
|
} h;
|
||||||
@ -66,9 +115,9 @@ typedef struct
|
|||||||
* Selected screen, from what you go everywhere; selected tag,
|
* Selected screen, from what you go everywhere; selected tag,
|
||||||
* and then selected client.
|
* and then selected client.
|
||||||
*/
|
*/
|
||||||
Screen *screen;
|
Scr33n *screen;
|
||||||
|
|
||||||
} Wmfs;
|
};
|
||||||
|
|
||||||
int wmfs_error_handler(Display *d, XErrorEvent *event);
|
int wmfs_error_handler(Display *d, XErrorEvent *event);
|
||||||
int wmfs_error_handler_dummy(Display *d, XErrorEvent *event);
|
int wmfs_error_handler_dummy(Display *d, XErrorEvent *event);
|
||||||
@ -76,6 +125,6 @@ void wmfs_grab_keys(void);
|
|||||||
void wmfs_quit(void);
|
void wmfs_quit(void);
|
||||||
|
|
||||||
/* Single global variable */
|
/* Single global variable */
|
||||||
Wmfs *W;
|
struct Wmfs *W;
|
||||||
|
|
||||||
#endif /* WMFS_H */
|
#endif /* WMFS_H */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user