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

View File

@ -22,6 +22,7 @@
#include <stdio.h> #include <stdio.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#include "awesome.h" #include "awesome.h"
#include "layout.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 */ configure(c); /* propagates border_width, if size doesn't change */
updatesizehints(c); updatesizehints(c);
XSelectInput(disp, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); XSelectInput(disp, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
if(awesomeconf->have_shape)
{
XShapeSelectInput(disp, w, ShapeNotifyMask);
set_shape(c);
}
grabbuttons(c, False, awesomeconf->modkey, awesomeconf->numlockmask); grabbuttons(c, False, awesomeconf->modkey, awesomeconf->numlockmask);
updatetitle(c); updatetitle(c);
if((rettrans = XGetTransientForHint(disp, w, &trans) == Success)) if((rettrans = XGetTransientForHint(disp, w, &trans) == Success))
@ -637,6 +643,17 @@ updatesizehints(Client * c)
&& c->maxw == c->minw && c->maxh == c->minh); && 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 void
uicb_settrans(Display *disp __attribute__ ((unused)), uicb_settrans(Display *disp __attribute__ ((unused)),
DC *drawcontext __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 updatesizehints(Client *); /* update the size hint variables of c */
void updatetitle(Client *); /* update the name of c */ void updatetitle(Client *); /* update the name of c */
void saveprops(Client * c, int); /* saves client properties */ 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_killclient(Display *, DC *, awesome_config *, const char *); /* kill client */
void uicb_moveresize(Display *, DC *, awesome_config *, const char *); /* move and resize window */ void uicb_moveresize(Display *, DC *, awesome_config *, const char *); /* move and resize window */
void uicb_settrans(Display *, DC *, awesome_config *, const char *); void uicb_settrans(Display *, DC *, awesome_config *, const char *);

View File

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

View File

@ -15,7 +15,7 @@ X11LIB = /usr/lib/X11
# includes and libs # includes and libs
INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags libconfig` 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 # 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}\" 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/keysym.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#include "awesome.h" #include "awesome.h"
#include "event.h" #include "event.h"
@ -389,6 +390,17 @@ handle_event_unmapnotify(XEvent * e, awesome_config *awesomeconf)
unmanage(c, &dc, WithdrawnState, 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 void
grabkeys(Display *disp, awesome_config *awesomeconf) 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_maprequest(XEvent *, awesome_config *);
void handle_event_propertynotify(XEvent *, awesome_config *); void handle_event_propertynotify(XEvent *, awesome_config *);
void handle_event_unmapnotify(XEvent *, awesome_config *); void handle_event_unmapnotify(XEvent *, awesome_config *);
void handle_event_shape(XEvent *, awesome_config *);
#endif #endif