Xrandr: Add Xrandr support in event/screen.
This commit is contained in:
parent
8f618c01df
commit
2c8d67ff27
@ -80,7 +80,8 @@ set(LIBRARIES_TO_LINK
|
||||
${X11_LIBRARIES}
|
||||
confuse
|
||||
Xft
|
||||
Xinerama)
|
||||
Xinerama
|
||||
Xrandr)
|
||||
|
||||
target_link_libraries(wmfs ${LIBRARIES_TO_LINK})
|
||||
|
||||
|
||||
20
src/event.c
20
src/event.c
@ -497,6 +497,22 @@ unmapnotify(XUnmapEvent *ev)
|
||||
return;
|
||||
}
|
||||
|
||||
/** Xrandr screen change notify handle event
|
||||
*\ param ev XEvent pointer
|
||||
*/
|
||||
void
|
||||
xrandrnotify(XEvent *ev)
|
||||
{
|
||||
XRRUpdateConfiguration(ev);
|
||||
|
||||
/* Reload WMFS to update the screen(s) geometry changement */
|
||||
quit();
|
||||
for(; argv_global[0] && argv_global[0] == ' '; ++argv_global);
|
||||
execlp(argv_global, argv_global, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Send a client event
|
||||
*\param data Event data
|
||||
*\param atom_name Event atom name
|
||||
@ -548,6 +564,10 @@ getevent(XEvent ev)
|
||||
case UnmapNotify: unmapnotify(&ev.xunmap); break;
|
||||
}
|
||||
|
||||
/* Check Xrandr event */
|
||||
if(ev.type == xrandr_event)
|
||||
xrandrnotify(&ev);
|
||||
|
||||
wait(&st);
|
||||
|
||||
return;
|
||||
|
||||
12
src/init.c
12
src/init.c
@ -60,11 +60,14 @@ void
|
||||
init_font(void)
|
||||
{
|
||||
font = XftFontOpenName(dpy, SCREEN, conf.font);
|
||||
|
||||
if(!font)
|
||||
{
|
||||
fprintf(stderr, "WMFS Error: Cannot initialize font\n");
|
||||
font = XftFontOpenName(dpy, SCREEN, "sans-10");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Init the graphic context
|
||||
@ -99,11 +102,11 @@ init_gc(void)
|
||||
void
|
||||
init_cursor(void)
|
||||
{
|
||||
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||
cursor[CurRightResize] = XCreateFontCursor(dpy, XC_lr_angle);
|
||||
cursor[CurLeftResize] = XCreateFontCursor(dpy, XC_ll_angle);
|
||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||
cursor[CurLeftResize] = XCreateFontCursor(dpy, XC_ll_angle);
|
||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -159,6 +162,7 @@ init_layout(void)
|
||||
|
||||
const func_name_list_t layout_list_tmp[] =
|
||||
{
|
||||
{"tile", tile },
|
||||
{"tile_right", tile },
|
||||
{"tile_left", tile_left },
|
||||
{"tile_top", tile_top },
|
||||
|
||||
@ -63,7 +63,6 @@ screen_get_geo(int s)
|
||||
int barpos = tags[selscreen][seltag[selscreen]].barpos;
|
||||
XRectangle geo;
|
||||
|
||||
|
||||
if(XineramaIsActive(dpy))
|
||||
{
|
||||
XineramaScreenInfo *xsi;
|
||||
@ -159,7 +158,7 @@ screen_get_sel(void)
|
||||
void
|
||||
screen_init_geo(void)
|
||||
{
|
||||
int i, n;
|
||||
int i, n, randr_e, d;
|
||||
XineramaScreenInfo *xsi;
|
||||
|
||||
sgeo = emalloc(screen_count(), sizeof(XRectangle));
|
||||
@ -188,6 +187,12 @@ screen_init_geo(void)
|
||||
spgeo[0].height = MAXH;
|
||||
}
|
||||
|
||||
/* Init Xrandr stuff for event */
|
||||
if(XRRQueryExtension(dpy, &randr_e, &d))
|
||||
xrandr_event = randr_e + RRScreenChangeNotify;
|
||||
else
|
||||
xrandr_event = -1;
|
||||
|
||||
ewmh_set_desktop_geometry();
|
||||
ewmh_set_workarea();
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
|
||||
/* Local headers */
|
||||
#include "config.h"
|
||||
@ -201,6 +202,8 @@ void keypress(XKeyPressedEvent *ev);
|
||||
void mappingnotify(XMappingEvent *ev);
|
||||
void maprequest(XMapRequestEvent *ev);
|
||||
void propertynotify(XPropertyEvent *ev);
|
||||
void unmapnotify(XUnmapEvent *ev);
|
||||
void xrandrnotify(XEvent *ev);
|
||||
void send_client_event(long data[5], char *atom_name);
|
||||
void getevent(XEvent ev);
|
||||
|
||||
@ -334,12 +337,15 @@ XRectangle *sgeo;
|
||||
XRectangle *spgeo;
|
||||
Cursor cursor[CurLast];
|
||||
char *argv_global;
|
||||
int xrandr_event;
|
||||
|
||||
/* Fonts */
|
||||
XftFont *font;
|
||||
|
||||
/* Atoms list */
|
||||
Atom net_atom[net_last];
|
||||
|
||||
/* InfoBar */
|
||||
/* InfoBar/Tags */
|
||||
InfoBar *infobar;
|
||||
Tag **tags;
|
||||
int *seltag;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user