add XShape support

This commit is contained in:
Julien Danjou 2007-09-13 15:57:35 +02:00
parent 4925ff0c7a
commit c8abcf33fb
7 changed files with 44 additions and 5 deletions

View File

@ -29,6 +29,7 @@
#include <X11/Xatom.h>
#include <X11/Xproto.h>
#include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#include "awesome.h"
#include "event.h"
@ -270,12 +271,13 @@ int
main(int argc, char *argv[])
{
char *p;
int r, xfd;
int r, xfd, e_dummy;
fd_set rd;
XEvent ev;
Display * dpy;
Window root;
awesome_config awesomeconf;
int shape_event;
if(argc == 2 && !strcmp("-v", argv[1]))
eprint("awesome-" VERSION " © 2007 Julien Danjou\n");
@ -301,8 +303,6 @@ main(int argc, char *argv[])
parse_config(dpy, DefaultScreen(dpy), &dc, &awesomeconf);
setup(dpy, &dc, &awesomeconf);
drawstatus(dpy, &dc, &awesomeconf);
scan(dpy, &dc, &awesomeconf);
XSync(dpy, False);
void (*handler[LASTEvent]) (XEvent *, awesome_config *) =
{
@ -317,9 +317,15 @@ main(int argc, char *argv[])
[MappingNotify] = handle_event_mappingnotify,
[MapRequest] = handle_event_maprequest,
[PropertyNotify] = handle_event_propertynotify,
[UnmapNotify] = handle_event_unmapnotify
[UnmapNotify] = handle_event_unmapnotify,
};
/* check for shape extension */
if((awesomeconf.have_shape = XShapeQueryExtension(dpy, &shape_event, &e_dummy)))
handler[shape_event] = handle_event_shape;
scan(dpy, &dc, &awesomeconf);
XSync(dpy, False);
/* main event loop, also reads status text from stdin */
while(running)

View File

@ -22,6 +22,7 @@
#include <stdio.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#include "awesome.h"
#include "layout.h"
@ -391,6 +392,11 @@ manage(Display * disp, DC *drawcontext, Window w, XWindowAttributes * wa, awesom
configure(c); /* propagates border_width, if size doesn't change */
updatesizehints(c);
XSelectInput(disp, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
if(awesomeconf->have_shape)
{
XShapeSelectInput(disp, w, ShapeNotifyMask);
set_shape(c);
}
grabbuttons(c, False, awesomeconf->modkey, awesomeconf->numlockmask);
updatetitle(c);
if((rettrans = XGetTransientForHint(disp, w, &trans) == Success))
@ -637,6 +643,17 @@ updatesizehints(Client * c)
&& c->maxw == c->minw && c->maxh == c->minh);
}
void
set_shape(Client *c)
{
int bounding_shaped;
int i, b; unsigned int u; /* dummies */
/* Logic to decide if we have a shaped window cribbed from fvwm-2.5.10. */
if (XShapeQueryExtents(c->display, c->win, &bounding_shaped, &i, &i,
&u, &u, &b, &i, &i, &u, &u) && bounding_shaped)
XShapeCombineShape(c->display, DefaultRootWindow(c->display), ShapeBounding, 0, 0, c->win, ShapeBounding, ShapeSet);
}
void
uicb_settrans(Display *disp __attribute__ ((unused)),
DC *drawcontext __attribute__ ((unused)),

View File

@ -60,6 +60,7 @@ void unmanage(Client *, DC *, long, awesome_config *); /* unmanage c */
void updatesizehints(Client *); /* update the size hint variables of c */
void updatetitle(Client *); /* update the name of c */
void saveprops(Client * c, int); /* saves client properties */
void set_shape(Client *);
void uicb_killclient(Display *, DC *, awesome_config *, const char *); /* kill client */
void uicb_moveresize(Display *, DC *, awesome_config *, const char *); /* move and resize window */
void uicb_settrans(Display *, DC *, awesome_config *, const char *);

View File

@ -139,6 +139,8 @@ struct awesome_config
Layout * current_layout;
/** Status bar */
Statusbar statusbar;
/** Check for XShape extension */
Bool have_shape;
};
void parse_config(Display *, int, DC *, awesome_config *); /* parse configuration file */

View File

@ -15,7 +15,7 @@ X11LIB = /usr/lib/X11
# includes and libs
INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags libconfig`
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfig`
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfig` -lXext
# flags
CFLAGS = -fgnu89-inline -std=gnu99 -ggdb3 -pipe -Wall -Wextra -W -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wuninitialized -Winit-self -Wpointer-arith -Wredundant-decls -Wno-format-zero-length -Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn -O2 ${INCS} -DVERSION=\"${VERSION}\"

12
event.c
View File

@ -22,6 +22,7 @@
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#include "awesome.h"
#include "event.h"
@ -389,6 +390,17 @@ handle_event_unmapnotify(XEvent * e, awesome_config *awesomeconf)
unmanage(c, &dc, WithdrawnState, awesomeconf);
}
void
handle_event_shape(XEvent * e,
awesome_config *awesomeconf __attribute__ ((unused)))
{
XShapeEvent *ev = (XShapeEvent *) e;
Client *c = getclient(ev->window);
if(c)
set_shape(c);
}
void
grabkeys(Display *disp, awesome_config *awesomeconf)
{

View File

@ -38,5 +38,6 @@ void handle_event_mappingnotify(XEvent *, awesome_config *);
void handle_event_maprequest(XEvent *, awesome_config *);
void handle_event_propertynotify(XEvent *, awesome_config *);
void handle_event_unmapnotify(XEvent *, awesome_config *);
void handle_event_shape(XEvent *, awesome_config *);
#endif