Merge branch 'master' of ssh://git.naquadah.org/var/cache/git/awesome

This commit is contained in:
Julien Danjou 2008-03-07 09:14:33 +01:00
commit af04238204
7 changed files with 110 additions and 72 deletions

View File

@ -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
* is already running.
* \param disp Display
@ -223,12 +185,14 @@ main(int argc, char *argv[])
const char *confpath = NULL;
int r, xfd, e_dummy, csfd, shape_event, randr_event_base, i, screen, opt;
ssize_t cmdlen = 1;
Statusbar *statusbar;
fd_set rd;
XEvent ev;
Display * dpy;
event_handler **handler;
struct sockaddr_un *addr;
Client *c;
XSetWindowAttributes wa;
static struct option long_options[] =
{
{"help", 0, NULL, 'h'},
@ -306,18 +270,42 @@ main(int argc, char *argv[])
/* parse config */
config_parse(confpath);
/* scan existing windows */
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(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 */
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);
/* call this to at least grab root window clicks */
window_root_grabbuttons(screen);
window_root_grabkeys(screen);
}
handler = p_new(event_handler *, LASTEvent);

25
event.c
View File

@ -360,7 +360,7 @@ event_handle_mappingnotify(XEvent *e)
XRefreshKeyboardMapping(ev);
if(ev->request == MappingKeyboard)
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
grabkeys(get_phys_screen(screen));
window_root_grabkeys(screen);
}
/** Handle XMapRequest events
@ -473,27 +473,4 @@ event_handle_clientmessage(XEvent *e)
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

View File

@ -26,8 +26,6 @@
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | LockMask))
void grabkeys(int);
void event_handle_buttonpress(XEvent *);
void event_handle_configurerequest(XEvent *);
void event_handle_configurenotify(XEvent *);

View File

@ -86,6 +86,9 @@ arrange(int screen)
globalconf.screens[screen].need_arrange = False;
}
/** Refresh the screen disposition
* \return true if the screen was arranged, false otherwise
*/
int
layout_refresh(void)
{
@ -102,6 +105,10 @@ layout_refresh(void)
return arranged;
}
/** Get current layout used on screen
* \param screen screen id
* \return layout used on that screen
*/
Layout *
layout_get_current(int screen)
{

View File

@ -1,7 +1,7 @@
/*
* 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>
*
* This program is free software; you can redistribute it and/or modify
@ -28,6 +28,11 @@ extern AwesomeConf globalconf;
#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
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
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;
}
/** 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 *
widget_find(char *name, int screen)
{
@ -90,6 +106,11 @@ widget_find(char *name, int screen)
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
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
widget_common_tell(Widget *widget, char *command __attribute__ ((unused)))
{
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
widget_common_new(Widget *widget, Statusbar *statusbar, cfg_t *config)
{
const char *name;
widget->statusbar = statusbar;
name = cfg_title(config);
widget->name = a_strdup(name);
widget->name = a_strdup(cfg_title(config));
widget->tell = widget_common_tell;
widget->button_press = widget_common_button_press;
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);
}
/** 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
widget_invalidate_cache(int screen, int flags)
{

View File

@ -27,7 +27,7 @@
extern AwesomeConf globalconf;
/** Mask shorthands, used in event.c and window.c */
/** Mask shorthands */
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
/** Set client WM_STATE property
@ -67,6 +67,12 @@ window_getstate(Window w)
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
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));
}
/** Grab buttons on root window
* \param phys_screen physical screen id
*/
void
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
window_setshape(int screen, Window win)
{

View File

@ -29,6 +29,7 @@ long window_getstate(Window);
Status window_configure(Window, Area, int);
void window_grabbuttons(int, Window);
void window_root_grabbuttons(int);
void window_root_grabkeys(int);
void window_setshape(int, Window);
int window_settrans(Window, double);