add barwin
This commit is contained in:
parent
861110c5a3
commit
e028c2aca5
105
wmfs2/src/barwin.c
Executable file
105
wmfs2/src/barwin.c
Executable file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
|
||||
* For license, see COPYING.
|
||||
*/
|
||||
|
||||
#include "wmfs.h"
|
||||
#include "barwin.h"
|
||||
#include "util.h"
|
||||
|
||||
/** Create a Barwin
|
||||
* \param parent Parent window of the BarWindow
|
||||
* \param x X position
|
||||
* \param y Y position
|
||||
* \param w Barwin Width
|
||||
* \param h Barwin Height
|
||||
* \param color Barwin color
|
||||
* \param entermask bool for know if the EnterMask mask is needed
|
||||
* \return The BarWindow pointer
|
||||
*/
|
||||
Barwin*
|
||||
barwin_new(Window parent, int x, int y, int w, int h, Color fg, Color bg, bool entermask)
|
||||
{
|
||||
Barwin *b;
|
||||
XSetWindowAttributes at =
|
||||
{
|
||||
.override_redirect = True,
|
||||
.background_pixmap = ParentRelative,
|
||||
.event_mask = BARWIN_MASK
|
||||
};
|
||||
|
||||
b = (Barwin*)xcalloc(1, sizeof(Barwin));
|
||||
|
||||
if(entermask)
|
||||
at.event_mask |= BARWIN_ENTERMASK;
|
||||
|
||||
/* Create window */
|
||||
b->win = XCreateWindow(W->dpy, parent, x, y, w, h, 0, W->xdepth, CopyFromParent,
|
||||
DefaultVisual(W->dpy, W->xscreen), BARWIN_WINCW, &at);
|
||||
|
||||
b->dr = XCreatePixmap(W->dpy, parent, w, h, W->xdepth);
|
||||
|
||||
/* Property */
|
||||
b->geo.x = x;
|
||||
b->geo.y = y;
|
||||
b->geo.w = w;
|
||||
b->geo.h = h;
|
||||
b->bg = bg;
|
||||
b->fg = fg;
|
||||
|
||||
/* Attach */
|
||||
SLIST_INSERT_HEAD(&W->h.barwin, b, next);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
/** Delete a Barwin
|
||||
* \param bw Barwin pointer
|
||||
*/
|
||||
void
|
||||
barwin_remove(Barwin *b)
|
||||
{
|
||||
SLIST_REMOVE(&W->h.barwin, b, Barwin, next);
|
||||
|
||||
XSelectInput(W->dpy, b->win, NoEventMask);
|
||||
XDestroyWindow(W->dpy, b->win);
|
||||
XFreePixmap(W->dpy, b->dr);
|
||||
|
||||
free(b);
|
||||
}
|
||||
|
||||
/** Resize a Barwin
|
||||
* \param bw Barwin pointer
|
||||
* \param w Width
|
||||
* \param h Height
|
||||
*/
|
||||
void
|
||||
barwin_resize(Barwin *b, int w, int h)
|
||||
{
|
||||
if(b->geo.w == w && b->geo.h == h)
|
||||
return;
|
||||
|
||||
/* Frame */
|
||||
XFreePixmap(W->dpy, b->dr);
|
||||
|
||||
b->dr = XCreatePixmap(W->dpy, W->root, w, h, W->xdepth);
|
||||
|
||||
b->geo.w = w;
|
||||
b->geo.h = h;
|
||||
|
||||
XResizeWindow(W->dpy, b->win, w, h);
|
||||
}
|
||||
|
||||
|
||||
/** Refresh the Barwin Color
|
||||
* \param bw Barwin pointer
|
||||
*/
|
||||
void
|
||||
barwin_refresh_color(Barwin *b)
|
||||
{
|
||||
XSetForeground(W->dpy, W->gc, b->bg);
|
||||
XFillRectangle(W->dpy, b->dr, W->gc, 0, 0, b->geo.w, b->geo.h);
|
||||
}
|
||||
|
||||
|
||||
|
||||
31
wmfs2/src/barwin.h
Executable file
31
wmfs2/src/barwin.h
Executable file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
|
||||
* For license, see COPYING.
|
||||
*/
|
||||
|
||||
#ifndef BARWIN_H
|
||||
#define BARWIN_H
|
||||
|
||||
#include "wmfs.h"
|
||||
|
||||
#define BARWIN_MASK \
|
||||
(SubstructureRedirectMask | SubstructureNotifyMask \
|
||||
| ButtonMask | MouseMask | ExposureMask | VisibilityChangeMask \
|
||||
| StructureNotifyMask | SubstructureRedirectMask)
|
||||
|
||||
#define BARWIN_ENTERMASK (EnterWindowMask | LeaveWindowMask | FocusChangeMask)
|
||||
#define BARWIN_WINCW (CWOverrideRedirect | CWBackPixmap | CWEventMask)
|
||||
|
||||
#define barwin_delete_subwin(b) XDestroySubwindows(W->dpy, b->win)
|
||||
#define barwin_map_subwin(b) XMapSubwindows(W->dpy, b->win)
|
||||
#define barwin_unmap_subwin(b) XUnmapSubwindows(W->dpy, b->win)
|
||||
#define barwin_refresh(b) XCopyArea(W->dpy, b->dr, b->win, W->gc, 0, 0, b->geo.w, b->geo.h, 0, 0)
|
||||
#define barwin_map(b) XMapWindow(W->dpy, b->win);
|
||||
#define barwin_unmap(b) XUnmapWindow(W->dpy, b->win);
|
||||
|
||||
Barwin* barwin_new(Window parent, int x, int y, int w, int h, Color fg, Color bg, bool entermask);
|
||||
void barwin_remove(Barwin *b);
|
||||
void barwin_resize(Barwin *b, int w, int h);
|
||||
void barwin_refresh_color(Barwin *b);
|
||||
|
||||
#endif /* BARWIN_H */
|
||||
@ -61,8 +61,6 @@ client_unmap(Client *c)
|
||||
void
|
||||
client_focus(Client *c)
|
||||
{
|
||||
puts("foc");
|
||||
|
||||
/* Unfocus selected */
|
||||
if(c->tag->sel && c->tag->sel != c)
|
||||
{
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
#include "wmfs.h"
|
||||
#include "event.h"
|
||||
#include "util.h"
|
||||
|
||||
int
|
||||
wmfs_error_handler(Display *d, XErrorEvent *event)
|
||||
@ -68,6 +69,7 @@ wmfs_xinit(void)
|
||||
* X var
|
||||
*/
|
||||
W->xscreen = DefaultScreen(W->dpy);
|
||||
W->xdepth = DefaultDepth(W->dpy, W->xscreen);
|
||||
W->gc = DefaultGC(W->dpy, W->xscreen);
|
||||
|
||||
/*
|
||||
|
||||
@ -28,12 +28,14 @@
|
||||
#define KeyMask (KeyPressMask | KeyReleaseMask)
|
||||
|
||||
typedef unsigned int Flags;
|
||||
typedef unsigned int Color;
|
||||
typedef const char* Uicb;
|
||||
|
||||
/*
|
||||
* Structures
|
||||
*/
|
||||
typedef struct Geo Geo;
|
||||
typedef struct Barwin Barwin;
|
||||
typedef struct Scr33n Scr33n;
|
||||
typedef struct Tag Tag;
|
||||
typedef struct Client Client;
|
||||
@ -44,6 +46,17 @@ struct Geo
|
||||
int x, y, w, h;
|
||||
};
|
||||
|
||||
/* Barwin */
|
||||
struct Barwin
|
||||
{
|
||||
Window win;
|
||||
Drawable dr;
|
||||
Color fg, bg;
|
||||
Geo geo;
|
||||
Flags flags;
|
||||
SLIST_ENTRY(Barwin) next;
|
||||
};
|
||||
|
||||
/* Screen */
|
||||
struct Scr33n
|
||||
{
|
||||
@ -92,7 +105,7 @@ struct Wmfs
|
||||
bool running;
|
||||
Display *dpy;
|
||||
Window root;
|
||||
int xscreen;
|
||||
int xscreen, xdepth;
|
||||
Flags numlockmask;
|
||||
GC gc;
|
||||
Atom *net_atom;
|
||||
@ -109,6 +122,7 @@ struct Wmfs
|
||||
SLIST_HEAD(, Scr33n) screen;
|
||||
SLIST_HEAD(, Client) client;
|
||||
SLIST_HEAD(, Keybind) keybind;
|
||||
SLIST_HEAD(, Barwin) barwin;
|
||||
} h;
|
||||
|
||||
/*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user