Merge branch 'master' of ssh://git.naquadah.org/var/cache/git/awesome
This commit is contained in:
commit
af04238204
66
awesome.c
66
awesome.c
|
@ -108,44 +108,6 @@ scan()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Setup everything before running
|
|
||||||
* \param screen Screen number
|
|
||||||
* \todo clean things...
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
setup(int screen)
|
|
||||||
{
|
|
||||||
XSetWindowAttributes wa;
|
|
||||||
Statusbar *statusbar;
|
|
||||||
int phys_screen = get_phys_screen(screen);
|
|
||||||
|
|
||||||
/* init cursors */
|
|
||||||
globalconf.cursor[CurNormal] = XCreateFontCursor(globalconf.display, XC_left_ptr);
|
|
||||||
globalconf.cursor[CurResize] = XCreateFontCursor(globalconf.display, XC_sizing);
|
|
||||||
globalconf.cursor[CurMove] = XCreateFontCursor(globalconf.display, XC_fleur);
|
|
||||||
|
|
||||||
/* select for events */
|
|
||||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
|
||||||
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PointerMotionMask;
|
|
||||||
wa.cursor = globalconf.cursor[CurNormal];
|
|
||||||
|
|
||||||
XChangeWindowAttributes(globalconf.display,
|
|
||||||
RootWindow(globalconf.display, phys_screen),
|
|
||||||
CWEventMask | CWCursor, &wa);
|
|
||||||
|
|
||||||
XSelectInput(globalconf.display,
|
|
||||||
RootWindow(globalconf.display, phys_screen),
|
|
||||||
wa.event_mask);
|
|
||||||
|
|
||||||
grabkeys(phys_screen);
|
|
||||||
|
|
||||||
/* view at least one tag */
|
|
||||||
tag_view(globalconf.screens[screen].tags, True);
|
|
||||||
|
|
||||||
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
|
||||||
statusbar_init(statusbar);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Startup Error handler to check if another window manager
|
/** Startup Error handler to check if another window manager
|
||||||
* is already running.
|
* is already running.
|
||||||
* \param disp Display
|
* \param disp Display
|
||||||
|
@ -223,12 +185,14 @@ main(int argc, char *argv[])
|
||||||
const char *confpath = NULL;
|
const char *confpath = NULL;
|
||||||
int r, xfd, e_dummy, csfd, shape_event, randr_event_base, i, screen, opt;
|
int r, xfd, e_dummy, csfd, shape_event, randr_event_base, i, screen, opt;
|
||||||
ssize_t cmdlen = 1;
|
ssize_t cmdlen = 1;
|
||||||
|
Statusbar *statusbar;
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
Display * dpy;
|
Display * dpy;
|
||||||
event_handler **handler;
|
event_handler **handler;
|
||||||
struct sockaddr_un *addr;
|
struct sockaddr_un *addr;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
XSetWindowAttributes wa;
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
{"help", 0, NULL, 'h'},
|
{"help", 0, NULL, 'h'},
|
||||||
|
@ -306,18 +270,42 @@ main(int argc, char *argv[])
|
||||||
/* parse config */
|
/* parse config */
|
||||||
config_parse(confpath);
|
config_parse(confpath);
|
||||||
|
|
||||||
|
/* scan existing windows */
|
||||||
scan();
|
scan();
|
||||||
|
|
||||||
|
/* init cursors */
|
||||||
|
globalconf.cursor[CurNormal] = XCreateFontCursor(globalconf.display, XC_left_ptr);
|
||||||
|
globalconf.cursor[CurResize] = XCreateFontCursor(globalconf.display, XC_sizing);
|
||||||
|
globalconf.cursor[CurMove] = XCreateFontCursor(globalconf.display, XC_fleur);
|
||||||
|
|
||||||
/* for each virtual screen */
|
/* for each virtual screen */
|
||||||
for(screen = 0; screen < globalconf.nscreen; screen++)
|
for(screen = 0; screen < globalconf.nscreen; screen++)
|
||||||
setup(screen);
|
{
|
||||||
|
/* view at least one tag */
|
||||||
|
tag_view(globalconf.screens[screen].tags, True);
|
||||||
|
|
||||||
|
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
||||||
|
statusbar_init(statusbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select for events */
|
||||||
|
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||||
|
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PointerMotionMask;
|
||||||
|
wa.cursor = globalconf.cursor[CurNormal];
|
||||||
|
|
||||||
/* do this only for real screen */
|
/* do this only for real screen */
|
||||||
for(screen = 0; screen < ScreenCount(dpy); screen++)
|
for(screen = 0; screen < ScreenCount(dpy); screen++)
|
||||||
{
|
{
|
||||||
|
XChangeWindowAttributes(globalconf.display,
|
||||||
|
RootWindow(globalconf.display, screen),
|
||||||
|
CWEventMask | CWCursor, &wa);
|
||||||
|
XSelectInput(globalconf.display,
|
||||||
|
RootWindow(globalconf.display, screen),
|
||||||
|
wa.event_mask);
|
||||||
ewmh_set_supported_hints(screen);
|
ewmh_set_supported_hints(screen);
|
||||||
/* call this to at least grab root window clicks */
|
/* call this to at least grab root window clicks */
|
||||||
window_root_grabbuttons(screen);
|
window_root_grabbuttons(screen);
|
||||||
|
window_root_grabkeys(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
handler = p_new(event_handler *, LASTEvent);
|
handler = p_new(event_handler *, LASTEvent);
|
||||||
|
|
25
event.c
25
event.c
|
@ -360,7 +360,7 @@ event_handle_mappingnotify(XEvent *e)
|
||||||
XRefreshKeyboardMapping(ev);
|
XRefreshKeyboardMapping(ev);
|
||||||
if(ev->request == MappingKeyboard)
|
if(ev->request == MappingKeyboard)
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
||||||
grabkeys(get_phys_screen(screen));
|
window_root_grabkeys(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XMapRequest events
|
/** Handle XMapRequest events
|
||||||
|
@ -473,27 +473,4 @@ event_handle_clientmessage(XEvent *e)
|
||||||
ewmh_process_client_message(&e->xclient);
|
ewmh_process_client_message(&e->xclient);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Grab keys on root window
|
|
||||||
* \param phys_screen physical screen id
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
grabkeys(int phys_screen)
|
|
||||||
{
|
|
||||||
Key *k;
|
|
||||||
|
|
||||||
XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
|
||||||
|
|
||||||
for(k = globalconf.keys; k; k = k->next)
|
|
||||||
if(k->keycode)
|
|
||||||
{
|
|
||||||
XGrabKey(globalconf.display, k->keycode, k->mod,
|
|
||||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
|
||||||
XGrabKey(globalconf.display, k->keycode, k->mod | LockMask,
|
|
||||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
|
||||||
XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask,
|
|
||||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
|
||||||
XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask | LockMask,
|
|
||||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
2
event.h
2
event.h
|
@ -26,8 +26,6 @@
|
||||||
|
|
||||||
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | LockMask))
|
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | LockMask))
|
||||||
|
|
||||||
void grabkeys(int);
|
|
||||||
|
|
||||||
void event_handle_buttonpress(XEvent *);
|
void event_handle_buttonpress(XEvent *);
|
||||||
void event_handle_configurerequest(XEvent *);
|
void event_handle_configurerequest(XEvent *);
|
||||||
void event_handle_configurenotify(XEvent *);
|
void event_handle_configurenotify(XEvent *);
|
||||||
|
|
7
layout.c
7
layout.c
|
@ -86,6 +86,9 @@ arrange(int screen)
|
||||||
globalconf.screens[screen].need_arrange = False;
|
globalconf.screens[screen].need_arrange = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Refresh the screen disposition
|
||||||
|
* \return true if the screen was arranged, false otherwise
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
layout_refresh(void)
|
layout_refresh(void)
|
||||||
{
|
{
|
||||||
|
@ -102,6 +105,10 @@ layout_refresh(void)
|
||||||
return arranged;
|
return arranged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get current layout used on screen
|
||||||
|
* \param screen screen id
|
||||||
|
* \return layout used on that screen
|
||||||
|
*/
|
||||||
Layout *
|
Layout *
|
||||||
layout_get_current(int screen)
|
layout_get_current(int screen)
|
||||||
{
|
{
|
||||||
|
|
46
widget.c
46
widget.c
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* widget.c - widget managing
|
* widget.c - widget managing
|
||||||
*
|
*
|
||||||
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
||||||
* Copyright © 2007 Aldo Cortesi <aldo@nullcube.com>
|
* Copyright © 2007 Aldo Cortesi <aldo@nullcube.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -28,6 +28,11 @@ extern AwesomeConf globalconf;
|
||||||
|
|
||||||
#include "widgetgen.h"
|
#include "widgetgen.h"
|
||||||
|
|
||||||
|
/** Compute widget alignment.
|
||||||
|
* This will process all widget starting at `widget' and will check their
|
||||||
|
* alignment and guess it if set to AlignAuto.
|
||||||
|
* \param widget a linked list of all widgets
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
widget_calculate_alignments(Widget *widget)
|
widget_calculate_alignments(Widget *widget)
|
||||||
{
|
{
|
||||||
|
@ -64,6 +69,12 @@ widget_calculate_alignments(Widget *widget)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Compute offset for drawing the first pixel of a widget.
|
||||||
|
* \param barwidth the statusbar width
|
||||||
|
* \param widgetwidth the widget width
|
||||||
|
* \param alignment the widget alignment on statusbar
|
||||||
|
* \return the x coordinate to draw at
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
widget_calculate_offset(int barwidth, int widgetwidth, int offset, int alignment)
|
widget_calculate_offset(int barwidth, int widgetwidth, int offset, int alignment)
|
||||||
{
|
{
|
||||||
|
@ -76,6 +87,11 @@ widget_calculate_offset(int barwidth, int widgetwidth, int offset, int alignment
|
||||||
return barwidth - offset - widgetwidth;
|
return barwidth - offset - widgetwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Find a widget on a screen by its name
|
||||||
|
* \param name the widget name
|
||||||
|
* \param screen the screen to look into
|
||||||
|
* \return a widget
|
||||||
|
*/
|
||||||
static Widget *
|
static Widget *
|
||||||
widget_find(char *name, int screen)
|
widget_find(char *name, int screen)
|
||||||
{
|
{
|
||||||
|
@ -90,6 +106,11 @@ widget_find(char *name, int screen)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Common function for button press event on widget.
|
||||||
|
* It will look into configuration to find the callback function to call.
|
||||||
|
* \param widget the widget
|
||||||
|
* \param ev the XButtonPressedEvent the widget received
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
widget_common_button_press(Widget *widget, XButtonPressedEvent *ev)
|
widget_common_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
{
|
{
|
||||||
|
@ -103,20 +124,27 @@ widget_common_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Common tell function for widget, which only warn user that widget
|
||||||
|
* cannot be told anything
|
||||||
|
* \param widget the widget
|
||||||
|
* \param command unused argument
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
widget_common_tell(Widget *widget, char *command __attribute__ ((unused)))
|
widget_common_tell(Widget *widget, char *command __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
warn("%s widget does not accept commands.\n", widget->name);
|
warn("%s widget does not accept commands.\n", widget->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Common function for creating a widget
|
||||||
|
* \param widget The allocated widget
|
||||||
|
* \param statusbar the statusbar the widget is on
|
||||||
|
* \param config the cfg_t structure we will parse to set common info
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
widget_common_new(Widget *widget, Statusbar *statusbar, cfg_t* config)
|
widget_common_new(Widget *widget, Statusbar *statusbar, cfg_t *config)
|
||||||
{
|
{
|
||||||
const char *name;
|
|
||||||
|
|
||||||
widget->statusbar = statusbar;
|
widget->statusbar = statusbar;
|
||||||
name = cfg_title(config);
|
widget->name = a_strdup(cfg_title(config));
|
||||||
widget->name = a_strdup(name);
|
|
||||||
widget->tell = widget_common_tell;
|
widget->tell = widget_common_tell;
|
||||||
widget->button_press = widget_common_button_press;
|
widget->button_press = widget_common_button_press;
|
||||||
widget->area.x = cfg_getint(config, "x");
|
widget->area.x = cfg_getint(config, "x");
|
||||||
|
@ -125,6 +153,12 @@ widget_common_new(Widget *widget, Statusbar *statusbar, cfg_t* config)
|
||||||
widget->user_supplied_y = (widget->area.y != (int) 0xffffffff);
|
widget->user_supplied_y = (widget->area.y != (int) 0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Invalidate widgets which should be refresh upon
|
||||||
|
* external modifications. Widget who watch flags will
|
||||||
|
* be set to be refreshed.
|
||||||
|
* \param screen screen id
|
||||||
|
* \param flags cache flags
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
widget_invalidate_cache(int screen, int flags)
|
widget_invalidate_cache(int screen, int flags)
|
||||||
{
|
{
|
||||||
|
|
35
window.c
35
window.c
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
extern AwesomeConf globalconf;
|
extern AwesomeConf globalconf;
|
||||||
|
|
||||||
/** Mask shorthands, used in event.c and window.c */
|
/** Mask shorthands */
|
||||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||||
|
|
||||||
/** Set client WM_STATE property
|
/** Set client WM_STATE property
|
||||||
|
@ -67,6 +67,12 @@ window_getstate(Window w)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Configure a window with its new geometry and border
|
||||||
|
* \param win the X window id
|
||||||
|
* \param geometry the new window geometry
|
||||||
|
* \param border new border size
|
||||||
|
* \return the XSendEvent() status
|
||||||
|
*/
|
||||||
Status
|
Status
|
||||||
window_configure(Window win, Area geometry, int border)
|
window_configure(Window win, Area geometry, int border)
|
||||||
{
|
{
|
||||||
|
@ -119,6 +125,9 @@ window_grabbuttons(int phys_screen, Window win)
|
||||||
XUngrabButton(globalconf.display, AnyButton, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
XUngrabButton(globalconf.display, AnyButton, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Grab buttons on root window
|
||||||
|
* \param phys_screen physical screen id
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
window_root_grabbuttons(int phys_screen)
|
window_root_grabbuttons(int phys_screen)
|
||||||
{
|
{
|
||||||
|
@ -141,6 +150,30 @@ window_root_grabbuttons(int phys_screen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Grab keys on root window
|
||||||
|
* \param phys_screen physical screen id
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
window_root_grabkeys(int phys_screen)
|
||||||
|
{
|
||||||
|
Key *k;
|
||||||
|
|
||||||
|
XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
||||||
|
|
||||||
|
for(k = globalconf.keys; k; k = k->next)
|
||||||
|
if(k->keycode)
|
||||||
|
{
|
||||||
|
XGrabKey(globalconf.display, k->keycode, k->mod,
|
||||||
|
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||||
|
XGrabKey(globalconf.display, k->keycode, k->mod | LockMask,
|
||||||
|
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||||
|
XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask,
|
||||||
|
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||||
|
XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask | LockMask,
|
||||||
|
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_setshape(int screen, Window win)
|
window_setshape(int screen, Window win)
|
||||||
{
|
{
|
||||||
|
|
1
window.h
1
window.h
|
@ -29,6 +29,7 @@ long window_getstate(Window);
|
||||||
Status window_configure(Window, Area, int);
|
Status window_configure(Window, Area, int);
|
||||||
void window_grabbuttons(int, Window);
|
void window_grabbuttons(int, Window);
|
||||||
void window_root_grabbuttons(int);
|
void window_root_grabbuttons(int);
|
||||||
|
void window_root_grabkeys(int);
|
||||||
void window_setshape(int, Window);
|
void window_setshape(int, Window);
|
||||||
int window_settrans(Window, double);
|
int window_settrans(Window, double);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue