Port Awesome to XCB
This commit is contained in:
parent
7e301b5ef2
commit
dafafd077c
22
Makefile.am
22
Makefile.am
|
@ -110,7 +110,12 @@ AWESOME_CFLAGS = -std=gnu99 -pipe \
|
||||||
-Wunused -Winit-self -Wpointer-arith -Wredundant-decls \
|
-Wunused -Winit-self -Wpointer-arith -Wredundant-decls \
|
||||||
-Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn
|
-Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn
|
||||||
endif
|
endif
|
||||||
AM_CPPFLAGS = $(X_CFLAGS) $(pangocairo_CFLAGS) $(confuse_CFLAGS) $(xrandr_CFLAGS) $(xinerama_CFLAGS) $(AWESOME_CFLAGS) $(GTK_CFLAGS) $(imlib2_CFLAGS)
|
AM_CPPFLAGS = $(pangocairo_CFLAGS) $(confuse_CFLAGS) $(AWESOME_CFLAGS) \
|
||||||
|
$(GTK_CFLAGS) $(imlib2_CFLAGS) \
|
||||||
|
$(xcb_CFLAGS) $(xcb_event_CFLAGS) \
|
||||||
|
$(xcb_randr_CFLAGS) $(xcb_xinerama_CFLAGS) $(xcb_shape_CFLAGS) \
|
||||||
|
$(xcb_aux_CFLAGS) $(xcb_atom_CFLAGS) $(xcb_keysyms_CFLAGS) \
|
||||||
|
$(xcb_icccm_CFLAGS)
|
||||||
|
|
||||||
bin_PROGRAMS += awesome
|
bin_PROGRAMS += awesome
|
||||||
awesome_SOURCES = \
|
awesome_SOURCES = \
|
||||||
|
@ -140,10 +145,14 @@ awesome_SOURCES = \
|
||||||
rules.c rules.h \
|
rules.c rules.h \
|
||||||
mouse.c mouse.h \
|
mouse.c mouse.h \
|
||||||
widget.c widget.h \
|
widget.c widget.h \
|
||||||
|
xcb_event_handler.c xcb_event_handler.h \
|
||||||
ewmh.c ewmh.h
|
ewmh.c ewmh.h
|
||||||
awesome_SOURCES += $(LAYOUTS)
|
awesome_SOURCES += $(LAYOUTS)
|
||||||
awesome_SOURCES += $(WIDGETS)
|
awesome_SOURCES += $(WIDGETS)
|
||||||
awesome_LDADD = $(X_LIBS) $(pangocairo_LIBS) $(confuse_LIBS) $(xrandr_LIBS) $(xinerama_LIBS) $(GTK_LIBS) $(imlib2_LIBS)
|
awesome_LDADD = $(pangocairo_LIBS) $(confuse_LIBS) $(xcb_LIBS) $(xcb_event_LIBS) \
|
||||||
|
$(xcb_randr_LIBS) $(xcb_xinerama_LIBS) $(xcb_shape_LIBS) $(xcb_aux_LIBS) \
|
||||||
|
$(xcb_atom_LIBS) $(xcb_keysyms_LIBS) $(xcb_icccm_LIBS) \
|
||||||
|
$(imlib2_LIBS) $(GTK_LIBS)
|
||||||
|
|
||||||
bin_PROGRAMS += awesome-client
|
bin_PROGRAMS += awesome-client
|
||||||
awesome_client_SOURCES = \
|
awesome_client_SOURCES = \
|
||||||
|
@ -160,9 +169,10 @@ awesome_message_SOURCES = \
|
||||||
common/version.h common/version.c \
|
common/version.h common/version.c \
|
||||||
common/configopts.h common/configopts.c \
|
common/configopts.h common/configopts.c \
|
||||||
common/xscreen.h common/xscreen.c \
|
common/xscreen.h common/xscreen.c \
|
||||||
|
common/xutil.h common/xutil.c \
|
||||||
awesome-message.c
|
awesome-message.c
|
||||||
|
awesome_message_LDADD = $(xcb_LIBS) $(xcb_atom_LIBS) $(xcb_keysyms_LIBS) $(xcb_aux_LIBS) \
|
||||||
awesome_message_LDADD = $(X_LIBS) $(pangocairo_LIBS) $(confuse_LIBS) $(xinerama_LIBS) $(GTK_LIBS) $(imlib2_LIBS)
|
$(pangocairo_LIBS) $(confuse_LIBS) $(xcb_xinerama_LIBS) $(imlib2_LIBS) $(GTK_LIBS)
|
||||||
|
|
||||||
bin_PROGRAMS += awesome-menu
|
bin_PROGRAMS += awesome-menu
|
||||||
awesome_menu_SOURCES = \
|
awesome_menu_SOURCES = \
|
||||||
|
@ -173,8 +183,8 @@ awesome_menu_SOURCES = \
|
||||||
common/configopts.h common/configopts.c \
|
common/configopts.h common/configopts.c \
|
||||||
common/xutil.h common/xutil.c \
|
common/xutil.h common/xutil.c \
|
||||||
awesome-menu.c
|
awesome-menu.c
|
||||||
|
awesome_menu_LDADD = $(xcb_LIBS) $(xcb_atom_LIBS) $(xcb_keysyms_LIBS) $(xcb_aux_LIBS) \
|
||||||
awesome_menu_LDADD = $(X_LIBS) $(pangocairo_LIBS) $(confuse_LIBS) $(xinerama_LIBS) $(GTK_LIBS) $(imlib2_LIBS)
|
$(pangocairo_LIBS) $(confuse_LIBS) $(xcb_xinerama_LIBS) $(imlib2_LIBS) $(GTK_LIBS)
|
||||||
|
|
||||||
if HAVE_XMLTO
|
if HAVE_XMLTO
|
||||||
if HAVE_ASCIIDOC
|
if HAVE_ASCIIDOC
|
||||||
|
|
183
awesome-menu.c
183
awesome-menu.c
|
@ -36,7 +36,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <X11/Xutil.h>
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_atom.h>
|
||||||
|
#include <xcb/xcb_keysyms.h>
|
||||||
|
|
||||||
|
/* XKeysymToString() */
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
#include "common/swindow.h"
|
#include "common/swindow.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
@ -47,7 +52,7 @@
|
||||||
|
|
||||||
#define PROGNAME "awesome-menu"
|
#define PROGNAME "awesome-menu"
|
||||||
|
|
||||||
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | LockMask))
|
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | XCB_MOD_MASK_LOCK))
|
||||||
|
|
||||||
/** awesome-menu run status */
|
/** awesome-menu run status */
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -76,7 +81,7 @@ struct item_t
|
||||||
/** Previous and next elems in item_t list */
|
/** Previous and next elems in item_t list */
|
||||||
item_t *prev, *next;
|
item_t *prev, *next;
|
||||||
/** True if the item currently matches */
|
/** True if the item currently matches */
|
||||||
Bool match;
|
bool match;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Destructor for item structure
|
/** Destructor for item structure
|
||||||
|
@ -94,8 +99,10 @@ DO_SLIST(item_t, item, item_delete)
|
||||||
/** awesome-run global configuration structure */
|
/** awesome-run global configuration structure */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/** Display ref */
|
/** Connection ref */
|
||||||
Display *display;
|
xcb_connection_t *connection;
|
||||||
|
/** Default screen number */
|
||||||
|
int default_screen;
|
||||||
/** The window */
|
/** The window */
|
||||||
SimpleWindow *sw;
|
SimpleWindow *sw;
|
||||||
/** The draw contet */
|
/** The draw contet */
|
||||||
|
@ -202,11 +209,11 @@ config_parse(int screen, const char *confpatharg,
|
||||||
&& (cfg_styles = cfg_getsec(cfg_screen, "styles")))
|
&& (cfg_styles = cfg_getsec(cfg_screen, "styles")))
|
||||||
{
|
{
|
||||||
/* Grab default styles */
|
/* Grab default styles */
|
||||||
draw_style_init(globalconf.display, DefaultScreen(globalconf.display),
|
draw_style_init(globalconf.connection, globalconf.default_screen,
|
||||||
cfg_getsec(cfg_styles, "normal"),
|
cfg_getsec(cfg_styles, "normal"),
|
||||||
&globalconf.styles.normal, NULL);
|
&globalconf.styles.normal, NULL);
|
||||||
|
|
||||||
draw_style_init(globalconf.display, DefaultScreen(globalconf.display),
|
draw_style_init(globalconf.connection, globalconf.default_screen,
|
||||||
cfg_getsec(cfg_styles, "focus"),
|
cfg_getsec(cfg_styles, "focus"),
|
||||||
&globalconf.styles.focus, &globalconf.styles.normal);
|
&globalconf.styles.focus, &globalconf.styles.normal);
|
||||||
}
|
}
|
||||||
|
@ -214,11 +221,11 @@ config_parse(int screen, const char *confpatharg,
|
||||||
/* Now grab menu styles if any */
|
/* Now grab menu styles if any */
|
||||||
if(cfg_menu_styles)
|
if(cfg_menu_styles)
|
||||||
{
|
{
|
||||||
draw_style_init(globalconf.display, DefaultScreen(globalconf.display),
|
draw_style_init(globalconf.connection, globalconf.default_screen,
|
||||||
cfg_getsec(cfg_menu_styles, "normal"),
|
cfg_getsec(cfg_menu_styles, "normal"),
|
||||||
&globalconf.styles.normal, NULL);
|
&globalconf.styles.normal, NULL);
|
||||||
|
|
||||||
draw_style_init(globalconf.display, DefaultScreen(globalconf.display),
|
draw_style_init(globalconf.connection, globalconf.default_screen,
|
||||||
cfg_getsec(cfg_menu_styles, "focus"),
|
cfg_getsec(cfg_menu_styles, "focus"),
|
||||||
&globalconf.styles.focus, &globalconf.styles.normal);
|
&globalconf.styles.focus, &globalconf.styles.normal);
|
||||||
}
|
}
|
||||||
|
@ -252,7 +259,7 @@ get_last_word(char *text)
|
||||||
* \param directory directory to look into
|
* \param directory directory to look into
|
||||||
* \return always true
|
* \return always true
|
||||||
*/
|
*/
|
||||||
static Bool
|
static bool
|
||||||
item_list_fill_file(const char *directory)
|
item_list_fill_file(const char *directory)
|
||||||
{
|
{
|
||||||
char *cwd, *home, *user, *filename;
|
char *cwd, *home, *user, *filename;
|
||||||
|
@ -290,7 +297,7 @@ item_list_fill_file(const char *directory)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p_delete(&user);
|
p_delete(&user);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +307,7 @@ item_list_fill_file(const char *directory)
|
||||||
if(!(dir = opendir(cwd)))
|
if(!(dir = opendir(cwd)))
|
||||||
{
|
{
|
||||||
p_delete(&cwd);
|
p_delete(&cwd);
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while((dirinfo = readdir(dir)))
|
while((dirinfo = readdir(dir)))
|
||||||
|
@ -332,11 +339,11 @@ item_list_fill_file(const char *directory)
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
p_delete(&cwd);
|
p_delete(&cwd);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
complete(Bool reverse)
|
complete(bool reverse)
|
||||||
{
|
{
|
||||||
int loop = 2;
|
int loop = 2;
|
||||||
item_t *item = NULL;
|
item_t *item = NULL;
|
||||||
|
@ -390,16 +397,16 @@ compute_match(const char *word)
|
||||||
|
|
||||||
for(item = globalconf.items; item; item = item->next)
|
for(item = globalconf.items; item; item = item->next)
|
||||||
if(!a_strncmp(word, item->data, a_strlen(word)))
|
if(!a_strncmp(word, item->data, a_strlen(word)))
|
||||||
item->match = True;
|
item->match = true;
|
||||||
else
|
else
|
||||||
item->match = False;
|
item->match = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(a_strlen(globalconf.text))
|
if(a_strlen(globalconf.text))
|
||||||
item_list_fill_file(NULL);
|
item_list_fill_file(NULL);
|
||||||
for(item = globalconf.items; item; item = item->next)
|
for(item = globalconf.items; item; item = item->next)
|
||||||
item->match = True;
|
item->match = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +419,7 @@ redraw(void)
|
||||||
{
|
{
|
||||||
item_t *item;
|
item_t *item;
|
||||||
area_t geometry = { 0, 0, 0, 0, NULL, NULL };
|
area_t geometry = { 0, 0, 0, 0, NULL, NULL };
|
||||||
Bool selected_item_is_drawn = False;
|
bool selected_item_is_drawn = false;
|
||||||
int len, prompt_len, x_of_previous_item;
|
int len, prompt_len, x_of_previous_item;
|
||||||
style_t style;
|
style_t style;
|
||||||
|
|
||||||
|
@ -424,7 +431,8 @@ redraw(void)
|
||||||
draw_text(globalconf.ctx, geometry, AlignLeft,
|
draw_text(globalconf.ctx, geometry, AlignLeft,
|
||||||
MARGIN, globalconf.prompt, globalconf.styles.focus);
|
MARGIN, globalconf.prompt, globalconf.styles.focus);
|
||||||
|
|
||||||
len = MARGIN * 2 + draw_textwidth(globalconf.display, globalconf.styles.focus.font, globalconf.prompt);
|
len = MARGIN * 2 + draw_textwidth(globalconf.connection, globalconf.default_screen,
|
||||||
|
globalconf.styles.focus.font, globalconf.prompt);
|
||||||
geometry.x += len;
|
geometry.x += len;
|
||||||
geometry.width -= len;
|
geometry.width -= len;
|
||||||
}
|
}
|
||||||
|
@ -432,7 +440,8 @@ redraw(void)
|
||||||
draw_text(globalconf.ctx, geometry, AlignLeft,
|
draw_text(globalconf.ctx, geometry, AlignLeft,
|
||||||
MARGIN, globalconf.text, globalconf.styles.normal);
|
MARGIN, globalconf.text, globalconf.styles.normal);
|
||||||
|
|
||||||
len = MARGIN * 2 + MAX(draw_textwidth(globalconf.display, globalconf.styles.normal.font, globalconf.text),
|
len = MARGIN * 2 + MAX(draw_textwidth(globalconf.connection, globalconf.default_screen,
|
||||||
|
globalconf.styles.normal.font, globalconf.text),
|
||||||
geometry.width / 20);
|
geometry.width / 20);
|
||||||
geometry.x += len;
|
geometry.x += len;
|
||||||
geometry.width -= len;
|
geometry.width -= len;
|
||||||
|
@ -442,13 +451,14 @@ redraw(void)
|
||||||
if(item->match)
|
if(item->match)
|
||||||
{
|
{
|
||||||
style = item == globalconf.item_selected ? globalconf.styles.focus : globalconf.styles.normal;
|
style = item == globalconf.item_selected ? globalconf.styles.focus : globalconf.styles.normal;
|
||||||
len = MARGIN + draw_textwidth(globalconf.display, style.font, item->data);
|
len = MARGIN + draw_textwidth(globalconf.connection, globalconf.default_screen,
|
||||||
|
style.font, item->data);
|
||||||
if(item == globalconf.item_selected)
|
if(item == globalconf.item_selected)
|
||||||
{
|
{
|
||||||
if(len > geometry.width)
|
if(len > geometry.width)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
selected_item_is_drawn = True;
|
selected_item_is_drawn = true;
|
||||||
}
|
}
|
||||||
draw_text(globalconf.ctx, geometry, AlignLeft,
|
draw_text(globalconf.ctx, geometry, AlignLeft,
|
||||||
MARGIN / 2, item->data, style);
|
MARGIN / 2, item->data, style);
|
||||||
|
@ -466,7 +476,8 @@ redraw(void)
|
||||||
{
|
{
|
||||||
style = item == globalconf.item_selected ? globalconf.styles.focus : globalconf.styles.normal;
|
style = item == globalconf.item_selected ? globalconf.styles.focus : globalconf.styles.normal;
|
||||||
x_of_previous_item = geometry.x;
|
x_of_previous_item = geometry.x;
|
||||||
geometry.width = MARGIN + draw_textwidth(globalconf.display, style.font, item->data);
|
geometry.width = MARGIN + draw_textwidth(globalconf.connection, globalconf.default_screen,
|
||||||
|
style.font, item->data);
|
||||||
geometry.x -= geometry.width;
|
geometry.x -= geometry.width;
|
||||||
|
|
||||||
if(geometry.x < prompt_len)
|
if(geometry.x < prompt_len)
|
||||||
|
@ -480,31 +491,37 @@ redraw(void)
|
||||||
{
|
{
|
||||||
geometry.x = prompt_len;
|
geometry.x = prompt_len;
|
||||||
geometry.width = x_of_previous_item - prompt_len;
|
geometry.width = x_of_previous_item - prompt_len;
|
||||||
draw_rectangle(globalconf.ctx, geometry, 1.0, True, globalconf.styles.normal.bg);
|
draw_rectangle(globalconf.ctx, geometry, 1.0, true, globalconf.styles.normal.bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(geometry.width)
|
else if(geometry.width)
|
||||||
draw_rectangle(globalconf.ctx, geometry, 1.0, True, globalconf.styles.normal.bg);
|
draw_rectangle(globalconf.ctx, geometry, 1.0, true, globalconf.styles.normal.bg);
|
||||||
|
|
||||||
simplewindow_refresh_drawable(globalconf.sw, DefaultScreen(globalconf.display));
|
simplewindow_refresh_drawable(globalconf.sw, globalconf.default_screen);
|
||||||
XSync(globalconf.display, False);
|
xcb_aux_sync(globalconf.connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle keypress event in awesome-menu.
|
/** Handle keypress event in awesome-menu.
|
||||||
* \param e received XKeyEvent
|
* \param e received XKeyEvent
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
handle_kpress(XKeyEvent *e)
|
handle_kpress(xcb_key_press_event_t *e)
|
||||||
{
|
{
|
||||||
char buf[32];
|
char *buf;
|
||||||
KeySym ksym;
|
xcb_key_symbols_t *keysyms = xcb_key_symbols_alloc(globalconf.connection);
|
||||||
|
xcb_keysym_t ksym;
|
||||||
int num;
|
int num;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
size_t text_dst_len;
|
size_t text_dst_len;
|
||||||
|
|
||||||
len = a_strlen(globalconf.text);
|
len = a_strlen(globalconf.text);
|
||||||
num = XLookupString(e, buf, sizeof(buf), &ksym, 0);
|
/* TODO: check whether 'col' (last parameter) is correct */
|
||||||
if(e->state & ControlMask)
|
ksym = xcb_key_press_lookup_keysym(keysyms, e, 1);
|
||||||
|
|
||||||
|
/* TODO: remove this call in favor of XCB */
|
||||||
|
buf = XKeysymToString(ksym);
|
||||||
|
num = strlen(buf);
|
||||||
|
if(e->state & XCB_MOD_MASK_CONTROL)
|
||||||
switch(ksym)
|
switch(ksym)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
@ -543,7 +560,7 @@ handle_kpress(XKeyEvent *e)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(CLEANMASK(e->state) & Mod1Mask)
|
else if(CLEANMASK(e->state) & XCB_MOD_MASK_1)
|
||||||
switch(ksym)
|
switch(ksym)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
@ -590,12 +607,12 @@ handle_kpress(XKeyEvent *e)
|
||||||
break;
|
break;
|
||||||
case XK_ISO_Left_Tab:
|
case XK_ISO_Left_Tab:
|
||||||
case XK_Left:
|
case XK_Left:
|
||||||
complete(True);
|
complete(true);
|
||||||
redraw();
|
redraw();
|
||||||
break;
|
break;
|
||||||
case XK_Right:
|
case XK_Right:
|
||||||
case XK_Tab:
|
case XK_Tab:
|
||||||
complete(False);
|
complete(false);
|
||||||
redraw();
|
redraw();
|
||||||
break;
|
break;
|
||||||
case XK_Escape:
|
case XK_Escape:
|
||||||
|
@ -638,7 +655,7 @@ getline(char ** buf, size_t* len, FILE* in)
|
||||||
/** Fill the completion by reading on stdin.
|
/** Fill the completion by reading on stdin.
|
||||||
* \return true if something has been filled up, false otherwise.
|
* \return true if something has been filled up, false otherwise.
|
||||||
*/
|
*/
|
||||||
static Bool
|
static bool
|
||||||
item_list_fill_stdin(void)
|
item_list_fill_stdin(void)
|
||||||
{
|
{
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
@ -646,12 +663,12 @@ item_list_fill_stdin(void)
|
||||||
ssize_t line_len;
|
ssize_t line_len;
|
||||||
|
|
||||||
item_t *newitem;
|
item_t *newitem;
|
||||||
Bool has_entry = False;
|
bool has_entry = false;
|
||||||
|
|
||||||
item_list_init(&globalconf.items);
|
item_list_init(&globalconf.items);
|
||||||
|
|
||||||
if((line_len = getline(&buf, &len, stdin)) != -1)
|
if((line_len = getline(&buf, &len, stdin)) != -1)
|
||||||
has_entry = True;
|
has_entry = true;
|
||||||
|
|
||||||
if(has_entry)
|
if(has_entry)
|
||||||
do
|
do
|
||||||
|
@ -659,7 +676,7 @@ item_list_fill_stdin(void)
|
||||||
buf[line_len - 1] = '\0';
|
buf[line_len - 1] = '\0';
|
||||||
newitem = p_new(item_t, 1);
|
newitem = p_new(item_t, 1);
|
||||||
newitem->data = a_strdup(buf);
|
newitem->data = a_strdup(buf);
|
||||||
newitem->match = True;
|
newitem->match = true;
|
||||||
item_list_append(&globalconf.items, newitem);
|
item_list_append(&globalconf.items, newitem);
|
||||||
}
|
}
|
||||||
while((line_len = getline(&buf, &len, stdin)) != -1);
|
while((line_len = getline(&buf, &len, stdin)) != -1);
|
||||||
|
@ -676,11 +693,19 @@ static void
|
||||||
keyboard_grab(void)
|
keyboard_grab(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
xcb_grab_keyboard_reply_t *xgb = NULL;
|
||||||
for(i = 1000; i; i--)
|
for(i = 1000; i; i--)
|
||||||
{
|
{
|
||||||
if(XGrabKeyboard(globalconf.display, DefaultRootWindow(globalconf.display), True,
|
if((xgb = xcb_grab_keyboard_reply(globalconf.connection,
|
||||||
GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
|
xcb_grab_keyboard(globalconf.connection, true,
|
||||||
|
xcb_aux_get_screen(globalconf.connection, globalconf.default_screen)->root,
|
||||||
|
XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC,
|
||||||
|
XCB_GRAB_MODE_ASYNC),
|
||||||
|
NULL)) != NULL)
|
||||||
|
{
|
||||||
|
p_delete(&xgb);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
if(!i)
|
if(!i)
|
||||||
|
@ -695,15 +720,14 @@ keyboard_grab(void)
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
xcb_generic_event_t *ev;
|
||||||
int opt, ret, x, y, i, screen = 0;
|
int opt, ret, screen = 0;
|
||||||
|
xcb_query_pointer_reply_t *xqp = NULL;
|
||||||
char *configfile = NULL, *cmd;
|
char *configfile = NULL, *cmd;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
const char *shell = getenv("SHELL");
|
const char *shell = getenv("SHELL");
|
||||||
area_t geometry = { 0, 0, 0, 0, NULL, NULL };
|
area_t geometry = { 0, 0, 0, 0, NULL, NULL };
|
||||||
ScreensInfo *si;
|
ScreensInfo *si;
|
||||||
unsigned int ui;
|
|
||||||
Window dummy;
|
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
{"help", 0, NULL, 'h'},
|
{"help", 0, NULL, 'h'},
|
||||||
|
@ -733,19 +757,24 @@ main(int argc, char **argv)
|
||||||
if(argc - optind >= 1)
|
if(argc - optind >= 1)
|
||||||
globalconf.prompt = a_strdup(argv[optind]);
|
globalconf.prompt = a_strdup(argv[optind]);
|
||||||
|
|
||||||
if(!(globalconf.display = XOpenDisplay(NULL)))
|
globalconf.connection = xcb_connect(NULL, &globalconf.default_screen);
|
||||||
|
if(xcb_connection_has_error(globalconf.connection))
|
||||||
eprint("unable to open display");
|
eprint("unable to open display");
|
||||||
|
|
||||||
/* Get the numlock mask */
|
/* Get the numlock mask */
|
||||||
globalconf.numlockmask = xgetnumlockmask(globalconf.display);
|
globalconf.numlockmask = xgetnumlockmask(globalconf.connection);
|
||||||
|
|
||||||
si = screensinfo_new(globalconf.display);
|
si = screensinfo_new(globalconf.connection);
|
||||||
if(si->xinerama_is_active)
|
if(si->xinerama_is_active)
|
||||||
{
|
{
|
||||||
if(XQueryPointer(globalconf.display, RootWindow(globalconf.display, DefaultScreen(globalconf.display)),
|
if((xqp = xcb_query_pointer_reply(globalconf.connection,
|
||||||
&dummy, &dummy, &x, &y, &i, &i, &ui))
|
xcb_query_pointer(globalconf.connection,
|
||||||
|
root_window(globalconf.connection,
|
||||||
|
globalconf.default_screen)),
|
||||||
|
NULL)) != NULL)
|
||||||
{
|
{
|
||||||
screen = screen_get_bycoord(si, 0, x, y);
|
screen = screen_get_bycoord(si, 0, xqp->root_x, xqp->root_y);
|
||||||
|
p_delete(&xqp);
|
||||||
|
|
||||||
geometry.x = si->geometry[screen].x;
|
geometry.x = si->geometry[screen].x;
|
||||||
geometry.y = si->geometry[screen].y;
|
geometry.y = si->geometry[screen].y;
|
||||||
|
@ -754,9 +783,9 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
screen = DefaultScreen(globalconf.display);
|
screen = globalconf.default_screen;
|
||||||
if(!geometry.width)
|
if(!geometry.width)
|
||||||
geometry.width = DisplayWidth(globalconf.display, DefaultScreen(globalconf.display));
|
geometry.width = xcb_aux_get_screen(globalconf.connection, globalconf.default_screen)->width_in_pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ret = config_parse(screen, configfile, globalconf.prompt, &geometry)))
|
if((ret = config_parse(screen, configfile, globalconf.prompt, &geometry)))
|
||||||
|
@ -770,13 +799,15 @@ main(int argc, char **argv)
|
||||||
screensinfo_delete(&si);
|
screensinfo_delete(&si);
|
||||||
|
|
||||||
/* Create the window */
|
/* Create the window */
|
||||||
globalconf.sw = simplewindow_new(globalconf.display, DefaultScreen(globalconf.display),
|
globalconf.sw = simplewindow_new(globalconf.connection, globalconf.default_screen,
|
||||||
geometry.x, geometry.y, geometry.width, geometry.height, 0);
|
geometry.x, geometry.y, geometry.width, geometry.height, 0);
|
||||||
|
|
||||||
XStoreName(globalconf.display, globalconf.sw->window, PROGNAME);
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||||
|
globalconf.sw->window, WM_NAME, STRING, 8,
|
||||||
|
strlen(PROGNAME), PROGNAME);
|
||||||
|
|
||||||
/* Create the drawing context */
|
/* Create the drawing context */
|
||||||
globalconf.ctx = draw_context_new(globalconf.display, DefaultScreen(globalconf.display),
|
globalconf.ctx = draw_context_new(globalconf.connection, globalconf.default_screen,
|
||||||
geometry.width, geometry.height,
|
geometry.width, geometry.height,
|
||||||
globalconf.sw->drawable);
|
globalconf.sw->drawable);
|
||||||
|
|
||||||
|
@ -804,25 +835,33 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
XMapRaised(globalconf.display, globalconf.sw->window);
|
xutil_map_raised(globalconf.connection, globalconf.sw->window);
|
||||||
|
|
||||||
while(status == RUN)
|
while(status == RUN)
|
||||||
{
|
{
|
||||||
XNextEvent(globalconf.display, &ev);
|
while((ev = xcb_poll_for_event(globalconf.connection)))
|
||||||
switch(ev.type)
|
|
||||||
{
|
{
|
||||||
case ButtonPress:
|
/* Skip errors */
|
||||||
status = CANCEL;
|
if(ev->response_type == 0)
|
||||||
break;
|
continue;
|
||||||
case KeyPress:
|
|
||||||
handle_kpress(&ev.xkey);
|
switch(ev->response_type & 0x7f)
|
||||||
break;
|
{
|
||||||
case Expose:
|
case XCB_BUTTON_PRESS:
|
||||||
if(!ev.xexpose.count)
|
status = CANCEL;
|
||||||
simplewindow_refresh_drawable(globalconf.sw, DefaultScreen(globalconf.display));
|
break;
|
||||||
break;
|
case XCB_KEY_PRESS:
|
||||||
default:
|
handle_kpress((xcb_key_press_event_t *) ev);
|
||||||
break;
|
break;
|
||||||
|
case XCB_EXPOSE:
|
||||||
|
if(!((xcb_expose_event_t *) ev)->count)
|
||||||
|
simplewindow_refresh_drawable(globalconf.sw, globalconf.default_screen);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_delete(&ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -845,7 +884,7 @@ main(int argc, char **argv)
|
||||||
p_delete(&globalconf.text);
|
p_delete(&globalconf.text);
|
||||||
draw_context_delete(&globalconf.ctx);
|
draw_context_delete(&globalconf.ctx);
|
||||||
simplewindow_delete(&globalconf.sw);
|
simplewindow_delete(&globalconf.sw);
|
||||||
XCloseDisplay(globalconf.display);
|
xcb_disconnect(globalconf.connection);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,11 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
#include <xcb/xcb_atom.h>
|
||||||
|
|
||||||
#include "common/swindow.h"
|
#include "common/swindow.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
@ -37,7 +40,7 @@
|
||||||
|
|
||||||
#define PROGNAME "awesome-message"
|
#define PROGNAME "awesome-message"
|
||||||
|
|
||||||
static Bool running = True;
|
static bool running = true;
|
||||||
|
|
||||||
/** Import awesome config file format */
|
/** Import awesome config file format */
|
||||||
extern cfg_opt_t awesome_opts[];
|
extern cfg_opt_t awesome_opts[];
|
||||||
|
@ -46,7 +49,9 @@ extern cfg_opt_t awesome_opts[];
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/** Display ref */
|
/** Display ref */
|
||||||
Display *display;
|
xcb_connection_t *connection;
|
||||||
|
/** Default screen number */
|
||||||
|
int default_screen;
|
||||||
/** Style */
|
/** Style */
|
||||||
style_t style;
|
style_t style;
|
||||||
} AwesomeMsgConf;
|
} AwesomeMsgConf;
|
||||||
|
@ -95,7 +100,7 @@ config_parse(int screen, const char *confpatharg)
|
||||||
eprint("parsing configuration file failed, no screen section found\n");
|
eprint("parsing configuration file failed, no screen section found\n");
|
||||||
|
|
||||||
/* style */
|
/* style */
|
||||||
draw_style_init(globalconf.display, DefaultScreen(globalconf.display),
|
draw_style_init(globalconf.connection, globalconf.default_screen,
|
||||||
cfg_getsec(cfg_getsec(cfg_screen, "styles"), "normal"),
|
cfg_getsec(cfg_getsec(cfg_screen, "styles"), "normal"),
|
||||||
&globalconf.style, NULL);
|
&globalconf.style, NULL);
|
||||||
|
|
||||||
|
@ -110,7 +115,7 @@ config_parse(int screen, const char *confpatharg)
|
||||||
static void
|
static void
|
||||||
exit_on_signal(int sig __attribute__ ((unused)))
|
exit_on_signal(int sig __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
running = False;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -118,14 +123,13 @@ main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
SimpleWindow *sw;
|
SimpleWindow *sw;
|
||||||
DrawCtx *ctx;
|
DrawCtx *ctx;
|
||||||
XEvent ev;
|
xcb_generic_event_t *ev;
|
||||||
area_t geometry = { 0, 0, 200, 50, NULL, NULL },
|
area_t geometry = { 0, 0, 200, 50, NULL, NULL },
|
||||||
icon_geometry = { -1, -1, -1, -1, NULL, NULL };
|
icon_geometry = { -1, -1, -1, -1, NULL, NULL };
|
||||||
int opt, i, x, y, ret, screen = 0, delay = 0;
|
int opt, ret, screen = 0, delay = 0;
|
||||||
unsigned int ui;
|
xcb_query_pointer_reply_t *xqp = NULL;
|
||||||
char *configfile = NULL;
|
char *configfile = NULL;
|
||||||
ScreensInfo *si;
|
ScreensInfo *si;
|
||||||
Window dummy;
|
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
{"help", 0, NULL, 'h'},
|
{"help", 0, NULL, 'h'},
|
||||||
|
@ -161,23 +165,31 @@ main(int argc, char **argv)
|
||||||
if(argc - optind < 1)
|
if(argc - optind < 1)
|
||||||
exit_help(EXIT_FAILURE);
|
exit_help(EXIT_FAILURE);
|
||||||
|
|
||||||
if(!(globalconf.display = XOpenDisplay(NULL)))
|
globalconf.connection = xcb_connect(NULL, &globalconf.default_screen);
|
||||||
|
if(xcb_connection_has_error(globalconf.connection))
|
||||||
eprint("unable to open display");
|
eprint("unable to open display");
|
||||||
|
|
||||||
si = screensinfo_new(globalconf.display);
|
si = screensinfo_new(globalconf.connection);
|
||||||
if(si->xinerama_is_active)
|
if(si->xinerama_is_active)
|
||||||
{
|
{
|
||||||
if(XQueryPointer(globalconf.display, RootWindow(globalconf.display, DefaultScreen(globalconf.display)),
|
if((xqp = xcb_query_pointer_reply(globalconf.connection,
|
||||||
&dummy, &dummy, &x, &y, &i, &i, &ui))
|
xcb_query_pointer(globalconf.connection,
|
||||||
screen = screen_get_bycoord(si, 0, x, y);
|
root_window(globalconf.connection,
|
||||||
|
globalconf.default_screen)),
|
||||||
|
NULL)) != NULL)
|
||||||
|
{
|
||||||
|
screen = screen_get_bycoord(si, 0, xqp->root_x, xqp->root_y);
|
||||||
|
p_delete(&xqp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
screen = DefaultScreen(globalconf.display);
|
screen = globalconf.default_screen;
|
||||||
|
|
||||||
if((ret = config_parse(screen, configfile)))
|
if((ret = config_parse(screen, configfile)))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
geometry.width = draw_textwidth(globalconf.display, globalconf.style.font, argv[optind]);
|
geometry.width = draw_textwidth(globalconf.connection, globalconf.default_screen,
|
||||||
|
globalconf.style.font, argv[optind]);
|
||||||
geometry.height = globalconf.style.font->height * 1.5;
|
geometry.height = globalconf.style.font->height * 1.5;
|
||||||
|
|
||||||
if(argc - optind >= 2)
|
if(argc - optind >= 2)
|
||||||
|
@ -190,12 +202,13 @@ main(int argc, char **argv)
|
||||||
* ((double) globalconf.style.font->height / (double) icon_geometry.height);
|
* ((double) globalconf.style.font->height / (double) icon_geometry.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
sw = simplewindow_new(globalconf.display, DefaultScreen(globalconf.display),
|
sw = simplewindow_new(globalconf.connection, globalconf.default_screen,
|
||||||
geometry.x, geometry.y, geometry.width, geometry.height, 0);
|
geometry.x, geometry.y, geometry.width, geometry.height, 0);
|
||||||
|
|
||||||
XStoreName(globalconf.display, sw->window, PROGNAME);
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, sw->window,
|
||||||
|
WM_NAME, STRING, 8, strlen(PROGNAME), PROGNAME);
|
||||||
|
|
||||||
ctx = draw_context_new(globalconf.display, DefaultScreen(globalconf.display),
|
ctx = draw_context_new(globalconf.connection, globalconf.default_screen,
|
||||||
geometry.width, geometry.height, sw->drawable);
|
geometry.width, geometry.height, sw->drawable);
|
||||||
|
|
||||||
geometry.x = geometry.y = 0;
|
geometry.x = geometry.y = 0;
|
||||||
|
@ -207,36 +220,41 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
p_delete(&ctx);
|
p_delete(&ctx);
|
||||||
|
|
||||||
simplewindow_refresh_drawable(sw, DefaultScreen(globalconf.display));
|
simplewindow_refresh_drawable(sw, globalconf.default_screen);
|
||||||
|
|
||||||
XMapRaised(globalconf.display, sw->window);
|
xutil_map_raised(globalconf.connection, sw->window);
|
||||||
XSync(globalconf.display, False);
|
xcb_aux_sync(globalconf.connection);
|
||||||
|
|
||||||
signal(SIGALRM, &exit_on_signal);
|
signal(SIGALRM, &exit_on_signal);
|
||||||
alarm(delay);
|
alarm(delay);
|
||||||
|
|
||||||
while(running)
|
while(running)
|
||||||
{
|
{
|
||||||
if(XPending(globalconf.display))
|
while((ev = xcb_poll_for_event(globalconf.connection)))
|
||||||
{
|
{
|
||||||
XNextEvent(globalconf.display, &ev);
|
/* Skip errors */
|
||||||
switch(ev.type)
|
if(ev->response_type == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch(ev->response_type & 0x7f)
|
||||||
{
|
{
|
||||||
case ButtonPress:
|
case XCB_BUTTON_PRESS:
|
||||||
case KeyPress:
|
case XCB_KEY_PRESS:
|
||||||
running = False;
|
running = false;
|
||||||
case Expose:
|
case XCB_EXPOSE:
|
||||||
simplewindow_refresh_drawable(sw, DefaultScreen(globalconf.display));
|
simplewindow_refresh_drawable(sw, globalconf.default_screen);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p_delete(&ev);
|
||||||
}
|
}
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
simplewindow_delete(&sw);
|
simplewindow_delete(&sw);
|
||||||
XCloseDisplay(globalconf.display);
|
xcb_disconnect(globalconf.connection);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
394
awesome.c
394
awesome.c
|
@ -33,13 +33,14 @@
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <X11/cursorfont.h>
|
#include <alloca.h>
|
||||||
#include <X11/keysym.h>
|
|
||||||
#include <X11/Xatom.h>
|
#include <xcb/xcb.h>
|
||||||
#include <X11/Xproto.h>
|
#include <xcb/shape.h>
|
||||||
#include <X11/Xutil.h>
|
#include <xcb/randr.h>
|
||||||
#include <X11/extensions/shape.h>
|
#include <xcb/xcb_aux.h>
|
||||||
#include <X11/extensions/Xrandr.h>
|
#include <xcb/xcb_atom.h>
|
||||||
|
#include <xcb/xcb_icccm.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "awesome.h"
|
#include "awesome.h"
|
||||||
|
@ -52,53 +53,174 @@
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
|
#include "xcb_event_handler.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "common/socket.h"
|
#include "common/socket.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "common/version.h"
|
#include "common/version.h"
|
||||||
#include "common/configopts.h"
|
#include "common/configopts.h"
|
||||||
#include "common/xscreen.h"
|
#include "common/xscreen.h"
|
||||||
|
#include "common/xutil.h"
|
||||||
|
|
||||||
static int (*xerrorxlib) (Display *, XErrorEvent *);
|
static bool running = true;
|
||||||
static Bool running = True;
|
|
||||||
|
|
||||||
AwesomeConf globalconf;
|
AwesomeConf globalconf;
|
||||||
|
|
||||||
|
/** Get geometry informations like XCB version, and also set 'x' and
|
||||||
|
* 'y' parameter on its parent window like Xlib does
|
||||||
|
*
|
||||||
|
* TODO: improve round-trip time?
|
||||||
|
*/
|
||||||
|
static xcb_get_geometry_reply_t *
|
||||||
|
x_get_geometry(xcb_connection_t *c, xcb_window_t w, xcb_get_geometry_reply_t *parent)
|
||||||
|
{
|
||||||
|
xcb_get_geometry_reply_t *win_geom;
|
||||||
|
|
||||||
|
win_geom = xcb_get_geometry_reply(c, xcb_get_geometry(c, w), NULL);
|
||||||
|
|
||||||
|
if(win_geom)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Unlike XCB, Xlib set 'x' and 'y' as parent window position */
|
||||||
|
win_geom->x = parent->x;
|
||||||
|
win_geom->y = parent->y;
|
||||||
|
|
||||||
|
return win_geom;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
xcb_get_geometry_cookie_t geom;
|
||||||
|
xcb_query_tree_cookie_t tree;
|
||||||
|
} screen_win_t;
|
||||||
|
|
||||||
/** Scan X to find windows to manage
|
/** Scan X to find windows to manage
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
scan()
|
scan()
|
||||||
{
|
{
|
||||||
unsigned int i, num;
|
unsigned int i;
|
||||||
int screen, real_screen;
|
int screen, real_screen;
|
||||||
Window *wins = NULL, d1, d2;
|
xcb_window_t w;
|
||||||
XWindowAttributes wa;
|
xcb_window_t *wins = NULL;
|
||||||
|
xcb_query_tree_reply_t *r_query_tree;
|
||||||
|
xcb_get_geometry_reply_t *parent_geom, *win_geom;
|
||||||
|
xcb_get_window_attributes_reply_t *reply_win;
|
||||||
|
xcb_get_window_attributes_cookie_t *cookies_win;
|
||||||
|
const int screen_max = xcb_setup_roots_length (xcb_get_setup (globalconf.connection));
|
||||||
|
screen_win_t *parents = alloca(sizeof(screen_win_t) * screen_max);
|
||||||
|
|
||||||
for(screen = 0; screen < ScreenCount(globalconf.display); screen++)
|
for(screen = 0; screen < screen_max; screen++)
|
||||||
{
|
{
|
||||||
if(XQueryTree(globalconf.display, RootWindow(globalconf.display, screen), &d1, &d2, &wins, &num))
|
w = root_window(globalconf.connection, screen);
|
||||||
for(i = 0; i < num; i++)
|
|
||||||
/* XGetWindowAttributes return 1 on success */
|
/* Get parent geometry informations, useful to get the real
|
||||||
if(XGetWindowAttributes(globalconf.display, wins[i], &wa)
|
* coordinates of the window because Xlib set 'x' and 'y'
|
||||||
&& !wa.override_redirect
|
* fields to the relative position within the parent window */
|
||||||
&& (wa.map_state == IsViewable || window_getstate(wins[i]) == IconicState))
|
parents[screen].geom = xcb_get_geometry(globalconf.connection, w);
|
||||||
{
|
|
||||||
real_screen = screen_get_bycoord(globalconf.screens_info, screen, wa.x, wa.y);
|
/* Get the window tree */
|
||||||
client_manage(wins[i], &wa, real_screen);
|
parents[screen].tree = xcb_query_tree_unchecked(globalconf.connection, w);
|
||||||
}
|
|
||||||
if(wins)
|
|
||||||
XFree(wins);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(screen = 0; screen < screen_max; screen++)
|
||||||
|
{
|
||||||
|
parent_geom = xcb_get_geometry_reply (globalconf.connection,
|
||||||
|
parents[screen].geom, NULL);
|
||||||
|
|
||||||
|
if(!parent_geom)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
r_query_tree = xcb_query_tree_reply(globalconf.connection,
|
||||||
|
parents[screen].tree, NULL);
|
||||||
|
|
||||||
|
if(!r_query_tree)
|
||||||
|
{
|
||||||
|
p_delete(&parent_geom);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
wins = xcb_query_tree_children(r_query_tree);
|
||||||
|
|
||||||
|
/* Store the answers of 'xcb_get_window_attributes' for all
|
||||||
|
* child windows */
|
||||||
|
cookies_win = p_new(xcb_get_window_attributes_cookie_t,
|
||||||
|
r_query_tree->children_len);
|
||||||
|
|
||||||
|
/* Send all the requests at the same time */
|
||||||
|
for(i = 0; i < r_query_tree->children_len; i++)
|
||||||
|
cookies_win[i] = xcb_get_window_attributes(globalconf.connection, wins[i]);
|
||||||
|
|
||||||
|
/* Now process the answers */
|
||||||
|
for(i = 0; i < r_query_tree->children_len; i++)
|
||||||
|
{
|
||||||
|
reply_win = xcb_get_window_attributes_reply(globalconf.connection,
|
||||||
|
cookies_win[i],
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if(reply_win && !reply_win->override_redirect &&
|
||||||
|
(reply_win->map_state == XCB_MAP_STATE_VIEWABLE ||
|
||||||
|
window_getstate(wins[i]) == XCB_WM_ICONIC_STATE))
|
||||||
|
{
|
||||||
|
/* TODO: should maybe be asynchronous */
|
||||||
|
win_geom = x_get_geometry(globalconf.connection, w, parent_geom);
|
||||||
|
if(!win_geom)
|
||||||
|
{
|
||||||
|
p_delete(&reply_win);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
real_screen = screen_get_bycoord(globalconf.screens_info, screen, win_geom->x, win_geom->y);
|
||||||
|
client_manage(wins[i], win_geom, real_screen);
|
||||||
|
|
||||||
|
/* win_geom is not useful anymore */
|
||||||
|
p_delete(&win_geom);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(reply_win)
|
||||||
|
p_delete(&reply_win);
|
||||||
|
}
|
||||||
|
|
||||||
|
p_delete(&parent_geom);
|
||||||
|
p_delete(&r_query_tree);
|
||||||
|
p_delete(&cookies_win);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Equivalent to 'XCreateFontCursor()', error are handled by the
|
||||||
|
* default current error handler
|
||||||
|
* \param cursor_font type of cursor to use
|
||||||
|
* \return allocated cursor font
|
||||||
|
*/
|
||||||
|
static xcb_cursor_t
|
||||||
|
create_font_cursor(unsigned int cursor_font)
|
||||||
|
{
|
||||||
|
xcb_font_t font;
|
||||||
|
xcb_cursor_t cursor;
|
||||||
|
|
||||||
|
/* Get the font for the cursor*/
|
||||||
|
font = xcb_generate_id(globalconf.connection);
|
||||||
|
xcb_open_font(globalconf.connection, font, strlen ("cursor"), "cursor");
|
||||||
|
|
||||||
|
cursor = xcb_generate_id(globalconf.connection);
|
||||||
|
xcb_create_glyph_cursor (globalconf.connection, cursor, font, font,
|
||||||
|
cursor_font, cursor_font + 1,
|
||||||
|
0, 0, 0,
|
||||||
|
0, 0, 0);
|
||||||
|
|
||||||
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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 data Additional optional parameters data
|
||||||
* \param ee Error event
|
* \param c X connection
|
||||||
|
* \param error Error event
|
||||||
*/
|
*/
|
||||||
static int __attribute__ ((noreturn))
|
static int __attribute__ ((noreturn))
|
||||||
xerrorstart(Display * disp __attribute__ ((unused)),
|
xerrorstart(void * data __attribute__ ((unused)),
|
||||||
XErrorEvent * ee __attribute__ ((unused)))
|
xcb_connection_t * c __attribute__ ((unused)),
|
||||||
|
xcb_generic_error_t * error __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
eprint("another window manager is already running\n");
|
eprint("another window manager is already running\n");
|
||||||
}
|
}
|
||||||
|
@ -111,13 +233,13 @@ xerrorstart(Display * disp __attribute__ ((unused)),
|
||||||
void
|
void
|
||||||
uicb_quit(int screen __attribute__ ((unused)), char *arg __attribute__ ((unused)))
|
uicb_quit(int screen __attribute__ ((unused)), char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
running = False;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
exit_on_signal(int sig __attribute__ ((unused)))
|
exit_on_signal(int sig __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
running = False;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief awesome xerror function
|
/** \brief awesome xerror function
|
||||||
|
@ -129,15 +251,39 @@ exit_on_signal(int sig __attribute__ ((unused)))
|
||||||
* \return 0 if no error, or xerror's xlib return status
|
* \return 0 if no error, or xerror's xlib return status
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xerror(Display *edpy, XErrorEvent *ee)
|
xerror(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *c __attribute__ ((unused)),
|
||||||
|
xcb_generic_error_t *e)
|
||||||
{
|
{
|
||||||
if(ee->error_code == BadWindow
|
/*
|
||||||
|| (ee->error_code == BadMatch && ee->request_code == X_SetInputFocus)
|
* Get the request code, taken from 'xcb-util/wm'. I can't figure
|
||||||
|| (ee->error_code == BadValue && ee->request_code == X_KillClient)
|
* out how it works BTW, seems to get a byte in 'pad' member
|
||||||
|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch))
|
* (second byte in second element of the array)
|
||||||
|
*/
|
||||||
|
uint8_t request_code = (e->response_type == 0 ? *((uint8_t *) e + 10) : e->response_type);
|
||||||
|
|
||||||
|
if(e->error_code == BadWindow
|
||||||
|
|| (e->error_code == BadMatch && request_code == XCB_SET_INPUT_FOCUS)
|
||||||
|
|| (e->error_code == BadValue && request_code == XCB_KILL_CLIENT)
|
||||||
|
|| (request_code == XCB_CONFIGURE_WINDOW && e->error_code == BadMatch))
|
||||||
return 0;
|
return 0;
|
||||||
warn("fatal error: request code=%d, error code=%d\n", ee->request_code, ee->error_code);
|
|
||||||
return xerrorxlib(edpy, ee); /* may call exit */
|
warn("fatal error: request=%s, error=%s\n",
|
||||||
|
x_label_request[request_code], x_label_error[e->error_code]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Xlib code was using default X error handler, namely
|
||||||
|
* '_XDefaultError()', which displays more informations about the
|
||||||
|
* error and also exit if 'error_code'' equals to
|
||||||
|
* 'BadImplementation'
|
||||||
|
*
|
||||||
|
* TODO: display more informations about the error (like the Xlib
|
||||||
|
* default error handler)
|
||||||
|
*/
|
||||||
|
if(e->error_code == BadImplementation)
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Print help and exit(2) with given exit_code.
|
/** Print help and exit(2) with given exit_code.
|
||||||
|
@ -161,23 +307,21 @@ exit_help(int exit_code)
|
||||||
* \param argv who knows
|
* \param argv who knows
|
||||||
* \return EXIT_SUCCESS I hope
|
* \return EXIT_SUCCESS I hope
|
||||||
*/
|
*/
|
||||||
typedef void event_handler (XEvent *);
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
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, csfd, i, screen_nbr, opt;
|
||||||
ssize_t cmdlen = 1;
|
ssize_t cmdlen = 1;
|
||||||
|
const xcb_query_extension_reply_t *shape_query, *randr_query;
|
||||||
Statusbar *statusbar;
|
Statusbar *statusbar;
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
XEvent ev;
|
xcb_generic_event_t *ev;
|
||||||
Display * dpy;
|
xcb_connection_t *conn;
|
||||||
event_handler **handler;
|
|
||||||
struct sockaddr_un *addr;
|
struct sockaddr_un *addr;
|
||||||
Client *c;
|
Client *c;
|
||||||
XSetWindowAttributes wa;
|
bool confcheck = false;
|
||||||
Bool xsync = False, confcheck = False;
|
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
{"help", 0, NULL, 'h'},
|
{"help", 0, NULL, 'h'},
|
||||||
|
@ -219,10 +363,7 @@ main(int argc, char *argv[])
|
||||||
eprint("-c option requires a file name\n");
|
eprint("-c option requires a file name\n");
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
confcheck = True;
|
confcheck = true;
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
xsync = True;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,33 +374,48 @@ main(int argc, char *argv[])
|
||||||
return config_check(confpath);
|
return config_check(confpath);
|
||||||
|
|
||||||
/* X stuff */
|
/* X stuff */
|
||||||
if(!(dpy = XOpenDisplay(NULL)))
|
conn = xcb_connect(NULL, &(globalconf.default_screen));
|
||||||
|
if(xcb_connection_has_error(conn))
|
||||||
eprint("cannot open display\n");
|
eprint("cannot open display\n");
|
||||||
|
|
||||||
xfd = ConnectionNumber(dpy);
|
xfd = xcb_get_file_descriptor(conn);
|
||||||
|
|
||||||
XSetErrorHandler(xerrorstart);
|
/* Allocate a handler which will holds all errors and events */
|
||||||
for(screen = 0; screen < ScreenCount(dpy); screen++)
|
globalconf.evenths = xcb_alloc_event_handlers(conn);
|
||||||
/* this causes an error if some other window manager is running */
|
xcb_set_error_handler_catch_all(globalconf.evenths, xerrorstart, NULL);
|
||||||
XSelectInput(dpy, RootWindow(dpy, screen), SubstructureRedirectMask);
|
|
||||||
|
|
||||||
/* need to XSync to validate errorhandler */
|
for(screen_nbr = 0;
|
||||||
XSync(dpy, False);
|
screen_nbr < xcb_setup_roots_length(xcb_get_setup(conn));
|
||||||
XSetErrorHandler(NULL);
|
screen_nbr++)
|
||||||
xerrorxlib = XSetErrorHandler(xerror);
|
{
|
||||||
XSync(dpy, False);
|
/* this causes an error if some other window manager is
|
||||||
|
* running */
|
||||||
|
x_select_input(conn, root_window(conn, screen_nbr),
|
||||||
|
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* need to xcb_flush to validate error handler */
|
||||||
|
xcb_aux_sync(conn);
|
||||||
|
|
||||||
|
/* process all errors in the queue if any */
|
||||||
|
xcb_poll_for_event_loop(globalconf.evenths);
|
||||||
|
|
||||||
|
/* set the default xerror handler */
|
||||||
|
xcb_set_error_handler_catch_all(globalconf.evenths, xerror, NULL);
|
||||||
|
|
||||||
|
/* TODO
|
||||||
if(xsync)
|
if(xsync)
|
||||||
XSynchronize(dpy, True);
|
XSynchronize(dpy, true);
|
||||||
|
*/
|
||||||
|
|
||||||
/* store display */
|
/* store display */
|
||||||
globalconf.display = dpy;
|
globalconf.connection = conn;
|
||||||
|
|
||||||
/* init EWMH atoms */
|
/* init EWMH atoms */
|
||||||
ewmh_init_atoms();
|
ewmh_init_atoms();
|
||||||
|
|
||||||
/* init screens struct */
|
/* init screens struct */
|
||||||
globalconf.screens_info = screensinfo_new(dpy);
|
globalconf.screens_info = screensinfo_new(conn);
|
||||||
globalconf.screens = p_new(VirtScreen, globalconf.screens_info->nscreen);
|
globalconf.screens = p_new(VirtScreen, globalconf.screens_info->nscreen);
|
||||||
focus_add_client(NULL);
|
focus_add_client(NULL);
|
||||||
|
|
||||||
|
@ -267,72 +423,80 @@ main(int argc, char *argv[])
|
||||||
config_parse(confpath);
|
config_parse(confpath);
|
||||||
|
|
||||||
/* init cursors */
|
/* init cursors */
|
||||||
globalconf.cursor[CurNormal] = XCreateFontCursor(globalconf.display, XC_left_ptr);
|
globalconf.cursor[CurNormal] = create_font_cursor(CURSOR_LEFT_PTR);
|
||||||
globalconf.cursor[CurResize] = XCreateFontCursor(globalconf.display, XC_sizing);
|
globalconf.cursor[CurResize] = create_font_cursor(CURSOR_SIZING);
|
||||||
globalconf.cursor[CurMove] = XCreateFontCursor(globalconf.display, XC_fleur);
|
globalconf.cursor[CurMove] = create_font_cursor(CURSOR_FLEUR);
|
||||||
|
|
||||||
/* for each virtual screen */
|
/* for each virtual screen */
|
||||||
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
for(screen_nbr = 0; screen_nbr < globalconf.screens_info->nscreen; screen_nbr++)
|
||||||
{
|
{
|
||||||
/* view at least one tag */
|
/* view at least one tag */
|
||||||
tag_view(globalconf.screens[screen].tags, True);
|
tag_view(globalconf.screens[screen_nbr].tags, true);
|
||||||
|
|
||||||
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
for(statusbar = globalconf.screens[screen_nbr].statusbar; statusbar; statusbar = statusbar->next)
|
||||||
statusbar_init(statusbar);
|
statusbar_init(statusbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* select for events */
|
/* select for events */
|
||||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
const uint32_t change_win_vals[] =
|
||||||
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
|
{
|
||||||
wa.cursor = globalconf.cursor[CurNormal];
|
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY
|
||||||
|
| XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW
|
||||||
|
| XCB_EVENT_MASK_STRUCTURE_NOTIFY,
|
||||||
|
globalconf.cursor[CurNormal]
|
||||||
|
};
|
||||||
|
|
||||||
/* do this only for real screen */
|
/* do this only for real screen */
|
||||||
for(screen = 0; screen < ScreenCount(dpy); screen++)
|
for(screen_nbr = 0;
|
||||||
|
screen_nbr < xcb_setup_roots_length(xcb_get_setup(conn));
|
||||||
|
screen_nbr++)
|
||||||
{
|
{
|
||||||
XChangeWindowAttributes(globalconf.display,
|
xcb_change_window_attributes(globalconf.connection,
|
||||||
RootWindow(globalconf.display, screen),
|
root_window(globalconf.connection, screen_nbr),
|
||||||
CWEventMask | CWCursor, &wa);
|
XCB_CW_EVENT_MASK | XCB_CW_CURSOR,
|
||||||
XSelectInput(globalconf.display,
|
change_win_vals);
|
||||||
RootWindow(globalconf.display, screen),
|
x_select_input(globalconf.connection,
|
||||||
wa.event_mask);
|
root_window(globalconf.connection, screen_nbr),
|
||||||
ewmh_set_supported_hints(screen);
|
change_win_vals[0]);
|
||||||
|
ewmh_set_supported_hints(screen_nbr);
|
||||||
/* 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_nbr);
|
||||||
window_root_grabkeys(screen);
|
window_root_grabkeys(screen_nbr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* scan existing windows */
|
/* scan existing windows */
|
||||||
scan();
|
scan();
|
||||||
|
|
||||||
handler = p_new(event_handler *, LASTEvent);
|
/* process all errors in the queue if any */
|
||||||
handler[ButtonPress] = event_handle_buttonpress;
|
xcb_poll_for_event_loop(globalconf.evenths);
|
||||||
handler[ConfigureRequest] = event_handle_configurerequest;
|
|
||||||
handler[ConfigureNotify] = event_handle_configurenotify;
|
set_button_press_event_handler(globalconf.evenths, event_handle_buttonpress, NULL);
|
||||||
handler[DestroyNotify] = event_handle_destroynotify;
|
set_configure_request_event_handler(globalconf.evenths, event_handle_configurerequest, NULL);
|
||||||
handler[EnterNotify] = event_handle_enternotify;
|
set_configure_notify_event_handler(globalconf.evenths, event_handle_configurenotify, NULL);
|
||||||
handler[Expose] = event_handle_expose;
|
set_destroy_notify_event_handler(globalconf.evenths, event_handle_destroynotify, NULL);
|
||||||
handler[KeyPress] = event_handle_keypress;
|
set_enter_notify_event_handler(globalconf.evenths, event_handle_enternotify, NULL);
|
||||||
handler[MappingNotify] = event_handle_mappingnotify;
|
set_expose_event_handler(globalconf.evenths, event_handle_expose, NULL);
|
||||||
handler[MapRequest] = event_handle_maprequest;
|
set_key_press_event_handler(globalconf.evenths, event_handle_keypress, NULL);
|
||||||
handler[PropertyNotify] = event_handle_propertynotify;
|
set_mapping_notify_event_handler(globalconf.evenths, event_handle_mappingnotify, NULL);
|
||||||
handler[UnmapNotify] = event_handle_unmapnotify;
|
set_map_request_event_handler(globalconf.evenths, event_handle_maprequest, NULL);
|
||||||
handler[ClientMessage] = event_handle_clientmessage;
|
set_property_notify_event_handler(globalconf.evenths, event_handle_propertynotify, NULL);
|
||||||
|
set_unmap_notify_event_handler(globalconf.evenths, event_handle_unmapnotify, NULL);
|
||||||
|
set_client_message_event_handler(globalconf.evenths, event_handle_clientmessage, NULL);
|
||||||
|
|
||||||
/* check for shape extension */
|
/* check for shape extension */
|
||||||
if((globalconf.have_shape = XShapeQueryExtension(dpy, &shape_event, &e_dummy)))
|
shape_query = xcb_get_extension_data(conn, &xcb_shape_id);
|
||||||
{
|
if((globalconf.have_shape = shape_query->present))
|
||||||
p_realloc(&handler, shape_event + 1);
|
xcb_set_event_handler(globalconf.evenths, (shape_query->first_event + XCB_SHAPE_NOTIFY),
|
||||||
handler[shape_event] = event_handle_shape;
|
(xcb_generic_event_handler_t) event_handle_shape, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
/* check for randr extension */
|
/* check for randr extension */
|
||||||
if((globalconf.have_randr = XRRQueryExtension(dpy, &randr_event_base, &e_dummy)))
|
randr_query = xcb_get_extension_data(conn, &xcb_randr_id);
|
||||||
{
|
if((globalconf.have_randr = randr_query->present))
|
||||||
p_realloc(&handler, randr_event_base + RRScreenChangeNotify + 1);
|
xcb_set_event_handler(globalconf.evenths, (randr_query->first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY),
|
||||||
handler[randr_event_base + RRScreenChangeNotify] = event_handle_randr_screen_change_notify;
|
(xcb_generic_event_handler_t) event_handle_randr_screen_change_notify,
|
||||||
}
|
NULL);
|
||||||
|
|
||||||
XSync(dpy, False);
|
xcb_aux_sync(conn);
|
||||||
|
|
||||||
/* get socket fd */
|
/* get socket fd */
|
||||||
csfd = socket_getclient();
|
csfd = socket_getclient();
|
||||||
|
@ -397,23 +561,21 @@ main(int argc, char *argv[])
|
||||||
* are available and select() won't tell us, so let's check
|
* are available and select() won't tell us, so let's check
|
||||||
* with XPending() again.
|
* with XPending() again.
|
||||||
*/
|
*/
|
||||||
while(XPending(dpy))
|
while((ev = xcb_poll_for_event(conn)))
|
||||||
{
|
{
|
||||||
while(XPending(dpy))
|
do
|
||||||
{
|
{
|
||||||
XNextEvent(dpy, &ev);
|
xcb_handle_event(globalconf.evenths, ev);
|
||||||
if(handler[ev.type])
|
|
||||||
handler[ev.type](&ev);
|
|
||||||
|
|
||||||
/* need to resync */
|
/* need to resync */
|
||||||
XSync(dpy, False);
|
xcb_aux_sync(conn);
|
||||||
}
|
} while((ev = xcb_poll_for_event(conn)));
|
||||||
|
|
||||||
statusbar_refresh();
|
statusbar_refresh();
|
||||||
layout_refresh();
|
layout_refresh();
|
||||||
|
|
||||||
/* need to resync */
|
/* need to resync */
|
||||||
XSync(dpy, False);
|
xcb_aux_sync(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,9 +590,9 @@ main(int argc, char *argv[])
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
client_unban(c);
|
client_unban(c);
|
||||||
|
|
||||||
XSync(globalconf.display, False);
|
xcb_aux_sync(globalconf.connection);
|
||||||
|
|
||||||
XCloseDisplay(dpy);
|
xcb_disconnect(conn);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
450
client.c
450
client.c
|
@ -20,8 +20,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <X11/Xatom.h>
|
#include <stdbool.h>
|
||||||
#include <X11/extensions/shape.h>
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
#include <xcb/xcb_atom.h>
|
||||||
|
#include <xcb/shape.h>
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
|
@ -45,28 +49,28 @@ extern AwesomeConf globalconf;
|
||||||
* \param screen Screen ID
|
* \param screen Screen ID
|
||||||
* \return true if client had property
|
* \return true if client had property
|
||||||
*/
|
*/
|
||||||
static Bool
|
static bool
|
||||||
client_loadprops(Client * c, int screen)
|
client_loadprops(Client * c, int screen)
|
||||||
{
|
{
|
||||||
int i, ntags = 0;
|
int i, ntags = 0;
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
char *prop;
|
char *prop;
|
||||||
Bool result = False;
|
bool result = false;
|
||||||
|
|
||||||
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
||||||
ntags++;
|
ntags++;
|
||||||
|
|
||||||
prop = p_new(char, ntags + 3);
|
prop = p_new(char, ntags + 3);
|
||||||
|
|
||||||
if(xgettextprop(globalconf.display, c->win,
|
if(xgettextprop(globalconf.connection, c->win,
|
||||||
XInternAtom(globalconf.display, "_AWESOME_PROPERTIES", False),
|
x_intern_atom(globalconf.connection, "_AWESOME_PROPERTIES"),
|
||||||
prop, ntags + 3))
|
prop, ntags + 3))
|
||||||
{
|
{
|
||||||
for(i = 0, tag = globalconf.screens[screen].tags; tag && i < ntags && prop[i]; i++, tag = tag->next)
|
for(i = 0, tag = globalconf.screens[screen].tags; tag && i < ntags && prop[i]; i++, tag = tag->next)
|
||||||
if(prop[i] == '1')
|
if(prop[i] == '1')
|
||||||
{
|
{
|
||||||
tag_client(c, tag);
|
tag_client(c, tag);
|
||||||
result = True;
|
result = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
untag_client(c, tag);
|
untag_client(c, tag);
|
||||||
|
@ -83,21 +87,21 @@ client_loadprops(Client * c, int screen)
|
||||||
/** Check if client supports protocol WM_DELETE_WINDOW
|
/** Check if client supports protocol WM_DELETE_WINDOW
|
||||||
* \param disp the display
|
* \param disp the display
|
||||||
* \param win the Window
|
* \param win the Window
|
||||||
* \return True if client has WM_DELETE_WINDOW
|
* \return true if client has WM_DELETE_WINDOW
|
||||||
*/
|
*/
|
||||||
static Bool
|
static bool
|
||||||
client_isprotodel(Display *disp, Window win)
|
client_isprotodel(xcb_connection_t *c, xcb_window_t win)
|
||||||
{
|
{
|
||||||
int i, n;
|
uint32_t i, n;
|
||||||
Atom *protocols;
|
xcb_atom_t *protocols;
|
||||||
Bool ret = False;
|
bool ret = false;
|
||||||
|
|
||||||
if(XGetWMProtocols(disp, win, &protocols, &n))
|
if(xcb_get_wm_protocols(c, win, &n, &protocols))
|
||||||
{
|
{
|
||||||
for(i = 0; !ret && i < n; i++)
|
for(i = 0; !ret && i < n; i++)
|
||||||
if(protocols[i] == XInternAtom(disp, "WM_DELETE_WINDOW", False))
|
if(protocols[i] == x_intern_atom(c, "WM_DELETE_WINDOW"))
|
||||||
ret = True;
|
ret = true;
|
||||||
XFree(protocols);
|
p_delete(&protocols);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +112,7 @@ client_isprotodel(Display *disp, Window win)
|
||||||
* \return client
|
* \return client
|
||||||
*/
|
*/
|
||||||
Client *
|
Client *
|
||||||
client_get_bywin(Client *list, Window w)
|
client_get_bywin(Client *list, xcb_window_t w)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
|
@ -139,10 +143,10 @@ client_get_byname(Client *list, char *name)
|
||||||
void
|
void
|
||||||
client_updatetitle(Client *c)
|
client_updatetitle(Client *c)
|
||||||
{
|
{
|
||||||
if(!xgettextprop(globalconf.display, c->win,
|
if(!xgettextprop(globalconf.connection, c->win,
|
||||||
XInternAtom(globalconf.display, "_NET_WM_NAME", False), c->name, sizeof(c->name)))
|
x_intern_atom(globalconf.connection, "_NET_WM_NAME"), c->name, sizeof(c->name)))
|
||||||
xgettextprop(globalconf.display, c->win,
|
xgettextprop(globalconf.connection, c->win,
|
||||||
XInternAtom(globalconf.display, "WM_NAME", False), c->name, sizeof(c->name));
|
x_intern_atom(globalconf.connection, "WM_NAME"), c->name, sizeof(c->name));
|
||||||
|
|
||||||
titlebar_draw(c);
|
titlebar_draw(c);
|
||||||
|
|
||||||
|
@ -157,8 +161,8 @@ client_unfocus(Client *c)
|
||||||
else if(globalconf.screens[c->screen].opacity_focused != -1)
|
else if(globalconf.screens[c->screen].opacity_focused != -1)
|
||||||
window_settrans(c->win, -1);
|
window_settrans(c->win, -1);
|
||||||
focus_add_client(NULL);
|
focus_add_client(NULL);
|
||||||
XSetWindowBorder(globalconf.display, c->win,
|
xcb_change_window_attributes(globalconf.connection, c->win, XCB_CW_BORDER_PIXEL,
|
||||||
globalconf.screens[c->screen].styles.normal.border.pixel);
|
&globalconf.screens[c->screen].styles.normal.border.pixel);
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
titlebar_draw(c);
|
titlebar_draw(c);
|
||||||
}
|
}
|
||||||
|
@ -171,10 +175,10 @@ client_ban(Client *c)
|
||||||
{
|
{
|
||||||
if(globalconf.focus->client == c)
|
if(globalconf.focus->client == c)
|
||||||
client_unfocus(c);
|
client_unfocus(c);
|
||||||
XUnmapWindow(globalconf.display, c->win);
|
xcb_unmap_window(globalconf.connection, c->win);
|
||||||
window_setstate(c->win, IconicState);
|
window_setstate(c->win, XCB_WM_ICONIC_STATE);
|
||||||
if(c->titlebar.position && c->titlebar.sw)
|
if(c->titlebar.position && c->titlebar.sw)
|
||||||
XUnmapWindow(globalconf.display, c->titlebar.sw->window);
|
xcb_unmap_window(globalconf.connection, c->titlebar.sw->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Give focus to client, or to first client if c is NULL
|
/** Give focus to client, or to first client if c is NULL
|
||||||
|
@ -183,8 +187,8 @@ client_ban(Client *c)
|
||||||
* \param raise raise window if true
|
* \param raise raise window if true
|
||||||
* \return true if a window (even root) has received focus, false otherwise
|
* \return true if a window (even root) has received focus, false otherwise
|
||||||
*/
|
*/
|
||||||
Bool
|
bool
|
||||||
client_focus(Client *c, int screen, Bool raise)
|
client_focus(Client *c, int screen, bool raise)
|
||||||
{
|
{
|
||||||
int phys_screen;
|
int phys_screen;
|
||||||
|
|
||||||
|
@ -196,7 +200,7 @@ client_focus(Client *c, int screen, Bool raise)
|
||||||
|
|
||||||
/* if c is already the focused window, then stop */
|
/* if c is already the focused window, then stop */
|
||||||
if(c == globalconf.focus->client)
|
if(c == globalconf.focus->client)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* unfocus current selected client */
|
/* unfocus current selected client */
|
||||||
if(globalconf.focus->client)
|
if(globalconf.focus->client)
|
||||||
|
@ -212,10 +216,11 @@ client_focus(Client *c, int screen, Bool raise)
|
||||||
window_settrans(c->win, globalconf.screens[c->screen].opacity_focused);
|
window_settrans(c->win, globalconf.screens[c->screen].opacity_focused);
|
||||||
else if(globalconf.screens[c->screen].opacity_unfocused != -1)
|
else if(globalconf.screens[c->screen].opacity_unfocused != -1)
|
||||||
window_settrans(c->win, -1);
|
window_settrans(c->win, -1);
|
||||||
XSetWindowBorder(globalconf.display, c->win,
|
xcb_change_window_attributes(globalconf.connection, c->win, XCB_CW_BORDER_PIXEL,
|
||||||
globalconf.screens[screen].styles.focus.border.pixel);
|
&globalconf.screens[screen].styles.focus.border.pixel);
|
||||||
titlebar_draw(c);
|
titlebar_draw(c);
|
||||||
XSetInputFocus(globalconf.display, c->win, RevertToPointerRoot, CurrentTime);
|
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_POINTER_ROOT,
|
||||||
|
c->win, XCB_CURRENT_TIME);
|
||||||
if(raise)
|
if(raise)
|
||||||
client_stack(c);
|
client_stack(c);
|
||||||
/* since we're dropping EnterWindow events and sometimes the window
|
/* since we're dropping EnterWindow events and sometimes the window
|
||||||
|
@ -226,27 +231,28 @@ client_focus(Client *c, int screen, Bool raise)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
phys_screen = screen_virttophys(screen);
|
phys_screen = screen_virttophys(screen);
|
||||||
XSetInputFocus(globalconf.display,
|
xcb_set_input_focus(globalconf.connection,
|
||||||
RootWindow(globalconf.display, phys_screen),
|
XCB_INPUT_FOCUS_POINTER_ROOT,
|
||||||
RevertToPointerRoot, CurrentTime);
|
root_window(globalconf.connection, phys_screen),
|
||||||
|
XCB_CURRENT_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_update_net_active_window(phys_screen);
|
ewmh_update_net_active_window(phys_screen);
|
||||||
widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
client_stack(Client *c)
|
client_stack(Client *c)
|
||||||
{
|
{
|
||||||
XWindowChanges wc;
|
uint32_t config_win_vals[2];
|
||||||
Client *client;
|
Client *client;
|
||||||
unsigned int layer;
|
unsigned int layer;
|
||||||
Layer maxlayer = LAYER_FULLSCREEN;
|
Layer maxlayer = LAYER_FULLSCREEN;
|
||||||
|
|
||||||
wc.stack_mode = Above;
|
config_win_vals[0] = XCB_NONE;
|
||||||
wc.sibling = None;
|
config_win_vals[1] = XCB_STACK_MODE_ABOVE;
|
||||||
|
|
||||||
for(layer = 0; layer < maxlayer; layer++)
|
for(layer = 0; layer < maxlayer; layer++)
|
||||||
{
|
{
|
||||||
|
@ -256,24 +262,31 @@ client_stack(Client *c)
|
||||||
{
|
{
|
||||||
if(client->titlebar.position && client->titlebar.sw)
|
if(client->titlebar.position && client->titlebar.sw)
|
||||||
{
|
{
|
||||||
XConfigureWindow(globalconf.display, client->titlebar.sw->window,
|
xcb_configure_window(globalconf.connection,
|
||||||
CWSibling | CWStackMode, &wc);
|
client->titlebar.sw->window,
|
||||||
wc.sibling = client->titlebar.sw->window;
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
||||||
|
config_win_vals);
|
||||||
|
config_win_vals[0] = client->titlebar.sw->window;
|
||||||
}
|
}
|
||||||
XConfigureWindow(globalconf.display, client->win, CWSibling | CWStackMode, &wc);
|
xcb_configure_window(globalconf.connection, client->win,
|
||||||
wc.sibling = client->win;
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
||||||
|
config_win_vals);
|
||||||
|
config_win_vals[0] = client->win;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c->layer == layer)
|
if(c->layer == layer)
|
||||||
{
|
{
|
||||||
if(c->titlebar.position && c->titlebar.sw)
|
if(c->titlebar.position && c->titlebar.sw)
|
||||||
{
|
{
|
||||||
XConfigureWindow(globalconf.display, c->titlebar.sw->window,
|
xcb_configure_window(globalconf.connection, c->titlebar.sw->window,
|
||||||
CWSibling | CWStackMode, &wc);
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
||||||
wc.sibling = c->titlebar.sw->window;
|
config_win_vals);
|
||||||
|
config_win_vals[0] = c->titlebar.sw->window;
|
||||||
}
|
}
|
||||||
XConfigureWindow(globalconf.display, c->win, CWSibling | CWStackMode, &wc);
|
xcb_configure_window(globalconf.connection, c->win,
|
||||||
wc.sibling = c->win;
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
||||||
|
config_win_vals);
|
||||||
|
config_win_vals[0] = c->win;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,22 +297,22 @@ client_stack(Client *c)
|
||||||
* \param screen Screen ID
|
* \param screen Screen ID
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
client_manage(Window w, XWindowAttributes *wa, int screen)
|
client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wa, int screen)
|
||||||
{
|
{
|
||||||
Client *c, *t = NULL;
|
Client *c, *t = NULL;
|
||||||
Window trans;
|
xcb_window_t trans;
|
||||||
Bool rettrans, retloadprops;
|
bool rettrans, retloadprops;
|
||||||
XWindowChanges wc;
|
uint32_t config_win_val;
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
Rule *rule;
|
Rule *rule;
|
||||||
long flags;
|
xcb_size_hints_t *u_size_hints;
|
||||||
|
|
||||||
c = p_new(Client, 1);
|
c = p_new(Client, 1);
|
||||||
|
|
||||||
c->screen = screen_get_bycoord(globalconf.screens_info, screen, wa->x, wa->y);
|
c->screen = screen_get_bycoord(globalconf.screens_info, screen, wa->x, wa->y);
|
||||||
|
|
||||||
if(globalconf.screens_info->xinerama_is_active)
|
if(globalconf.screens_info->xinerama_is_active)
|
||||||
c->phys_screen = DefaultScreen(globalconf.display);
|
c->phys_screen = globalconf.default_screen;
|
||||||
else
|
else
|
||||||
c->phys_screen = c->screen;
|
c->phys_screen = c->screen;
|
||||||
|
|
||||||
|
@ -310,13 +323,15 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
||||||
c->geometry.width = c->f_geometry.width = c->m_geometry.width = wa->width;
|
c->geometry.width = c->f_geometry.width = c->m_geometry.width = wa->width;
|
||||||
c->geometry.height = c->f_geometry.height = c->m_geometry.height = wa->height;
|
c->geometry.height = c->f_geometry.height = c->m_geometry.height = wa->height;
|
||||||
c->oldborder = wa->border_width;
|
c->oldborder = wa->border_width;
|
||||||
c->newcomer = True;
|
c->newcomer = true;
|
||||||
c->layer = c->oldlayer = LAYER_TILE;
|
c->layer = c->oldlayer = LAYER_TILE;
|
||||||
|
|
||||||
/* Set windows borders */
|
/* Set windows borders */
|
||||||
wc.border_width = c->border = globalconf.screens[screen].borderpx;
|
config_win_val = c->border = globalconf.screens[screen].borderpx;
|
||||||
XConfigureWindow(globalconf.display, w, CWBorderWidth, &wc);
|
xcb_configure_window(globalconf.connection, w, XCB_CONFIG_WINDOW_BORDER_WIDTH,
|
||||||
XSetWindowBorder(globalconf.display, w, c->border);
|
&config_win_val);
|
||||||
|
xcb_configure_window(globalconf.connection, w, XCB_CONFIG_WINDOW_STACK_MODE,
|
||||||
|
&config_win_val);
|
||||||
/* propagates border_width, if size doesn't change */
|
/* propagates border_width, if size doesn't change */
|
||||||
window_configure(c->win, c->geometry, c->border);
|
window_configure(c->win, c->geometry, c->border);
|
||||||
|
|
||||||
|
@ -324,12 +339,12 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
||||||
client_updatetitle(c);
|
client_updatetitle(c);
|
||||||
|
|
||||||
/* update hints */
|
/* update hints */
|
||||||
flags = client_updatesizehints(c);
|
u_size_hints = client_updatesizehints(c);
|
||||||
client_updatewmhints(c);
|
client_updatewmhints(c);
|
||||||
|
|
||||||
/* Try to load props if any */
|
/* Try to load props if any */
|
||||||
if(!(retloadprops = client_loadprops(c, screen)))
|
if(!(retloadprops = client_loadprops(c, screen)))
|
||||||
move_client_to_screen(c, screen, True);
|
move_client_to_screen(c, screen, true);
|
||||||
|
|
||||||
/* Then check clients hints */
|
/* Then check clients hints */
|
||||||
ewmh_check_client_hints(c);
|
ewmh_check_client_hints(c);
|
||||||
|
@ -344,7 +359,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
||||||
if(!retloadprops && rule)
|
if(!retloadprops && rule)
|
||||||
{
|
{
|
||||||
if(rule->screen != RULE_NOSCREEN)
|
if(rule->screen != RULE_NOSCREEN)
|
||||||
move_client_to_screen(c, rule->screen, True);
|
move_client_to_screen(c, rule->screen, true);
|
||||||
tag_client_with_rule(c, rule);
|
tag_client_with_rule(c, rule);
|
||||||
|
|
||||||
switch(rule->isfloating)
|
switch(rule->isfloating)
|
||||||
|
@ -352,10 +367,10 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
||||||
case Maybe:
|
case Maybe:
|
||||||
break;
|
break;
|
||||||
case Yes:
|
case Yes:
|
||||||
client_setfloating(c, True, c->layer != LAYER_TILE ? c->layer : LAYER_FLOAT);
|
client_setfloating(c, true, c->layer != LAYER_TILE ? c->layer : LAYER_FLOAT);
|
||||||
break;
|
break;
|
||||||
case No:
|
case No:
|
||||||
client_setfloating(c, False, LAYER_TILE);
|
client_setfloating(c, false, LAYER_TILE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,10 +378,8 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
||||||
window_settrans(c->win, rule->opacity);
|
window_settrans(c->win, rule->opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for transient and set tags like its parent,
|
/* check for transient and set tags like its parent */
|
||||||
* XGetTransientForHint returns 1 on success
|
if((rettrans = x_get_transient_for_hint(globalconf.connection, w, &trans))
|
||||||
*/
|
|
||||||
if((rettrans = XGetTransientForHint(globalconf.display, w, &trans))
|
|
||||||
&& (t = client_get_bywin(globalconf.clients, trans)))
|
&& (t = client_get_bywin(globalconf.clients, trans)))
|
||||||
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
||||||
if(is_client_tagged(t, tag))
|
if(is_client_tagged(t, tag))
|
||||||
|
@ -374,7 +387,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
||||||
|
|
||||||
/* should be floating if transsient or fixed */
|
/* should be floating if transsient or fixed */
|
||||||
if(rettrans || c->isfixed)
|
if(rettrans || c->isfixed)
|
||||||
client_setfloating(c, True, c->layer != LAYER_TILE ? c->layer : LAYER_FLOAT);
|
client_setfloating(c, true, c->layer != LAYER_TILE ? c->layer : LAYER_FLOAT);
|
||||||
|
|
||||||
/* titlebar init */
|
/* titlebar init */
|
||||||
if(rule && rule->titlebar.position != Auto)
|
if(rule && rule->titlebar.position != Auto)
|
||||||
|
@ -382,23 +395,27 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
||||||
|
|
||||||
titlebar_init(c);
|
titlebar_init(c);
|
||||||
|
|
||||||
if(!retloadprops && !(flags & (USPosition | PPosition)))
|
if(!retloadprops
|
||||||
|
&& u_size_hints
|
||||||
|
&& !(xcb_size_hints_is_us_position(u_size_hints) | xcb_size_hints_is_p_position(u_size_hints)))
|
||||||
{
|
{
|
||||||
if(c->isfloating && !c->ismax)
|
if(c->isfloating && !c->ismax)
|
||||||
client_resize(c, globalconf.screens[c->screen].floating_placement(c), False);
|
client_resize(c, globalconf.screens[c->screen].floating_placement(c), false);
|
||||||
else
|
else
|
||||||
c->f_geometry = globalconf.screens[c->screen].floating_placement(c);
|
c->f_geometry = globalconf.screens[c->screen].floating_placement(c);
|
||||||
|
|
||||||
|
xcb_free_size_hints(u_size_hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update titlebar with real floating info now */
|
/* update titlebar with real floating info now */
|
||||||
titlebar_update_geometry_floating(c);
|
titlebar_update_geometry_floating(c);
|
||||||
|
|
||||||
XSelectInput(globalconf.display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
x_select_input(globalconf.connection, w, XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_ENTER_WINDOW);
|
||||||
|
|
||||||
/* handle xshape */
|
/* handle xshape */
|
||||||
if(globalconf.have_shape)
|
if(globalconf.have_shape)
|
||||||
{
|
{
|
||||||
XShapeSelectInput(globalconf.display, w, ShapeNotifyMask);
|
xcb_shape_select_input(globalconf.connection, w, true);
|
||||||
window_setshape(c->win, c->phys_screen);
|
window_setshape(c->win, c->phys_screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,16 +497,15 @@ client_geometry_hints(Client *c, area_t geometry)
|
||||||
* \param c client to resize
|
* \param c client to resize
|
||||||
* \param geometry new window geometry
|
* \param geometry new window geometry
|
||||||
* \param hints use resize hints
|
* \param hints use resize hints
|
||||||
* \param return True if resize has been done
|
* \param return true if resize has been done
|
||||||
*/
|
*/
|
||||||
Bool
|
bool
|
||||||
client_resize(Client *c, area_t geometry, Bool hints)
|
client_resize(Client *c, area_t geometry, bool hints)
|
||||||
{
|
{
|
||||||
int new_screen;
|
int new_screen;
|
||||||
area_t area;
|
area_t area;
|
||||||
XWindowChanges wc;
|
|
||||||
Layout *layout = layout_get_current(c->screen);
|
Layout *layout = layout_get_current(c->screen);
|
||||||
Bool resized = False;
|
bool resized = false;
|
||||||
|
|
||||||
if(!c->ismoving && !c->isfloating && layout->arrange != layout_floating)
|
if(!c->ismoving && !c->isfloating && layout->arrange != layout_floating)
|
||||||
{
|
{
|
||||||
|
@ -497,11 +513,15 @@ client_resize(Client *c, area_t geometry, Bool hints)
|
||||||
geometry = titlebar_geometry_remove(&c->titlebar, geometry);
|
geometry = titlebar_geometry_remove(&c->titlebar, geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Values to configure a window is an array where values are
|
||||||
|
* stored according to 'value_mask' */
|
||||||
|
uint32_t values[5];
|
||||||
|
|
||||||
if(hints)
|
if(hints)
|
||||||
geometry = client_geometry_hints(c, geometry);
|
geometry = client_geometry_hints(c, geometry);
|
||||||
|
|
||||||
if(geometry.width <= 0 || geometry.height <= 0)
|
if(geometry.width <= 0 || geometry.height <= 0)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
/* offscreen appearance fixes */
|
/* offscreen appearance fixes */
|
||||||
area = get_display_area(c->phys_screen, NULL,
|
area = get_display_area(c->phys_screen, NULL,
|
||||||
|
@ -522,11 +542,11 @@ client_resize(Client *c, area_t geometry, Bool hints)
|
||||||
new_screen =
|
new_screen =
|
||||||
screen_get_bycoord(globalconf.screens_info, c->screen, geometry.x, geometry.y);
|
screen_get_bycoord(globalconf.screens_info, c->screen, geometry.x, geometry.y);
|
||||||
|
|
||||||
c->geometry.x = wc.x = geometry.x;
|
c->geometry.x = values[0] = geometry.x;
|
||||||
c->geometry.width = wc.width = geometry.width;
|
c->geometry.width = values[2] = geometry.width;
|
||||||
c->geometry.y = wc.y = geometry.y;
|
c->geometry.y = values[1] = geometry.y;
|
||||||
c->geometry.height = wc.height = geometry.height;
|
c->geometry.height = values[3] = geometry.height;
|
||||||
wc.border_width = c->border;
|
values[4] = c->border;
|
||||||
|
|
||||||
/* save the floating geometry if the window is floating but not
|
/* save the floating geometry if the window is floating but not
|
||||||
* maximized */
|
* maximized */
|
||||||
|
@ -538,14 +558,17 @@ client_resize(Client *c, area_t geometry, Bool hints)
|
||||||
titlebar_update_geometry_floating(c);
|
titlebar_update_geometry_floating(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
XConfigureWindow(globalconf.display, c->win,
|
xcb_configure_window(globalconf.connection, c->win,
|
||||||
CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
|
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
|
||||||
|
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT |
|
||||||
|
XCB_CONFIG_WINDOW_BORDER_WIDTH,
|
||||||
|
values);
|
||||||
window_configure(c->win, geometry, c->border);
|
window_configure(c->win, geometry, c->border);
|
||||||
|
|
||||||
if(c->screen != new_screen)
|
if(c->screen != new_screen)
|
||||||
move_client_to_screen(c, new_screen, False);
|
move_client_to_screen(c, new_screen, false);
|
||||||
|
|
||||||
resized = True;
|
resized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* call it again like it was floating,
|
/* call it again like it was floating,
|
||||||
|
@ -557,21 +580,19 @@ client_resize(Client *c, area_t geometry, Bool hints)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
client_setfloating(Client *c, Bool floating, Layer layer)
|
client_setfloating(Client *c, bool floating, Layer layer)
|
||||||
{
|
{
|
||||||
if(c->isfloating != floating)
|
if(c->isfloating != floating)
|
||||||
{
|
{
|
||||||
if((c->isfloating = floating))
|
if((c->isfloating = floating))
|
||||||
{
|
client_resize(c, c->f_geometry, false);
|
||||||
client_resize(c, c->f_geometry, False);
|
|
||||||
}
|
|
||||||
else if(c->ismax)
|
else if(c->ismax)
|
||||||
{
|
{
|
||||||
c->ismax = False;
|
c->ismax = false;
|
||||||
client_resize(c, c->m_geometry, False);
|
client_resize(c, c->m_geometry, false);
|
||||||
}
|
}
|
||||||
if(client_isvisible(c, c->screen))
|
if(client_isvisible(c, c->screen))
|
||||||
globalconf.screens[c->screen].need_arrange = True;
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
if(floating)
|
if(floating)
|
||||||
{
|
{
|
||||||
|
@ -611,9 +632,9 @@ client_saveprops(Client *c)
|
||||||
|
|
||||||
prop[++i] = '\0';
|
prop[++i] = '\0';
|
||||||
|
|
||||||
XChangeProperty(globalconf.display, c->win,
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, c->win,
|
||||||
XInternAtom(globalconf.display, "_AWESOME_PROPERTIES", False),
|
x_intern_atom(globalconf.connection, "_AWESOME_PROPERTIES"),
|
||||||
XA_STRING, 8, PropModeReplace, (unsigned char *) prop, i);
|
STRING, 8, i, (unsigned char *) prop);
|
||||||
|
|
||||||
p_delete(&prop);
|
p_delete(&prop);
|
||||||
}
|
}
|
||||||
|
@ -621,24 +642,23 @@ client_saveprops(Client *c)
|
||||||
void
|
void
|
||||||
client_unban(Client *c)
|
client_unban(Client *c)
|
||||||
{
|
{
|
||||||
XMapWindow(globalconf.display, c->win);
|
xcb_map_window(globalconf.connection, c->win);
|
||||||
window_setstate(c->win, NormalState);
|
window_setstate(c->win, XCB_WM_NORMAL_STATE);
|
||||||
if(c->titlebar.sw && c->titlebar.position != Off)
|
if(c->titlebar.sw && c->titlebar.position != Off)
|
||||||
XMapWindow(globalconf.display, c->titlebar.sw->window);
|
xcb_map_window(globalconf.connection, c->titlebar.sw->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
client_unmanage(Client *c)
|
client_unmanage(Client *c)
|
||||||
{
|
{
|
||||||
XWindowChanges wc;
|
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
|
|
||||||
wc.border_width = c->oldborder;
|
|
||||||
|
|
||||||
/* The server grab construct avoids race conditions. */
|
/* The server grab construct avoids race conditions. */
|
||||||
XGrabServer(globalconf.display);
|
xcb_grab_server(globalconf.connection);
|
||||||
|
|
||||||
XConfigureWindow(globalconf.display, c->win, CWBorderWidth, &wc); /* restore border */
|
xcb_configure_window(globalconf.connection, c->win,
|
||||||
|
XCB_CONFIG_WINDOW_BORDER_WIDTH,
|
||||||
|
(uint32_t *) &c->oldborder);
|
||||||
|
|
||||||
/* remove client everywhere */
|
/* remove client everywhere */
|
||||||
client_list_detach(&globalconf.clients, c);
|
client_list_detach(&globalconf.clients, c);
|
||||||
|
@ -649,13 +669,13 @@ client_unmanage(Client *c)
|
||||||
untag_client(c, tag);
|
untag_client(c, tag);
|
||||||
|
|
||||||
if(globalconf.focus->client == c)
|
if(globalconf.focus->client == c)
|
||||||
client_focus(NULL, c->screen, True);
|
client_focus(NULL, c->screen, true);
|
||||||
|
|
||||||
XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win);
|
xcb_ungrab_button(globalconf.connection, XCB_BUTTON_INDEX_ANY, c->win, ANY_MODIFIER);
|
||||||
window_setstate(c->win, WithdrawnState);
|
window_setstate(c->win, XCB_WM_WITHDRAWN_STATE);
|
||||||
|
|
||||||
XSync(globalconf.display, False);
|
xcb_aux_sync(globalconf.connection);
|
||||||
XUngrabServer(globalconf.display);
|
xcb_ungrab_server(globalconf.connection);
|
||||||
|
|
||||||
if(c->titlebar.sw)
|
if(c->titlebar.sw)
|
||||||
simplewindow_delete(&c->titlebar.sw);
|
simplewindow_delete(&c->titlebar.sw);
|
||||||
|
@ -666,110 +686,91 @@ client_unmanage(Client *c)
|
||||||
void
|
void
|
||||||
client_updatewmhints(Client *c)
|
client_updatewmhints(Client *c)
|
||||||
{
|
{
|
||||||
XWMHints *wmh;
|
xcb_wm_hints_t *wmh;
|
||||||
|
|
||||||
if((wmh = XGetWMHints(globalconf.display, c->win)))
|
if((wmh = xcb_get_wm_hints(globalconf.connection, c->win)))
|
||||||
{
|
{
|
||||||
if((c->isurgent = ((wmh->flags & XUrgencyHint) && globalconf.focus->client != c)))
|
if((c->isurgent = (xcb_wm_hints_is_x_urgency_hint(wmh) && globalconf.focus->client != c)))
|
||||||
{
|
{
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
titlebar_draw(c);
|
titlebar_draw(c);
|
||||||
}
|
}
|
||||||
if((wmh->flags & StateHint) && wmh->initial_state == WithdrawnState)
|
if(xcb_wm_hints_is_state_hint(wmh) && xcb_wm_hints_state_is_withdrawn(wmh))
|
||||||
{
|
{
|
||||||
c->border = 0;
|
c->border = 0;
|
||||||
c->skip = True;
|
c->skip = true;
|
||||||
}
|
}
|
||||||
XFree(wmh);
|
free(wmh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
xcb_size_hints_t *
|
||||||
client_updatesizehints(Client *c)
|
client_updatesizehints(Client *c)
|
||||||
{
|
{
|
||||||
long msize;
|
long msize;
|
||||||
XSizeHints size;
|
xcb_size_hints_t *size = NULL;
|
||||||
|
|
||||||
if(!XGetWMNormalHints(globalconf.display, c->win, &size, &msize))
|
if(!xcb_get_wm_normal_hints(globalconf.connection, c->win, size, &msize) ||
|
||||||
return 0L;
|
size == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if(size.flags & PBaseSize)
|
if(xcb_size_hints_is_p_size(size))
|
||||||
{
|
xcb_size_hints_get_base_size(size, &c->basew, &c->baseh);
|
||||||
c->basew = size.base_width;
|
else if(xcb_size_hints_is_p_min_size(size))
|
||||||
c->baseh = size.base_height;
|
xcb_size_hints_get_min_size(size, &c->basew, &c->baseh);
|
||||||
}
|
|
||||||
else if(size.flags & PMinSize)
|
|
||||||
{
|
|
||||||
c->basew = size.min_width;
|
|
||||||
c->baseh = size.min_height;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
c->basew = c->baseh = 0;
|
c->basew = c->baseh = 0;
|
||||||
if(size.flags & PResizeInc)
|
if(xcb_size_hints_is_p_resize_inc(size))
|
||||||
{
|
xcb_size_hints_get_increase(size, &c->incw, &c->inch);
|
||||||
c->incw = size.width_inc;
|
|
||||||
c->inch = size.height_inc;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
c->incw = c->inch = 0;
|
c->incw = c->inch = 0;
|
||||||
|
|
||||||
if(size.flags & PMaxSize)
|
if(xcb_size_hints_is_p_max_size(size))
|
||||||
{
|
xcb_size_hints_get_max_size(size, &c->maxw, &c->maxh);
|
||||||
c->maxw = size.max_width;
|
|
||||||
c->maxh = size.max_height;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
c->maxw = c->maxh = 0;
|
c->maxw = c->maxh = 0;
|
||||||
|
|
||||||
if(size.flags & PMinSize)
|
if(xcb_size_hints_is_p_min_size(size))
|
||||||
{
|
xcb_size_hints_get_min_size(size, &c->minw, &c->minh);
|
||||||
c->minw = size.min_width;
|
else if(xcb_size_hints_is_p_base_size(size))
|
||||||
c->minh = size.min_height;
|
xcb_size_hints_get_base_size(size, &c->minw, &c->minh);
|
||||||
}
|
|
||||||
else if(size.flags & PBaseSize)
|
|
||||||
{
|
|
||||||
c->minw = size.base_width;
|
|
||||||
c->minh = size.base_height;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
c->minw = c->minh = 0;
|
c->minw = c->minh = 0;
|
||||||
|
|
||||||
if(size.flags & PAspect)
|
if(xcb_size_hints_is_p_aspect(size))
|
||||||
{
|
{
|
||||||
c->minax = size.min_aspect.x;
|
xcb_size_hints_get_min_aspect(size, &c->minax, &c->minay);
|
||||||
c->maxax = size.max_aspect.x;
|
xcb_size_hints_get_max_aspect(size, &c->maxax, &c->maxay);
|
||||||
c->minay = size.min_aspect.y;
|
|
||||||
c->maxay = size.max_aspect.y;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
c->minax = c->maxax = c->minay = c->maxay = 0;
|
c->minax = c->maxax = c->minay = c->maxay = 0;
|
||||||
|
|
||||||
if(c->maxw && c->minw && c->maxh && c->minh
|
if(c->maxw && c->minw && c->maxh && c->minh
|
||||||
&& c->maxw == c->minw && c->maxh == c->minh)
|
&& c->maxw == c->minw && c->maxh == c->minh)
|
||||||
c->isfixed = True;
|
c->isfixed = true;
|
||||||
|
|
||||||
return size.flags;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns True if a client is tagged
|
/** Returns true if a client is tagged
|
||||||
* with one of the tags
|
* with one of the tags
|
||||||
* \return True or False
|
* \return true or false
|
||||||
*/
|
*/
|
||||||
Bool
|
bool
|
||||||
client_isvisible(Client *c, int screen)
|
client_isvisible(Client *c, int screen)
|
||||||
{
|
{
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
|
|
||||||
if(!c || c->screen != screen)
|
if(!c || c->screen != screen)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
if(globalconf.scratch.client == c)
|
if(globalconf.scratch.client == c)
|
||||||
return globalconf.scratch.isvisible;
|
return globalconf.scratch.isvisible;
|
||||||
|
|
||||||
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
||||||
if(tag->selected && is_client_tagged(c, tag))
|
if(tag->selected && is_client_tagged(c, tag))
|
||||||
return True;
|
return true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the transparency of the selected client.
|
/** Set the transparency of the selected client.
|
||||||
|
@ -781,27 +782,28 @@ client_isvisible(Client *c, int screen)
|
||||||
void
|
void
|
||||||
uicb_client_settrans(int screen __attribute__ ((unused)), char *arg)
|
uicb_client_settrans(int screen __attribute__ ((unused)), char *arg)
|
||||||
{
|
{
|
||||||
double delta = 1.0, current_opacity = 1.0;
|
double delta = 1.0, current_opacity = 100.0;
|
||||||
unsigned char *data;
|
|
||||||
Atom actual;
|
|
||||||
int format;
|
|
||||||
unsigned long n, left;
|
|
||||||
unsigned int current_opacity_raw = 0;
|
unsigned int current_opacity_raw = 0;
|
||||||
int set_prop = 0;
|
int set_prop = 0;
|
||||||
Client *sel = globalconf.focus->client;
|
Client *sel = globalconf.focus->client;
|
||||||
|
xcb_get_property_reply_t *prop_r;
|
||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XGetWindowProperty(globalconf.display, sel->win,
|
prop_r = xcb_get_property_reply(globalconf.connection,
|
||||||
XInternAtom(globalconf.display, "_NET_WM_WINDOW_OPACITY", False),
|
xcb_get_property_unchecked(globalconf.connection,
|
||||||
0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
|
false, sel->win,
|
||||||
(unsigned char **) &data);
|
x_intern_atom(globalconf.connection, "_NET_WM_WINDOW_OPACITY"),
|
||||||
if(data)
|
CARDINAL,
|
||||||
|
0, 1),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if(prop_r)
|
||||||
{
|
{
|
||||||
memcpy(¤t_opacity_raw, data, sizeof(unsigned int));
|
memcpy(¤t_opacity_raw, xcb_get_property_value(prop_r), sizeof(unsigned int));
|
||||||
XFree(data);
|
|
||||||
current_opacity = (double) current_opacity_raw / 0xffffffff;
|
current_opacity = (double) current_opacity_raw / 0xffffffff;
|
||||||
|
p_delete(&prop_r);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
set_prop = 1;
|
set_prop = 1;
|
||||||
|
@ -829,7 +831,7 @@ uicb_client_settrans(int screen __attribute__ ((unused)), char *arg)
|
||||||
* \return next or previous client
|
* \return next or previous client
|
||||||
*/
|
*/
|
||||||
static Client *
|
static Client *
|
||||||
client_find_visible(Client *sel, Bool reverse)
|
client_find_visible(Client *sel, bool reverse)
|
||||||
{
|
{
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *(*client_iter)(Client **, Client *) = client_list_next_cycle;
|
Client *(*client_iter)(Client **, Client *) = client_list_next_cycle;
|
||||||
|
@ -858,10 +860,10 @@ uicb_client_swapprev(int screen __attribute__ ((unused)), char *arg __attribute_
|
||||||
{
|
{
|
||||||
Client *prev;
|
Client *prev;
|
||||||
|
|
||||||
if((prev = client_find_visible(globalconf.focus->client, True)))
|
if((prev = client_find_visible(globalconf.focus->client, true)))
|
||||||
{
|
{
|
||||||
client_list_swap(&globalconf.clients, prev, globalconf.focus->client);
|
client_list_swap(&globalconf.clients, prev, globalconf.focus->client);
|
||||||
globalconf.screens[prev->screen].need_arrange = True;
|
globalconf.screens[prev->screen].need_arrange = true;
|
||||||
widget_invalidate_cache(prev->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(prev->screen, WIDGET_CACHE_CLIENTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -876,10 +878,10 @@ uicb_client_swapnext(int screen __attribute__ ((unused)), char *arg __attribute_
|
||||||
{
|
{
|
||||||
Client *next;
|
Client *next;
|
||||||
|
|
||||||
if((next = client_find_visible(globalconf.focus->client, False)))
|
if((next = client_find_visible(globalconf.focus->client, false)))
|
||||||
{
|
{
|
||||||
client_list_swap(&globalconf.clients, globalconf.focus->client, next);
|
client_list_swap(&globalconf.clients, globalconf.focus->client, next);
|
||||||
globalconf.screens[next->screen].need_arrange = True;
|
globalconf.screens[next->screen].need_arrange = true;
|
||||||
widget_invalidate_cache(next->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(next->screen, WIDGET_CACHE_CLIENTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -895,11 +897,10 @@ uicb_client_moveresize(int screen, char *arg)
|
||||||
{
|
{
|
||||||
int ox, oy, ow, oh; /* old geometry */
|
int ox, oy, ow, oh; /* old geometry */
|
||||||
char x[8], y[8], w[8], h[8];
|
char x[8], y[8], w[8], h[8];
|
||||||
int mx, my, dx, dy, nmx, nmy;
|
int nmx, nmy;
|
||||||
unsigned int dui;
|
|
||||||
Window dummy;
|
|
||||||
area_t geometry;
|
area_t geometry;
|
||||||
Client *sel = globalconf.focus->client;
|
Client *sel = globalconf.focus->client;
|
||||||
|
xcb_query_pointer_reply_t *xqp;
|
||||||
Layout *curlay = layout_get_current(screen);
|
Layout *curlay = layout_get_current(screen);
|
||||||
|
|
||||||
if(!sel || sel->isfixed || !arg ||
|
if(!sel || sel->isfixed || !arg ||
|
||||||
|
@ -919,27 +920,27 @@ uicb_client_moveresize(int screen, char *arg)
|
||||||
ow = sel->geometry.width;
|
ow = sel->geometry.width;
|
||||||
oh = sel->geometry.height;
|
oh = sel->geometry.height;
|
||||||
|
|
||||||
Bool xqp = XQueryPointer(globalconf.display,
|
xqp = xcb_query_pointer_reply(globalconf.connection,
|
||||||
RootWindow(globalconf.display,
|
xcb_query_pointer_unchecked(globalconf.connection,
|
||||||
sel->phys_screen),
|
root_window(globalconf.connection, sel->phys_screen)),
|
||||||
&dummy, &dummy, &mx, &my, &dx, &dy, &dui);
|
NULL);
|
||||||
if(globalconf.screens[sel->screen].resize_hints)
|
if(globalconf.screens[sel->screen].resize_hints)
|
||||||
geometry = client_geometry_hints(sel, geometry);
|
geometry = client_geometry_hints(sel, geometry);
|
||||||
client_resize(sel, geometry, False);
|
client_resize(sel, geometry, false);
|
||||||
if (xqp && ox <= mx && (ox + 2 * sel->border + ow) >= mx &&
|
if (xqp && ox <= xqp->root_x && (ox + 2 * sel->border + ow) >= xqp->root_x &&
|
||||||
oy <= my && (oy + 2 * sel->border + oh) >= my)
|
oy <= xqp->root_y && (oy + 2 * sel->border + oh) >= xqp->root_y)
|
||||||
{
|
{
|
||||||
nmx = mx - (ox + sel->border) + sel->geometry.width - ow;
|
nmx = xqp->root_x - (ox + sel->border) + sel->geometry.width - ow;
|
||||||
nmy = my - (oy + sel->border) + sel->geometry.height - oh;
|
nmy = xqp->root_y - (oy + sel->border) + sel->geometry.height - oh;
|
||||||
|
|
||||||
if(nmx < -sel->border) /* can happen on a resize */
|
if(nmx < -sel->border) /* can happen on a resize */
|
||||||
nmx = -sel->border;
|
nmx = -sel->border;
|
||||||
if(nmy < -sel->border)
|
if(nmy < -sel->border)
|
||||||
nmy = -sel->border;
|
nmy = -sel->border;
|
||||||
|
|
||||||
XWarpPointer(globalconf.display,
|
xcb_warp_pointer(globalconf.connection,
|
||||||
None, sel->win,
|
XCB_NONE, sel->win,
|
||||||
0, 0, 0, 0, nmx, nmy);
|
0, 0, 0, 0, nmx, nmy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,20 +951,24 @@ uicb_client_moveresize(int screen, char *arg)
|
||||||
void
|
void
|
||||||
client_kill(Client *c)
|
client_kill(Client *c)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
xcb_client_message_event_t ev;
|
||||||
|
|
||||||
if(client_isprotodel(globalconf.display, c->win))
|
if(client_isprotodel(globalconf.connection, c->win))
|
||||||
{
|
{
|
||||||
ev.type = ClientMessage;
|
ev.window = c->win;
|
||||||
ev.xclient.window = c->win;
|
ev.type = x_intern_atom(globalconf.connection, "WM_PROTOCOLS");
|
||||||
ev.xclient.message_type = XInternAtom(globalconf.display, "WM_PROTOCOLS", False);
|
|
||||||
ev.xclient.format = 32;
|
ev.data.data32[0] = x_intern_atom(globalconf.connection, "WM_DELETE_WINDOW");
|
||||||
ev.xclient.data.l[0] = XInternAtom(globalconf.display, "WM_DELETE_WINDOW", False);
|
ev.data.data32[1] = XCB_CURRENT_TIME;
|
||||||
ev.xclient.data.l[1] = CurrentTime;
|
|
||||||
XSendEvent(globalconf.display, c->win, False, NoEventMask, &ev);
|
/* TODO: really useful? */
|
||||||
|
ev.data.data32[2] = ev.data.data32[3] = ev.data.data32[4] = 0;
|
||||||
|
|
||||||
|
xcb_send_event(globalconf.connection, false, c->win,
|
||||||
|
XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
XKillClient(globalconf.display, c->win);
|
xcb_kill_client(globalconf.connection, c->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Kill the currently focused client.
|
/** Kill the currently focused client.
|
||||||
|
@ -994,25 +999,26 @@ client_maximize(Client *c, area_t geometry)
|
||||||
c->wasfloating = c->isfloating;
|
c->wasfloating = c->isfloating;
|
||||||
c->m_geometry = c->geometry;
|
c->m_geometry = c->geometry;
|
||||||
if(layout_get_current(c->screen)->arrange != layout_floating)
|
if(layout_get_current(c->screen)->arrange != layout_floating)
|
||||||
client_setfloating(c, True, LAYER_FULLSCREEN);
|
client_setfloating(c, true, LAYER_FULLSCREEN);
|
||||||
client_focus(c, c->screen, True);
|
client_focus(c, c->screen, true);
|
||||||
client_resize(c, geometry, False);
|
client_resize(c, geometry, false);
|
||||||
}
|
}
|
||||||
else if(c->wasfloating)
|
else if(c->wasfloating)
|
||||||
{
|
{
|
||||||
c->titlebar.position = c->titlebar.dposition;
|
c->titlebar.position = c->titlebar.dposition;
|
||||||
client_setfloating(c, True, LAYER_FULLSCREEN);
|
client_setfloating(c, true, LAYER_FULLSCREEN);
|
||||||
client_resize(c, c->m_geometry, False);
|
client_resize(c, c->m_geometry, false);
|
||||||
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
}
|
}
|
||||||
else if(layout_get_current(c->screen)->arrange == layout_floating)
|
else if(layout_get_current(c->screen)->arrange == layout_floating)
|
||||||
{
|
{
|
||||||
c->titlebar.position = c->titlebar.dposition;
|
c->titlebar.position = c->titlebar.dposition;
|
||||||
client_resize(c, c->m_geometry, False);
|
client_resize(c, c->m_geometry, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c->titlebar.position = c->titlebar.dposition;
|
c->titlebar.position = c->titlebar.dposition;
|
||||||
client_setfloating(c, False, LAYER_TILE);
|
client_setfloating(c, false, LAYER_TILE);
|
||||||
}
|
}
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
}
|
}
|
||||||
|
@ -1104,7 +1110,7 @@ uicb_client_zoom(int screen, char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
client_list_detach(&globalconf.clients, sel);
|
client_list_detach(&globalconf.clients, sel);
|
||||||
client_list_push(&globalconf.clients, sel);
|
client_list_push(&globalconf.clients, sel);
|
||||||
globalconf.screens[screen].need_arrange = True;
|
globalconf.screens[screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1118,8 +1124,8 @@ uicb_client_focusnext(int screen, char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
Client *next;
|
Client *next;
|
||||||
|
|
||||||
if((next = client_find_visible(globalconf.focus->client, False)))
|
if((next = client_find_visible(globalconf.focus->client, false)))
|
||||||
client_focus(next, screen, True);
|
client_focus(next, screen, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Give focus to the previous visible client in the stack.
|
/** Give focus to the previous visible client in the stack.
|
||||||
|
@ -1132,8 +1138,8 @@ uicb_client_focusprev(int screen, char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
Client *prev;
|
Client *prev;
|
||||||
|
|
||||||
if((prev = client_find_visible(globalconf.focus->client, True)))
|
if((prev = client_find_visible(globalconf.focus->client, true)))
|
||||||
client_focus(prev, screen, True);
|
client_focus(prev, screen, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Toggle the floating state of the focused client.
|
/** Toggle the floating state of the focused client.
|
||||||
|
@ -1166,7 +1172,7 @@ uicb_client_setscratch(int screen, char *arg __attribute__ ((unused)))
|
||||||
globalconf.scratch.client = globalconf.focus->client;
|
globalconf.scratch.client = globalconf.focus->client;
|
||||||
|
|
||||||
widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS | WIDGET_CACHE_TAGS);
|
widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS | WIDGET_CACHE_TAGS);
|
||||||
globalconf.screens[screen].need_arrange = True;
|
globalconf.screens[screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Toggle the scratch client's visibility.
|
/** Toggle the scratch client's visibility.
|
||||||
|
@ -1181,8 +1187,8 @@ uicb_client_togglescratch(int screen, char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
globalconf.scratch.isvisible = !globalconf.scratch.isvisible;
|
globalconf.scratch.isvisible = !globalconf.scratch.isvisible;
|
||||||
if(globalconf.scratch.isvisible)
|
if(globalconf.scratch.isvisible)
|
||||||
client_focus(globalconf.scratch.client, screen, True);
|
client_focus(globalconf.scratch.client, screen, true);
|
||||||
globalconf.screens[globalconf.scratch.client->screen].need_arrange = True;
|
globalconf.screens[globalconf.scratch.client->screen].need_arrange = true;
|
||||||
widget_invalidate_cache(globalconf.scratch.client->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(globalconf.scratch.client->screen, WIDGET_CACHE_CLIENTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
client.h
18
client.h
|
@ -22,24 +22,28 @@
|
||||||
#ifndef AWESOME_CLIENT_H
|
#ifndef AWESOME_CLIENT_H
|
||||||
#define AWESOME_CLIENT_H
|
#define AWESOME_CLIENT_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <xcb/xcb_icccm.h>
|
||||||
|
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
Bool client_isvisible(Client *, int);
|
bool client_isvisible(Client *, int);
|
||||||
Client * client_get_bywin(Client *, Window);
|
Client * client_get_bywin(Client *, xcb_window_t);
|
||||||
Client * client_get_byname(Client *, char *);
|
Client * client_get_byname(Client *, char *);
|
||||||
Bool client_focus(Client *, int, Bool);
|
bool client_focus(Client *, int, bool);
|
||||||
void client_stack(Client *);
|
void client_stack(Client *);
|
||||||
void client_ban(Client *);
|
void client_ban(Client *);
|
||||||
void client_unban(Client *);
|
void client_unban(Client *);
|
||||||
void client_manage(Window, XWindowAttributes *, int);
|
void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, int);
|
||||||
Bool client_resize(Client *, area_t, Bool);
|
bool client_resize(Client *, area_t, bool);
|
||||||
void client_unmanage(Client *);
|
void client_unmanage(Client *);
|
||||||
void client_updatewmhints(Client *);
|
void client_updatewmhints(Client *);
|
||||||
long client_updatesizehints(Client *);
|
xcb_size_hints_t *client_updatesizehints(Client *);
|
||||||
void client_updatetitle(Client *);
|
void client_updatetitle(Client *);
|
||||||
void client_saveprops(Client *);
|
void client_saveprops(Client *);
|
||||||
void client_kill(Client *);
|
void client_kill(Client *);
|
||||||
void client_setfloating(Client *, Bool, Layer);
|
void client_setfloating(Client *, bool, Layer);
|
||||||
|
|
||||||
Uicb uicb_client_kill;
|
Uicb uicb_client_kill;
|
||||||
Uicb uicb_client_moveresize;
|
Uicb uicb_client_moveresize;
|
||||||
|
|
|
@ -235,7 +235,7 @@ cfg_opt_t mouse_taglist_opts[] =
|
||||||
/** Modifier keys. */
|
/** Modifier keys. */
|
||||||
CFG_STR_LIST((char *) "modkey", (char *) "{}", CFGF_NONE),
|
CFG_STR_LIST((char *) "modkey", (char *) "{}", CFGF_NONE),
|
||||||
/** Mouse button. */
|
/** Mouse button. */
|
||||||
CFG_STR((char *) "button", (char *) "None", CFGF_NONE),
|
CFG_STR((char *) "button", (char *) "XCB_NONE", CFGF_NONE),
|
||||||
/** Uicb command to run. */
|
/** Uicb command to run. */
|
||||||
CFG_STR((char *) "command", NULL, CFGF_NONE),
|
CFG_STR((char *) "command", NULL, CFGF_NONE),
|
||||||
CFG_AWESOME_END()
|
CFG_AWESOME_END()
|
||||||
|
@ -246,7 +246,7 @@ cfg_opt_t mouse_generic_opts[] =
|
||||||
/** Modifier keys. */
|
/** Modifier keys. */
|
||||||
CFG_STR_LIST((char *) "modkey", (char *) "{}", CFGF_NONE),
|
CFG_STR_LIST((char *) "modkey", (char *) "{}", CFGF_NONE),
|
||||||
/** Mouse button. */
|
/** Mouse button. */
|
||||||
CFG_STR((char *) "button", (char *) "None", CFGF_NONE),
|
CFG_STR((char *) "button", (char *) "XCB_NONE", CFGF_NONE),
|
||||||
/** Uicb command to run. */
|
/** Uicb command to run. */
|
||||||
CFG_STR((char *) "command", NULL, CFGF_NONE),
|
CFG_STR((char *) "command", NULL, CFGF_NONE),
|
||||||
/** Argument to use for command. */
|
/** Argument to use for command. */
|
||||||
|
@ -580,7 +580,7 @@ cfg_opt_t key_opts[] =
|
||||||
/** Modifier keys. */
|
/** Modifier keys. */
|
||||||
CFG_STR_LIST((char *) "modkey", (char *) "", CFGF_NONE),
|
CFG_STR_LIST((char *) "modkey", (char *) "", CFGF_NONE),
|
||||||
/** Key to press. */
|
/** Key to press. */
|
||||||
CFG_STR((char *) "key", (char *) "None", CFGF_NONE),
|
CFG_STR((char *) "key", (char *) "XCB_NONE", CFGF_NONE),
|
||||||
/** Uicb command to run. */
|
/** Uicb command to run. */
|
||||||
CFG_STR((char *) "command", (char *) "", CFGF_NONE),
|
CFG_STR((char *) "command", (char *) "", CFGF_NONE),
|
||||||
/** Argument to use for command. */
|
/** Argument to use for command. */
|
||||||
|
|
149
common/draw.c
149
common/draw.c
|
@ -19,7 +19,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cairo-xlib.h>
|
#include <cairo-xcb.h>
|
||||||
|
|
||||||
#ifdef HAVE_GTK
|
#ifdef HAVE_GTK
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
@ -27,14 +28,19 @@
|
||||||
#include <Imlib2.h>
|
#include <Imlib2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
#include "common/xutil.h"
|
||||||
|
|
||||||
/** Convert text from any charset to UTF-8 using iconv
|
/** Convert text from any charset to UTF-8 using iconv
|
||||||
* \param iso the ISO string to convert
|
* \param iso the ISO string to convert
|
||||||
|
@ -80,8 +86,27 @@ draw_iso2utf8(char *iso)
|
||||||
return utf8p;
|
return utf8p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static xcb_visualtype_t *
|
||||||
|
default_visual_from_screen(xcb_screen_t *s)
|
||||||
|
{
|
||||||
|
xcb_depth_iterator_t depth_iter;
|
||||||
|
xcb_visualtype_iterator_t visual_iter;
|
||||||
|
|
||||||
|
if(!s)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for(depth_iter = xcb_screen_allowed_depths_iterator(s);
|
||||||
|
depth_iter.rem; xcb_depth_next (&depth_iter))
|
||||||
|
for(visual_iter = xcb_depth_visuals_iterator (depth_iter.data);
|
||||||
|
visual_iter.rem; xcb_visualtype_next (&visual_iter))
|
||||||
|
if (s->root_visual == visual_iter.data->visual_id)
|
||||||
|
return visual_iter.data;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get a draw context
|
/** Get a draw context
|
||||||
* \param disp Display ref
|
* \param conn Connection ref
|
||||||
* \param phys_screen physical screen id
|
* \param phys_screen physical screen id
|
||||||
* \param width width
|
* \param width width
|
||||||
* \param height height
|
* \param height height
|
||||||
|
@ -89,18 +114,19 @@ draw_iso2utf8(char *iso)
|
||||||
* \return draw context ref
|
* \return draw context ref
|
||||||
*/
|
*/
|
||||||
DrawCtx *
|
DrawCtx *
|
||||||
draw_context_new(Display *disp, int phys_screen, int width, int height, Drawable dw)
|
draw_context_new(xcb_connection_t *conn, int phys_screen, int width, int height, xcb_drawable_t dw)
|
||||||
{
|
{
|
||||||
DrawCtx *d = p_new(DrawCtx, 1);
|
DrawCtx *d = p_new(DrawCtx, 1);
|
||||||
|
xcb_screen_t *s = xcb_aux_get_screen(conn, phys_screen);
|
||||||
|
|
||||||
d->display = disp;
|
d->connection = conn;
|
||||||
d->phys_screen = phys_screen;
|
d->phys_screen = phys_screen;
|
||||||
d->width = width;
|
d->width = width;
|
||||||
d->height = height;
|
d->height = height;
|
||||||
d->depth = DefaultDepth(disp, phys_screen);
|
d->depth = s->root_depth;
|
||||||
d->visual = DefaultVisual(disp, phys_screen);
|
d->visual = default_visual_from_screen(s);
|
||||||
d->drawable = dw;
|
d->drawable = dw;
|
||||||
d->surface = cairo_xlib_surface_create(disp, dw, d->visual, width, height);
|
d->surface = cairo_xcb_surface_create(conn, dw, d->visual, width, height);
|
||||||
d->cr = cairo_create(d->surface);
|
d->cr = cairo_create(d->surface);
|
||||||
d->layout = pango_cairo_create_layout(d->cr);
|
d->layout = pango_cairo_create_layout(d->cr);
|
||||||
|
|
||||||
|
@ -120,25 +146,26 @@ draw_context_delete(DrawCtx **ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a new Pango font
|
/** Create a new Pango font
|
||||||
* \param disp Display ref
|
* \param conn Connection ref
|
||||||
* \param fontname Pango fontname (e.g. [FAMILY-LIST] [STYLE-OPTIONS] [SIZE])
|
* \param fontname Pango fontname (e.g. [FAMILY-LIST] [STYLE-OPTIONS] [SIZE])
|
||||||
* \return a new font
|
* \return a new font
|
||||||
*/
|
*/
|
||||||
font_t *
|
font_t *
|
||||||
draw_font_new(Display *disp, char *fontname)
|
draw_font_new(xcb_connection_t *conn, int phys_screen, char *fontname)
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
xcb_screen_t *s = xcb_aux_get_screen(conn, phys_screen);
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
font_t *font = p_new(font_t, 1);
|
font_t *font = p_new(font_t, 1);
|
||||||
|
|
||||||
/* Create a dummy cairo surface, cairo context and pango layout in
|
/* Create a dummy cairo surface, cairo context and pango layout in
|
||||||
* order to get font informations */
|
* order to get font informations */
|
||||||
surface = cairo_xlib_surface_create(disp,
|
surface = cairo_xcb_surface_create(conn,
|
||||||
DefaultScreen(disp),
|
phys_screen,
|
||||||
DefaultVisual(disp, DefaultScreen(disp)),
|
default_visual_from_screen(s),
|
||||||
DisplayWidth(disp, DefaultScreen(disp)),
|
s->width_in_pixels,
|
||||||
DisplayHeight(disp, DefaultScreen(disp)));
|
s->height_in_pixels);
|
||||||
|
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
layout = pango_cairo_create_layout(cr);
|
layout = pango_cairo_create_layout(cr);
|
||||||
|
@ -207,7 +234,7 @@ draw_text(DrawCtx *ctx,
|
||||||
ssize_t len, olen;
|
ssize_t len, olen;
|
||||||
char *buf = NULL, *utf8 = NULL;
|
char *buf = NULL, *utf8 = NULL;
|
||||||
|
|
||||||
draw_rectangle(ctx, area, 1.0, True, style.bg);
|
draw_rectangle(ctx, area, 1.0, true, style.bg);
|
||||||
|
|
||||||
if(!(len = olen = a_strlen(text)))
|
if(!(len = olen = a_strlen(text)))
|
||||||
return;
|
return;
|
||||||
|
@ -222,7 +249,7 @@ draw_text(DrawCtx *ctx,
|
||||||
buf = a_strdup(text);
|
buf = a_strdup(text);
|
||||||
|
|
||||||
/* check that the text is not too long */
|
/* check that the text is not too long */
|
||||||
while(len && (nw = (draw_textwidth(ctx->display, style.font, buf)) + padding * 2) > area.width)
|
while(len && (nw = (draw_textwidth(ctx->connection, ctx->default_screen, style.font, buf)) + padding * 2) > area.width)
|
||||||
{
|
{
|
||||||
len--;
|
len--;
|
||||||
/* we can't blindly null the char, we need to check if it's not part of
|
/* we can't blindly null the char, we need to check if it's not part of
|
||||||
|
@ -297,8 +324,8 @@ draw_text(DrawCtx *ctx,
|
||||||
*/
|
*/
|
||||||
static cairo_pattern_t *
|
static cairo_pattern_t *
|
||||||
draw_setup_cairo_color_source(DrawCtx *ctx, area_t rect,
|
draw_setup_cairo_color_source(DrawCtx *ctx, area_t rect,
|
||||||
XColor *pcolor, XColor *pcolor_center,
|
xcolor_t *pcolor, xcolor_t *pcolor_center,
|
||||||
XColor *pcolor_end)
|
xcolor_t *pcolor_end)
|
||||||
{
|
{
|
||||||
cairo_pattern_t *pat = NULL;
|
cairo_pattern_t *pat = NULL;
|
||||||
|
|
||||||
|
@ -336,7 +363,7 @@ draw_setup_cairo_color_source(DrawCtx *ctx, area_t rect,
|
||||||
* \param color color to use
|
* \param color color to use
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
draw_rectangle(DrawCtx *ctx, area_t geometry, float line_width, Bool filled, XColor color)
|
draw_rectangle(DrawCtx *ctx, area_t geometry, float line_width, bool filled, xcolor_t color)
|
||||||
{
|
{
|
||||||
cairo_set_antialias(ctx->cr, CAIRO_ANTIALIAS_NONE);
|
cairo_set_antialias(ctx->cr, CAIRO_ANTIALIAS_NONE);
|
||||||
cairo_set_line_width(ctx->cr, line_width);
|
cairo_set_line_width(ctx->cr, line_width);
|
||||||
|
@ -372,9 +399,9 @@ draw_rectangle(DrawCtx *ctx, area_t geometry, float line_width, Bool filled, XCo
|
||||||
* \param pcolor_end color at pattern_start + pattern_width
|
* \param pcolor_end color at pattern_start + pattern_width
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
draw_rectangle_gradient(DrawCtx *ctx, area_t geometry, float line_width, Bool filled,
|
draw_rectangle_gradient(DrawCtx *ctx, area_t geometry, float line_width, bool filled,
|
||||||
area_t pattern_rect, XColor *pcolor,
|
area_t pattern_rect, xcolor_t *pcolor,
|
||||||
XColor *pcolor_center, XColor *pcolor_end)
|
xcolor_t *pcolor_center, xcolor_t *pcolor_end)
|
||||||
{
|
{
|
||||||
cairo_pattern_t *pat;
|
cairo_pattern_t *pat;
|
||||||
|
|
||||||
|
@ -430,7 +457,7 @@ draw_graph_setup(DrawCtx *ctx)
|
||||||
void
|
void
|
||||||
draw_graph(DrawCtx *ctx, area_t rect, int *from, int *to, int cur_index,
|
draw_graph(DrawCtx *ctx, area_t rect, int *from, int *to, int cur_index,
|
||||||
Position grow, area_t patt_rect,
|
Position grow, area_t patt_rect,
|
||||||
XColor *pcolor, XColor *pcolor_center, XColor *pcolor_end)
|
xcolor_t *pcolor, xcolor_t *pcolor_center, xcolor_t *pcolor_end)
|
||||||
{
|
{
|
||||||
int i, y, w;
|
int i, y, w;
|
||||||
float x;
|
float x;
|
||||||
|
@ -492,7 +519,7 @@ draw_graph(DrawCtx *ctx, area_t rect, int *from, int *to, int cur_index,
|
||||||
void
|
void
|
||||||
draw_graph_line(DrawCtx *ctx, area_t rect, int *to, int cur_index,
|
draw_graph_line(DrawCtx *ctx, area_t rect, int *to, int cur_index,
|
||||||
Position grow, area_t patt_rect,
|
Position grow, area_t patt_rect,
|
||||||
XColor *pcolor, XColor *pcolor_center, XColor *pcolor_end)
|
xcolor_t *pcolor, xcolor_t *pcolor_center, xcolor_t *pcolor_end)
|
||||||
{
|
{
|
||||||
int i, w;
|
int i, w;
|
||||||
float x, y;
|
float x, y;
|
||||||
|
@ -564,7 +591,7 @@ draw_graph_line(DrawCtx *ctx, area_t rect, int *to, int cur_index,
|
||||||
* \param color color to use
|
* \param color color to use
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
draw_circle(DrawCtx *ctx, int x, int y, int r, Bool filled, XColor color)
|
draw_circle(DrawCtx *ctx, int x, int y, int r, bool filled, xcolor_t color)
|
||||||
{
|
{
|
||||||
cairo_set_line_width(ctx->cr, 1.0);
|
cairo_set_line_width(ctx->cr, 1.0);
|
||||||
cairo_set_source_rgb(ctx->cr, color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0);
|
cairo_set_source_rgb(ctx->cr, color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0);
|
||||||
|
@ -811,16 +838,16 @@ draw_get_image_size(const char *filename)
|
||||||
* \return new rotated drawable
|
* \return new rotated drawable
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
draw_rotate(DrawCtx *ctx, Drawable dest, int dest_w, int dest_h,
|
draw_rotate(DrawCtx *ctx, xcb_drawable_t dest, int dest_w, int dest_h,
|
||||||
double angle, int tx, int ty)
|
double angle, int tx, int ty)
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface, *source;
|
cairo_surface_t *surface, *source;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
surface = cairo_xlib_surface_create(ctx->display, dest,
|
surface = cairo_xcb_surface_create(ctx->connection, dest,
|
||||||
ctx->visual, dest_w, dest_h);
|
ctx->visual, dest_w, dest_h);
|
||||||
source = cairo_xlib_surface_create(ctx->display, ctx->drawable,
|
source = cairo_xcb_surface_create(ctx->connection, ctx->drawable,
|
||||||
ctx->visual, ctx->width, ctx->height);
|
ctx->visual, ctx->width, ctx->height);
|
||||||
cr = cairo_create (surface);
|
cr = cairo_create (surface);
|
||||||
|
|
||||||
cairo_translate(cr, tx, ty);
|
cairo_translate(cr, tx, ty);
|
||||||
|
@ -835,26 +862,27 @@ draw_rotate(DrawCtx *ctx, Drawable dest, int dest_w, int dest_h,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the width of a text in pixel
|
/** Return the width of a text in pixel
|
||||||
* \param disp Display ref
|
* \param conn Connection ref
|
||||||
* \param font font to use
|
* \param font font to use
|
||||||
* \param text the text
|
* \param text the text
|
||||||
* \return text width
|
* \return text width
|
||||||
*/
|
*/
|
||||||
unsigned short
|
unsigned short
|
||||||
draw_textwidth(Display *disp, font_t *font, const char *text)
|
draw_textwidth(xcb_connection_t *conn, int default_screen, font_t *font, const char *text)
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
PangoRectangle ext;
|
PangoRectangle ext;
|
||||||
|
xcb_screen_t *s = xcb_aux_get_screen(conn, default_screen);
|
||||||
|
|
||||||
if(!a_strlen(text))
|
if(!a_strlen(text))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
surface = cairo_xlib_surface_create(disp, DefaultScreen(disp),
|
surface = cairo_xcb_surface_create(conn, default_screen,
|
||||||
DefaultVisual(disp, DefaultScreen(disp)),
|
default_visual_from_screen(s),
|
||||||
DisplayWidth(disp, DefaultScreen(disp)),
|
s->width_in_pixels,
|
||||||
DisplayHeight(disp, DefaultScreen(disp)));
|
s->height_in_pixels);
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
layout = pango_cairo_create_layout(cr);
|
layout = pango_cairo_create_layout(cr);
|
||||||
pango_layout_set_text(layout, text, -1);
|
pango_layout_set_text(layout, text, -1);
|
||||||
|
@ -889,29 +917,40 @@ draw_align_get_from_str(const char *align)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize an X color
|
/** Initialize an X color
|
||||||
* \param disp display ref
|
* \param conn Connection ref
|
||||||
* \param phys_screen Physical screen number
|
* \param phys_screen Physical screen number
|
||||||
* \param colstr Color specification
|
* \param colstr Color specification
|
||||||
* \param color XColor struct to store color to
|
* \param color xcolor_t struct to store color to
|
||||||
* \return true if color allocation was successfull
|
* \return true if color allocation was successfull
|
||||||
*/
|
*/
|
||||||
Bool
|
bool
|
||||||
draw_color_new(Display *disp, int phys_screen, const char *colstr, XColor *color)
|
draw_color_new(xcb_connection_t *conn, int phys_screen, const char *colstr, xcolor_t *color)
|
||||||
{
|
{
|
||||||
Bool ret;
|
xcb_alloc_named_color_reply_t *c;
|
||||||
XColor exactColor;
|
xcb_screen_t *s = xcb_aux_get_screen(conn, phys_screen);
|
||||||
|
|
||||||
if(!a_strlen(colstr))
|
if(!a_strlen(colstr))
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
if(!(ret = XAllocNamedColor(disp,
|
if((c = xcb_alloc_named_color_reply(conn,
|
||||||
DefaultColormap(disp, phys_screen),
|
xcb_alloc_named_color(conn,
|
||||||
colstr,
|
s->default_colormap,
|
||||||
color,
|
strlen(colstr),
|
||||||
&exactColor)))
|
colstr),
|
||||||
|
NULL)) == NULL)
|
||||||
|
{
|
||||||
warn("awesome: error, cannot allocate color '%s'\n", colstr);
|
warn("awesome: error, cannot allocate color '%s'\n", colstr);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
color->pixel = c->pixel;
|
||||||
|
color->red = c->visual_red;
|
||||||
|
color->green = c->visual_green;
|
||||||
|
color->blue = c->visual_blue;
|
||||||
|
|
||||||
|
p_delete(&c);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Init a style struct. Every value will be inherited from m
|
/** Init a style struct. Every value will be inherited from m
|
||||||
|
@ -923,7 +962,7 @@ draw_color_new(Display *disp, int phys_screen, const char *colstr, XColor *color
|
||||||
* \param m style to use as template
|
* \param m style to use as template
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
draw_style_init(Display *disp, int phys_screen, cfg_t *cfg,
|
draw_style_init(xcb_connection_t *conn, int phys_screen, cfg_t *cfg,
|
||||||
style_t *c, style_t *m)
|
style_t *c, style_t *m)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
|
@ -936,18 +975,18 @@ draw_style_init(Display *disp, int phys_screen, cfg_t *cfg,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if((buf = cfg_getstr(cfg, "font")))
|
if((buf = cfg_getstr(cfg, "font")))
|
||||||
c->font = draw_font_new(disp, buf);
|
c->font = draw_font_new(conn, phys_screen, buf);
|
||||||
|
|
||||||
draw_color_new(disp, phys_screen,
|
draw_color_new(conn, phys_screen,
|
||||||
cfg_getstr(cfg, "fg"), &c->fg);
|
cfg_getstr(cfg, "fg"), &c->fg);
|
||||||
|
|
||||||
draw_color_new(disp, phys_screen,
|
draw_color_new(conn, phys_screen,
|
||||||
cfg_getstr(cfg, "bg"), &c->bg);
|
cfg_getstr(cfg, "bg"), &c->bg);
|
||||||
|
|
||||||
draw_color_new(disp, phys_screen,
|
draw_color_new(conn, phys_screen,
|
||||||
cfg_getstr(cfg, "border"), &c->border);
|
cfg_getstr(cfg, "border"), &c->border);
|
||||||
|
|
||||||
draw_color_new(disp, phys_screen,
|
draw_color_new(conn, phys_screen,
|
||||||
cfg_getstr(cfg, "shadow"), &c->shadow);
|
cfg_getstr(cfg, "shadow"), &c->shadow);
|
||||||
|
|
||||||
if((shadow = cfg_getint(cfg, "shadow_offset")) != (int) 0xffffffff)
|
if((shadow = cfg_getint(cfg, "shadow_offset")) != (int) 0xffffffff)
|
||||||
|
|
|
@ -23,14 +23,15 @@
|
||||||
#define AWESOME_COMMON_DRAW_H
|
#define AWESOME_COMMON_DRAW_H
|
||||||
|
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
#include <pango/pangocairo.h>
|
||||||
|
|
||||||
#include <confuse.h>
|
#include <confuse.h>
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <xcb/xcb.h>
|
||||||
#include <pango/pangocairo.h>
|
|
||||||
|
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "common/list.h"
|
#include "common/list.h"
|
||||||
|
#include "common/xutil.h"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -59,7 +60,7 @@ DO_SLIST(area_t, area, p_delete)
|
||||||
#define AREA_RIGHT(a) ((a).x + (a).width)
|
#define AREA_RIGHT(a) ((a).x + (a).width)
|
||||||
#define AREA_BOTTOM(a) ((a).y + (a).height)
|
#define AREA_BOTTOM(a) ((a).y + (a).height)
|
||||||
|
|
||||||
static inline Bool
|
static inline bool
|
||||||
area_intersect_area(area_t a, area_t b)
|
area_intersect_area(area_t a, area_t b)
|
||||||
{
|
{
|
||||||
return (b.x < a.x + a.width
|
return (b.x < a.x + a.width
|
||||||
|
@ -90,13 +91,13 @@ typedef struct
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/** Foreground color */
|
/** Foreground color */
|
||||||
XColor fg;
|
xcolor_t fg;
|
||||||
/** Background color */
|
/** Background color */
|
||||||
XColor bg;
|
xcolor_t bg;
|
||||||
/** Shadow color */
|
/** Shadow color */
|
||||||
XColor shadow;
|
xcolor_t shadow;
|
||||||
/** Border color */
|
/** Border color */
|
||||||
XColor border;
|
xcolor_t border;
|
||||||
/** Shadow offset */
|
/** Shadow offset */
|
||||||
int shadow_offset;
|
int shadow_offset;
|
||||||
/** Font */
|
/** Font */
|
||||||
|
@ -105,9 +106,10 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Display *display;
|
xcb_connection_t *connection;
|
||||||
Drawable drawable;
|
int default_screen;
|
||||||
Visual *visual;
|
xcb_drawable_t drawable;
|
||||||
|
xcb_visualtype_t *visual;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int phys_screen;
|
int phys_screen;
|
||||||
|
@ -117,28 +119,28 @@ typedef struct
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
} DrawCtx;
|
} DrawCtx;
|
||||||
|
|
||||||
DrawCtx *draw_context_new(Display *, int, int, int, Drawable);
|
DrawCtx *draw_context_new(xcb_connection_t *, int, int, int, xcb_drawable_t);
|
||||||
void draw_context_delete(DrawCtx **);
|
void draw_context_delete(DrawCtx **);
|
||||||
|
|
||||||
font_t *draw_font_new(Display *disp, char *fontname);
|
font_t *draw_font_new(xcb_connection_t *, int, char *);
|
||||||
void draw_font_delete(font_t **);
|
void draw_font_delete(font_t **);
|
||||||
|
|
||||||
void draw_text(DrawCtx *, area_t, Alignment, int, char *, style_t);
|
void draw_text(DrawCtx *, area_t, Alignment, int, char *, style_t);
|
||||||
void draw_rectangle(DrawCtx *, area_t, float, Bool, XColor);
|
void draw_rectangle(DrawCtx *, area_t, float, bool, xcolor_t);
|
||||||
void draw_rectangle_gradient(DrawCtx *, area_t, float, Bool, area_t, XColor *, XColor *, XColor *);
|
void draw_rectangle_gradient(DrawCtx *, area_t, float, bool, area_t, xcolor_t *, xcolor_t *, xcolor_t *);
|
||||||
|
|
||||||
void draw_graph_setup(DrawCtx *);
|
void draw_graph_setup(DrawCtx *);
|
||||||
void draw_graph(DrawCtx *, area_t, int *, int *, int, Position, area_t, XColor *, XColor *, XColor *);
|
void draw_graph(DrawCtx *, area_t, int *, int *, int, Position, area_t, xcolor_t *, xcolor_t *, xcolor_t *);
|
||||||
void draw_graph_line(DrawCtx *, area_t, int *, int, Position, area_t, XColor *, XColor *, XColor *);
|
void draw_graph_line(DrawCtx *, area_t, int *, int, Position, area_t, xcolor_t *, xcolor_t *, xcolor_t *);
|
||||||
void draw_circle(DrawCtx *, int, int, int, Bool, XColor);
|
void draw_circle(DrawCtx *, int, int, int, bool, xcolor_t);
|
||||||
void draw_image(DrawCtx *, int, int, int, const char *);
|
void draw_image(DrawCtx *, int, int, int, const char *);
|
||||||
void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *);
|
void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *);
|
||||||
area_t draw_get_image_size(const char *filename);
|
area_t draw_get_image_size(const char *filename);
|
||||||
void draw_rotate(DrawCtx *, Drawable, int, int, double, int, int);
|
void draw_rotate(DrawCtx *, xcb_drawable_t, int, int, double, int, int);
|
||||||
unsigned short draw_textwidth(Display *, font_t *, const char *);
|
unsigned short draw_textwidth(xcb_connection_t *, int, font_t *, const char *);
|
||||||
Alignment draw_align_get_from_str(const char *);
|
Alignment draw_align_get_from_str(const char *);
|
||||||
Bool draw_color_new(Display *, int, const char *, XColor *);
|
bool draw_color_new(xcb_connection_t *, int, const char *, xcolor_t *);
|
||||||
void draw_style_init(Display *, int, cfg_t *, style_t *, style_t *);
|
void draw_style_init(xcb_connection_t *, int, cfg_t *, style_t *, style_t *);
|
||||||
|
|
||||||
void area_list_remove(area_t **, area_t *);
|
void area_list_remove(area_t **, area_t *);
|
||||||
|
|
||||||
|
|
106
common/swindow.c
106
common/swindow.c
|
@ -19,12 +19,14 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
|
||||||
#include "common/swindow.h"
|
#include "common/swindow.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
|
||||||
/** Create a simple window
|
/** Create a simple window
|
||||||
* \param disp Display ref
|
* \param conn Connection ref
|
||||||
* \param phys_screen physical screen id
|
* \param phys_screen physical screen id
|
||||||
* \param x x coordinate
|
* \param x x coordinate
|
||||||
* \param y y coordinate
|
* \param y y coordinate
|
||||||
|
@ -34,12 +36,13 @@
|
||||||
* \return pointer to a SimpleWindow
|
* \return pointer to a SimpleWindow
|
||||||
*/
|
*/
|
||||||
SimpleWindow *
|
SimpleWindow *
|
||||||
simplewindow_new(Display *disp, int phys_screen, int x, int y,
|
simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y,
|
||||||
unsigned int w, unsigned int h,
|
unsigned int w, unsigned int h,
|
||||||
unsigned int border_width)
|
unsigned int border_width)
|
||||||
{
|
{
|
||||||
XSetWindowAttributes wa;
|
|
||||||
SimpleWindow *sw;
|
SimpleWindow *sw;
|
||||||
|
xcb_screen_t *s = xcb_aux_get_screen(conn, phys_screen);
|
||||||
|
uint32_t create_win_val[3];
|
||||||
|
|
||||||
sw = p_new(SimpleWindow, 1);
|
sw = p_new(SimpleWindow, 1);
|
||||||
|
|
||||||
|
@ -47,30 +50,31 @@ simplewindow_new(Display *disp, int phys_screen, int x, int y,
|
||||||
sw->geometry.y = y;
|
sw->geometry.y = y;
|
||||||
sw->geometry.width = w;
|
sw->geometry.width = w;
|
||||||
sw->geometry.height = h;
|
sw->geometry.height = h;
|
||||||
sw->display = disp;
|
sw->connection = conn;
|
||||||
sw->phys_screen = phys_screen;
|
sw->phys_screen = phys_screen;
|
||||||
|
|
||||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
create_win_val[0] = XCB_BACK_PIXMAP_PARENT_RELATIVE;
|
||||||
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask
|
create_win_val[1] = 1;
|
||||||
| ButtonPressMask | ExposureMask;
|
create_win_val[2] = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
|
||||||
wa.override_redirect = 1;
|
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_ENTER_WINDOW |
|
||||||
wa.background_pixmap = ParentRelative;
|
XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
|
||||||
sw->window = XCreateWindow(disp,
|
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_EXPOSURE;
|
||||||
RootWindow(disp, phys_screen),
|
|
||||||
x, y, w, h,
|
|
||||||
border_width,
|
|
||||||
DefaultDepth(disp, phys_screen),
|
|
||||||
CopyFromParent,
|
|
||||||
DefaultVisual(disp, phys_screen),
|
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask,
|
|
||||||
&wa);
|
|
||||||
|
|
||||||
XSelectInput(disp, sw->window, wa.event_mask);
|
sw->window = xcb_generate_id(conn);
|
||||||
|
xcb_create_window(conn, s->root_depth, sw->window,
|
||||||
|
root_window(conn, phys_screen),
|
||||||
|
x, y, w, h, border_width,
|
||||||
|
XCB_COPY_FROM_PARENT,
|
||||||
|
s->root_visual,
|
||||||
|
XCB_CW_BACK_PIXMAP | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
|
||||||
|
create_win_val);
|
||||||
|
|
||||||
|
x_select_input(conn, sw->window, create_win_val[2]);
|
||||||
|
|
||||||
|
sw->drawable = xcb_generate_id(conn);
|
||||||
|
xcb_create_pixmap(conn, s->root_depth, sw->drawable,
|
||||||
|
root_window(conn, phys_screen), w, h);
|
||||||
|
|
||||||
sw->drawable = XCreatePixmap(disp,
|
|
||||||
RootWindow(disp, phys_screen),
|
|
||||||
w, h,
|
|
||||||
DefaultDepth(disp, phys_screen));
|
|
||||||
return sw;
|
return sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +84,8 @@ simplewindow_new(Display *disp, int phys_screen, int x, int y,
|
||||||
void
|
void
|
||||||
simplewindow_delete(SimpleWindow **sw)
|
simplewindow_delete(SimpleWindow **sw)
|
||||||
{
|
{
|
||||||
XDestroyWindow((*sw)->display, (*sw)->window);
|
xcb_destroy_window((*sw)->connection, (*sw)->window);
|
||||||
XFreePixmap((*sw)->display, (*sw)->drawable);
|
xcb_free_pixmap((*sw)->connection, (*sw)->drawable);
|
||||||
p_delete(sw);
|
p_delete(sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,49 +93,63 @@ simplewindow_delete(SimpleWindow **sw)
|
||||||
* \param sw the SimpleWindow to move
|
* \param sw the SimpleWindow to move
|
||||||
* \param x x coordinate
|
* \param x x coordinate
|
||||||
* \param y y coordinate
|
* \param y y coordinate
|
||||||
* \return status
|
|
||||||
*/
|
*/
|
||||||
int
|
void
|
||||||
simplewindow_move(SimpleWindow *sw, int x, int y)
|
simplewindow_move(SimpleWindow *sw, int x, int y)
|
||||||
{
|
{
|
||||||
|
const uint32_t move_win_vals[] = { x, y };
|
||||||
|
|
||||||
sw->geometry.x = x;
|
sw->geometry.x = x;
|
||||||
sw->geometry.y = y;
|
sw->geometry.y = y;
|
||||||
return XMoveWindow(sw->display, sw->window, x, y);
|
xcb_configure_window(sw->connection, sw->window,
|
||||||
|
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y,
|
||||||
|
move_win_vals);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resize a simple window
|
/** Resize a simple window
|
||||||
* \param sw the SimpleWindow to resize
|
* \param sw the SimpleWindow to resize
|
||||||
* \param w new width
|
* \param w new width
|
||||||
* \param h new height
|
* \param h new height
|
||||||
* \return status
|
|
||||||
*/
|
*/
|
||||||
int
|
void
|
||||||
simplewindow_resize(SimpleWindow *sw, unsigned int w, unsigned int h)
|
simplewindow_resize(SimpleWindow *sw, unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
|
xcb_screen_t *s = xcb_aux_get_screen(sw->connection, sw->phys_screen);
|
||||||
|
const uint32_t resize_win_vals[] = { w, h };
|
||||||
|
|
||||||
sw->geometry.width = w;
|
sw->geometry.width = w;
|
||||||
sw->geometry.height = h;
|
sw->geometry.height = h;
|
||||||
XFreePixmap(sw->display, sw->drawable);
|
xcb_free_pixmap(sw->connection, sw->drawable);
|
||||||
sw->drawable = XCreatePixmap(sw->display,
|
sw->drawable = xcb_generate_id(sw->connection);
|
||||||
RootWindow(sw->display, sw->phys_screen),
|
xcb_create_pixmap(sw->connection, s->root_depth, sw->drawable,
|
||||||
w, h,
|
root_window(sw->connection, sw->phys_screen), w, h);
|
||||||
DefaultDepth(sw->display, sw->phys_screen));
|
xcb_configure_window(sw->connection, sw->window,
|
||||||
return XResizeWindow(sw->display, sw->window, w, h);
|
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
|
||||||
|
resize_win_vals);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Refresh the window content
|
/** Refresh the window content
|
||||||
* \param sw the SimpleWindow to refresh
|
* \param sw the SimpleWindow to refresh
|
||||||
* \param phys_screen physical screen id
|
* \param phys_screen physical screen id
|
||||||
* \return status
|
|
||||||
*/
|
*/
|
||||||
int
|
void
|
||||||
simplewindow_refresh_drawable(SimpleWindow *sw, int phys_screen)
|
simplewindow_refresh_drawable(SimpleWindow *sw, int phys_screen)
|
||||||
{
|
{
|
||||||
return XCopyArea(sw->display, sw->drawable,
|
xcb_screen_t *s = xcb_aux_get_screen(sw->connection, phys_screen);
|
||||||
sw->window,
|
|
||||||
DefaultGC(sw->display, phys_screen), 0, 0,
|
/* The default GC is just a newly created associated to the root
|
||||||
sw->geometry.width,
|
* window */
|
||||||
sw->geometry.height,
|
xcb_drawable_t gc_draw = s->root;
|
||||||
0, 0);
|
xcb_gcontext_t gc = xcb_generate_id(sw->connection);
|
||||||
|
|
||||||
|
const uint32_t gc_mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
|
||||||
|
const uint32_t gc_values[2] = { s->black_pixel, s->white_pixel };
|
||||||
|
|
||||||
|
xcb_create_gc(sw->connection, gc, gc_draw, gc_mask, gc_values);
|
||||||
|
xcb_copy_area(sw->connection, sw->drawable,
|
||||||
|
sw->window, gc, 0, 0, 0, 0,
|
||||||
|
sw->geometry.width,
|
||||||
|
sw->geometry.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
|
@ -27,25 +27,25 @@
|
||||||
/** A simple window */
|
/** A simple window */
|
||||||
typedef struct SimpleWindow
|
typedef struct SimpleWindow
|
||||||
{
|
{
|
||||||
Display *display;
|
xcb_connection_t *connection;
|
||||||
int phys_screen;
|
int phys_screen;
|
||||||
Window window;
|
xcb_window_t window;
|
||||||
Drawable drawable;
|
xcb_drawable_t drawable;
|
||||||
area_t geometry;
|
area_t geometry;
|
||||||
} SimpleWindow;
|
} SimpleWindow;
|
||||||
|
|
||||||
SimpleWindow * simplewindow_new(Display *, int, int, int, unsigned int, unsigned int, unsigned int);
|
SimpleWindow * simplewindow_new(xcb_connection_t *, int, int, int, unsigned int, unsigned int, unsigned int);
|
||||||
void simplewindow_delete(SimpleWindow **);
|
void simplewindow_delete(SimpleWindow **);
|
||||||
int simplewindow_move(SimpleWindow *, int, int);
|
void simplewindow_move(SimpleWindow *, int, int);
|
||||||
int simplewindow_resize(SimpleWindow *, unsigned int, unsigned int);
|
void simplewindow_resize(SimpleWindow *, unsigned int, unsigned int);
|
||||||
int simplewindow_refresh_drawable(SimpleWindow *, int);
|
void simplewindow_refresh_drawable(SimpleWindow *, int);
|
||||||
|
|
||||||
static inline int
|
static inline void
|
||||||
simplewindow_move_resize(SimpleWindow *sw, int x, int y,
|
simplewindow_move_resize(SimpleWindow *sw, int x, int y,
|
||||||
unsigned int w, unsigned int h)
|
unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
return (simplewindow_move(sw, x, y)
|
simplewindow_move(sw, x, y);
|
||||||
&& simplewindow_resize(sw, w, h));
|
simplewindow_resize(sw, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <X11/extensions/Xinerama.h>
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
#include <xcb/xinerama.h>
|
||||||
|
|
||||||
#include "common/xscreen.h"
|
#include "common/xscreen.h"
|
||||||
|
|
||||||
|
@ -47,7 +49,7 @@ screen_get_bycoord(ScreensInfo *si, int screen, int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline area_t
|
static inline area_t
|
||||||
screen_xsitoarea(XineramaScreenInfo si)
|
screen_xsitoarea(xcb_xinerama_screen_info_t si)
|
||||||
{
|
{
|
||||||
area_t a;
|
area_t a;
|
||||||
|
|
||||||
|
@ -67,33 +69,57 @@ screensinfo_delete(ScreensInfo **si)
|
||||||
p_delete(si);
|
p_delete(si);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static xcb_xinerama_screen_info_t *
|
||||||
|
xinerama_query_screens(xcb_connection_t *c, int *screen_number)
|
||||||
|
{
|
||||||
|
xcb_xinerama_query_screens_reply_t *reply;
|
||||||
|
xcb_xinerama_screen_info_t *si;
|
||||||
|
|
||||||
|
reply = xcb_xinerama_query_screens_reply(c,
|
||||||
|
xcb_xinerama_query_screens_unchecked(c),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if(!reply)
|
||||||
|
{
|
||||||
|
*screen_number = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*screen_number = xcb_xinerama_query_screens_screen_info_length(reply);
|
||||||
|
si = xcb_xinerama_query_screens_screen_info(reply);
|
||||||
|
p_delete(&reply);
|
||||||
|
|
||||||
|
return si;
|
||||||
|
}
|
||||||
|
|
||||||
ScreensInfo *
|
ScreensInfo *
|
||||||
screensinfo_new(Display *disp)
|
screensinfo_new(xcb_connection_t *conn)
|
||||||
{
|
{
|
||||||
ScreensInfo *si;
|
ScreensInfo *si;
|
||||||
XineramaScreenInfo *xsi;
|
xcb_xinerama_screen_info_t *xsi;
|
||||||
int xinerama_screen_number, screen, screen_to_test;
|
int xinerama_screen_number, screen, screen_to_test;
|
||||||
Bool drop;
|
xcb_screen_t *s;
|
||||||
|
bool drop;
|
||||||
|
|
||||||
si = p_new(ScreensInfo, 1);
|
si = p_new(ScreensInfo, 1);
|
||||||
|
|
||||||
if((si->xinerama_is_active = XineramaIsActive(disp)))
|
if((si->xinerama_is_active = xinerama_is_active(conn)))
|
||||||
{
|
{
|
||||||
xsi = XineramaQueryScreens(disp, &xinerama_screen_number);
|
xsi = xinerama_query_screens(conn, &xinerama_screen_number);
|
||||||
si->geometry = p_new(area_t, xinerama_screen_number);
|
si->geometry = p_new(area_t, xinerama_screen_number);
|
||||||
si->nscreen = 0;
|
si->nscreen = 0;
|
||||||
|
|
||||||
/* now check if screens overlaps (same x,y): if so, we take only the biggest one */
|
/* now check if screens overlaps (same x,y): if so, we take only the biggest one */
|
||||||
for(screen = 0; screen < xinerama_screen_number; screen++)
|
for(screen = 0; screen < xinerama_screen_number; screen++)
|
||||||
{
|
{
|
||||||
drop = False;
|
drop = false;
|
||||||
for(screen_to_test = 0; screen_to_test < si->nscreen; screen_to_test++)
|
for(screen_to_test = 0; screen_to_test < si->nscreen; screen_to_test++)
|
||||||
if(xsi[screen].x_org == si->geometry[screen_to_test].x
|
if(xsi[screen].x_org == si->geometry[screen_to_test].x
|
||||||
&& xsi[screen].y_org == si->geometry[screen_to_test].y)
|
&& xsi[screen].y_org == si->geometry[screen_to_test].y)
|
||||||
{
|
{
|
||||||
/* we already have a screen for this area, just check if
|
/* we already have a screen for this area, just check if
|
||||||
* it's not bigger and drop it */
|
* it's not bigger and drop it */
|
||||||
drop = True;
|
drop = true;
|
||||||
si->geometry[screen_to_test].width =
|
si->geometry[screen_to_test].width =
|
||||||
MAX(xsi[screen].width, xsi[screen_to_test].width);
|
MAX(xsi[screen].width, xsi[screen_to_test].width);
|
||||||
si->geometry[screen_to_test].height =
|
si->geometry[screen_to_test].height =
|
||||||
|
@ -112,18 +138,19 @@ screensinfo_new(Display *disp)
|
||||||
si->geometry = newgeometry;
|
si->geometry = newgeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(xsi);
|
p_delete(&xsi);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
si->nscreen = ScreenCount(disp);
|
si->nscreen = xcb_setup_roots_length(xcb_get_setup(conn));
|
||||||
si->geometry = p_new(area_t, si->nscreen);
|
si->geometry = p_new(area_t, si->nscreen);
|
||||||
for(screen = 0; screen < si->nscreen; screen++)
|
for(screen = 0; screen < si->nscreen; screen++)
|
||||||
{
|
{
|
||||||
|
s = xcb_aux_get_screen(conn, screen);
|
||||||
si->geometry[screen].x = 0;
|
si->geometry[screen].x = 0;
|
||||||
si->geometry[screen].y = 0;
|
si->geometry[screen].y = 0;
|
||||||
si->geometry[screen].width = DisplayWidth(disp, screen);
|
si->geometry[screen].width = s->width_in_pixels;
|
||||||
si->geometry[screen].height = DisplayHeight(disp, screen);
|
si->geometry[screen].height = s->height_in_pixels;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,13 @@
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int nscreen;
|
int nscreen;
|
||||||
Bool xinerama_is_active;
|
bool xinerama_is_active;
|
||||||
area_t *geometry;
|
area_t *geometry;
|
||||||
} ScreensInfo;
|
} ScreensInfo;
|
||||||
|
|
||||||
int screen_get_bycoord(ScreensInfo *, int, int, int);
|
int screen_get_bycoord(ScreensInfo *, int, int, int);
|
||||||
void screensinfo_delete(ScreensInfo **);
|
void screensinfo_delete(ScreensInfo **);
|
||||||
ScreensInfo * screensinfo_new(Display *);
|
ScreensInfo * screensinfo_new(xcb_connection_t *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// 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
|
||||||
|
|
202
common/xutil.c
202
common/xutil.c
|
@ -19,60 +19,208 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <X11/Xutil.h>
|
/* strndup() */
|
||||||
#include <X11/Xatom.h>
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
#include <xcb/xcb_atom.h>
|
||||||
|
#include <xcb/xinerama.h>
|
||||||
|
#include <xcb/xcb_keysyms.h>
|
||||||
|
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "common/xutil.h"
|
#include "common/xutil.h"
|
||||||
|
|
||||||
Bool
|
bool
|
||||||
xgettextprop(Display *disp, Window w, Atom atom, char *text, ssize_t textlen)
|
xgettextprop(xcb_connection_t *conn, xcb_window_t w, xcb_atom_t atom,
|
||||||
|
char *text, ssize_t textlen)
|
||||||
{
|
{
|
||||||
char **list = NULL;
|
xcb_get_property_reply_t *name = NULL;
|
||||||
int n;
|
char *prop_val = NULL;
|
||||||
XTextProperty name;
|
|
||||||
|
|
||||||
if(!text || !textlen)
|
if(!text || !textlen)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
text[0] = '\0';
|
text[0] = '\0';
|
||||||
XGetTextProperty(disp, w, &name, atom);
|
name = xcb_get_property_reply(conn,
|
||||||
|
xcb_get_property_unchecked(conn, false,
|
||||||
|
w, atom,
|
||||||
|
XCB_GET_PROPERTY_TYPE_ANY,
|
||||||
|
0L, 1000000L),
|
||||||
|
NULL);
|
||||||
|
|
||||||
if(!name.nitems)
|
if(!name->value_len)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
if(name.encoding == XA_STRING)
|
prop_val = (char *) xcb_get_property_value(name);
|
||||||
a_strncpy(text, textlen, (char *) name.value, textlen - 1);
|
if(name->type == STRING)
|
||||||
|
a_strncpy(text, textlen, prop_val, textlen - 1);
|
||||||
|
|
||||||
else if(XmbTextPropertyToTextList(disp, &name, &list, &n) >= Success && n > 0 && *list)
|
/* TODO: XCB doesn't provide a XmbTextPropertyToTextList(), check
|
||||||
{
|
* whether this code is correct (locales) */
|
||||||
a_strncpy(text, textlen, *list, textlen - 1);
|
else if(name->format == 8)
|
||||||
XFreeStringList(list);
|
a_strncpy(text, textlen, prop_val, textlen - 1);
|
||||||
}
|
|
||||||
|
|
||||||
text[textlen - 1] = '\0';
|
text[textlen - 1] = '\0';
|
||||||
XFree(name.value);
|
p_delete(&name);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
xgetnumlockmask(Display *disp)
|
xgetnumlockmask(xcb_connection_t *conn)
|
||||||
{
|
{
|
||||||
XModifierKeymap *modmap;
|
xcb_get_modifier_mapping_reply_t *modmap_r;
|
||||||
|
xcb_keycode_t *modmap;
|
||||||
|
xcb_key_symbols_t *keysyms = xcb_key_symbols_alloc(conn);
|
||||||
unsigned int mask = 0;
|
unsigned int mask = 0;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
modmap = XGetModifierMapping(disp);
|
modmap_r = xcb_get_modifier_mapping_reply(conn,
|
||||||
|
xcb_get_modifier_mapping_unchecked(conn),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
modmap = xcb_get_modifier_mapping_keycodes(modmap_r);
|
||||||
|
|
||||||
for(i = 0; i < 8; i++)
|
for(i = 0; i < 8; i++)
|
||||||
for(j = 0; j < modmap->max_keypermod; j++)
|
for(j = 0; j < modmap_r->keycodes_per_modifier; j++)
|
||||||
if(modmap->modifiermap[i * modmap->max_keypermod + j]
|
if(modmap[i * modmap_r->keycodes_per_modifier + j]
|
||||||
== XKeysymToKeycode(disp, XK_Num_Lock))
|
== xcb_key_symbols_get_keycode(keysyms, XK_Num_Lock))
|
||||||
mask = (1 << i);
|
mask = (1 << i);
|
||||||
|
|
||||||
XFreeModifiermap(modmap);
|
p_delete(&modmap_r);
|
||||||
|
xcb_key_symbols_free(keysyms);
|
||||||
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 'XSelectInput' from Xlib is only a function around
|
||||||
|
* 'ChangeWindowAttributes' which set the value mask to 'CWEventMask'
|
||||||
|
* \param c X connection
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
x_select_input(xcb_connection_t *c, xcb_window_t w,
|
||||||
|
uint32_t event_mask)
|
||||||
|
{
|
||||||
|
const uint32_t config_win_val[] = { event_mask };
|
||||||
|
xcb_change_window_attributes_checked(c, w, XCB_CW_EVENT_MASK, config_win_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Equivalent to 'XGetTransientForHint' which is actually a
|
||||||
|
* 'XGetWindowProperty' which gets the WM_TRANSIENT_FOR property of
|
||||||
|
* the specified window
|
||||||
|
*
|
||||||
|
* \param c X connection
|
||||||
|
* \param win get the property from this window
|
||||||
|
* \param prop_win returns the WM_TRANSIENT_FOR property of win
|
||||||
|
* \return return true if successfull
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
x_get_transient_for_hint(xcb_connection_t *c, xcb_window_t win,
|
||||||
|
xcb_window_t *prop_win)
|
||||||
|
{
|
||||||
|
xcb_get_property_reply_t *r;
|
||||||
|
|
||||||
|
/* Use checked because the error handler should not take care of
|
||||||
|
* this error as we only return a boolean */
|
||||||
|
r = xcb_get_property_reply(c,
|
||||||
|
xcb_get_property(c, false, win,
|
||||||
|
WM_TRANSIENT_FOR,
|
||||||
|
WINDOW, 0, 1),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if(!r)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*prop_win = *((xcb_window_t *) xcb_get_property_value(r));
|
||||||
|
p_delete(&r);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
xinerama_is_active(xcb_connection_t *c)
|
||||||
|
{
|
||||||
|
bool ret;
|
||||||
|
xcb_xinerama_is_active_reply_t *r = NULL;
|
||||||
|
|
||||||
|
r = xcb_xinerama_is_active_reply(c, xcb_xinerama_is_active(c), NULL);
|
||||||
|
if(!r)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ret = r->state;
|
||||||
|
p_delete(&r);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
xcb_window_t
|
||||||
|
root_window(xcb_connection_t *c, int screen_number)
|
||||||
|
{
|
||||||
|
return xcb_aux_get_screen(c, screen_number)->root;
|
||||||
|
}
|
||||||
|
|
||||||
|
xcb_atom_t
|
||||||
|
x_intern_atom(xcb_connection_t *c, const char *property)
|
||||||
|
{
|
||||||
|
xcb_atom_t atom;
|
||||||
|
xcb_intern_atom_reply_t *r_atom;
|
||||||
|
|
||||||
|
r_atom = xcb_intern_atom_reply(c,
|
||||||
|
xcb_intern_atom_unchecked(c, false, strlen(property), property),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if(!r_atom)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
atom = r_atom->atom;
|
||||||
|
p_delete(&r_atom);
|
||||||
|
|
||||||
|
return atom;
|
||||||
|
}
|
||||||
|
|
||||||
|
class_hint_t *
|
||||||
|
x_get_class_hint(xcb_connection_t *conn, xcb_window_t win)
|
||||||
|
{
|
||||||
|
xcb_get_property_reply_t *r = NULL;
|
||||||
|
char *data = NULL;
|
||||||
|
|
||||||
|
int len_name, len_class;
|
||||||
|
|
||||||
|
class_hint_t *ch = p_new(class_hint_t, 1);
|
||||||
|
|
||||||
|
/* TODO: 2048? (BUFINC is declared as private in xcb.c) */
|
||||||
|
r = xcb_get_property_reply(conn,
|
||||||
|
xcb_get_property_unchecked(conn,
|
||||||
|
false, win, WM_CLASS,
|
||||||
|
STRING, 0L, 2048),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if(!r || r->type != STRING || r->format == 8)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
data = xcb_get_property_value(r);
|
||||||
|
|
||||||
|
len_name = strlen((char *) data);
|
||||||
|
len_class = strlen((char *) (data + len_name + 1));
|
||||||
|
|
||||||
|
ch->res_name = strndup(data, len_name);
|
||||||
|
ch->res_class = strndup(data + len_name + 1, len_class);
|
||||||
|
|
||||||
|
p_delete(&r);
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xutil_map_raised(xcb_connection_t *conn, xcb_window_t win)
|
||||||
|
{
|
||||||
|
const uint32_t map_raised_val = XCB_STACK_MODE_ABOVE;
|
||||||
|
|
||||||
|
xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_STACK_MODE,
|
||||||
|
&map_raised_val);
|
||||||
|
|
||||||
|
xcb_map_window(conn, win);
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
|
@ -22,10 +22,91 @@
|
||||||
#ifndef AWESOME_COMMON_XUTIL_H
|
#ifndef AWESOME_COMMON_XUTIL_H
|
||||||
#define AWESOME_COMMON_XUTIL_H
|
#define AWESOME_COMMON_XUTIL_H
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
Bool xgettextprop(Display *, Window, Atom, char *, ssize_t);
|
#include <xcb/xcb.h>
|
||||||
unsigned int xgetnumlockmask(Display *);
|
|
||||||
|
/* XCB doesn't provide keysyms definition */
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
|
||||||
|
bool xgettextprop(xcb_connection_t *, xcb_window_t, xcb_atom_t, char *, ssize_t);
|
||||||
|
unsigned int xgetnumlockmask(xcb_connection_t *);
|
||||||
|
|
||||||
|
/* See http://tronche.com/gui/x/xlib/appendix/b/ for values */
|
||||||
|
#define CURSOR_FLEUR 52
|
||||||
|
#define CURSOR_LEFT_PTR 68
|
||||||
|
#define CURSOR_SIZING 120
|
||||||
|
|
||||||
|
#define ANY_KEY 0L /* special Key Code, passed to GrabKey */
|
||||||
|
#define ANY_MODIFIER (1<<15) /* used in GrabButton, GrabKey */
|
||||||
|
|
||||||
|
/*****************************************************************
|
||||||
|
* ERROR CODES
|
||||||
|
*****************************************************************/
|
||||||
|
|
||||||
|
#define Success 0 /* everything's okay */
|
||||||
|
#define BadRequest 1 /* bad request code */
|
||||||
|
#define BadValue 2 /* int parameter out of range */
|
||||||
|
#define BadWindow 3 /* parameter not a Window */
|
||||||
|
#define BadPixmap 4 /* parameter not a Pixmap */
|
||||||
|
#define BadAtom 5 /* parameter not an Atom */
|
||||||
|
#define BadCursor 6 /* parameter not a Cursor */
|
||||||
|
#define BadFont 7 /* parameter not a Font */
|
||||||
|
#define BadMatch 8 /* parameter mismatch */
|
||||||
|
#define BadDrawable 9 /* parameter not a Pixmap or Window */
|
||||||
|
#define BadAccess 10 /* depending on context:
|
||||||
|
- key/button already grabbed
|
||||||
|
- attempt to free an illegal
|
||||||
|
cmap entry
|
||||||
|
- attempt to store into a read-only
|
||||||
|
color map entry.
|
||||||
|
- attempt to modify the access control
|
||||||
|
list from other than the local host.
|
||||||
|
*/
|
||||||
|
#define BadAlloc 11 /* insufficient resources */
|
||||||
|
#define BadColor 12 /* no such colormap */
|
||||||
|
#define BadGC 13 /* parameter not a GC */
|
||||||
|
#define BadIDChoice 14 /* choice not in range or already used */
|
||||||
|
#define BadName 15 /* font or color name doesn't exist */
|
||||||
|
#define BadLength 16 /* Request length incorrect */
|
||||||
|
#define BadImplementation 17 /* server is defective */
|
||||||
|
|
||||||
|
#define FirstExtensionError 128
|
||||||
|
#define LastExtensionError 255
|
||||||
|
/* End of macros not defined in XCB */
|
||||||
|
|
||||||
|
/* Common function defined in Xlib but not in XCB */
|
||||||
|
void x_select_input(xcb_connection_t *, xcb_window_t, uint32_t);
|
||||||
|
bool x_get_transient_for_hint(xcb_connection_t *, xcb_window_t, xcb_window_t *);
|
||||||
|
bool xinerama_is_active(xcb_connection_t *);
|
||||||
|
xcb_window_t root_window(xcb_connection_t *, int);
|
||||||
|
|
||||||
|
typedef struct _class_hint_t
|
||||||
|
{
|
||||||
|
char *res_name;
|
||||||
|
char *res_class;
|
||||||
|
} class_hint_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t pixel;
|
||||||
|
uint16_t red;
|
||||||
|
uint16_t green;
|
||||||
|
uint16_t blue;
|
||||||
|
} xcolor_t;
|
||||||
|
|
||||||
|
class_hint_t *x_get_class_hint(xcb_connection_t *, xcb_window_t);
|
||||||
|
|
||||||
|
/* Equivalent call to XInternAtom
|
||||||
|
*
|
||||||
|
* WARNING: should not be used in loop, in this case, it should send
|
||||||
|
* the queries first and then treat the answer as late as possible)
|
||||||
|
*/
|
||||||
|
xcb_atom_t x_intern_atom(xcb_connection_t *, const char *);
|
||||||
|
|
||||||
|
/* Equivalent XCB call to XMapRaised, which actually raises the
|
||||||
|
specified window to the top of the stack and maps it */
|
||||||
|
void xutil_map_raised(xcb_connection_t *, xcb_window_t);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// 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
|
||||||
|
|
80
config.c
80
config.c
|
@ -19,8 +19,11 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* XStringToKeysym() */
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
#include <xcb/xcb_keysyms.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <X11/keysym.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
|
@ -34,11 +37,11 @@
|
||||||
#include "common/xutil.h"
|
#include "common/xutil.h"
|
||||||
|
|
||||||
/* Permit to use mouse with many more buttons */
|
/* Permit to use mouse with many more buttons */
|
||||||
#ifndef Button6
|
#ifndef XCB_BUTTON_INDEX_6
|
||||||
#define Button6 6
|
#define XCB_BUTTON_INDEX_6 6
|
||||||
#endif
|
#endif
|
||||||
#ifndef Button7
|
#ifndef XCB_BUTTON_INDEX_7
|
||||||
#define Button7 7
|
#define XCB_BUTTON_INDEX_7 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern AwesomeConf globalconf;
|
extern AwesomeConf globalconf;
|
||||||
|
@ -48,7 +51,7 @@ extern cfg_opt_t awesome_opts[];
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
KeySym keysym;
|
xcb_keysym_t keysym;
|
||||||
} KeyMod;
|
} KeyMod;
|
||||||
|
|
||||||
/** Link a name to a mouse button symbol */
|
/** Link a name to a mouse button symbol */
|
||||||
|
@ -67,21 +70,21 @@ extern const name_func_link_t FloatingPlacementList[];
|
||||||
* \param keyname Key name
|
* \param keyname Key name
|
||||||
* \return Key mask or 0 if not found
|
* \return Key mask or 0 if not found
|
||||||
*/
|
*/
|
||||||
static KeySym
|
static xcb_keysym_t
|
||||||
key_mask_lookup(const char *keyname)
|
key_mask_lookup(const char *keyname)
|
||||||
{
|
{
|
||||||
/** List of keyname and corresponding X11 mask codes */
|
/** List of keyname and corresponding X11 mask codes */
|
||||||
static const KeyMod KeyModList[] =
|
static const KeyMod KeyModList[] =
|
||||||
{
|
{
|
||||||
{"Shift", ShiftMask},
|
{"Shift", XCB_MOD_MASK_SHIFT},
|
||||||
{"Lock", LockMask},
|
{"Lock", XCB_MOD_MASK_LOCK},
|
||||||
{"Control", ControlMask},
|
{"Control", XCB_MOD_MASK_CONTROL},
|
||||||
{"Mod1", Mod1Mask},
|
{"Mod1", XCB_MOD_MASK_1},
|
||||||
{"Mod2", Mod2Mask},
|
{"Mod2", XCB_MOD_MASK_2},
|
||||||
{"Mod3", Mod3Mask},
|
{"Mod3", XCB_MOD_MASK_3},
|
||||||
{"Mod4", Mod4Mask},
|
{"Mod4", XCB_MOD_MASK_4},
|
||||||
{"Mod5", Mod5Mask},
|
{"Mod5", XCB_MOD_MASK_5},
|
||||||
{NULL, NoSymbol}
|
{NULL, XCB_NO_SYMBOL}
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -103,13 +106,13 @@ mouse_button_lookup(const char *button)
|
||||||
/** List of button name and corresponding X11 mask codes */
|
/** List of button name and corresponding X11 mask codes */
|
||||||
static const MouseButton MouseButtonList[] =
|
static const MouseButton MouseButtonList[] =
|
||||||
{
|
{
|
||||||
{"1", Button1},
|
{"1", XCB_BUTTON_INDEX_1},
|
||||||
{"2", Button2},
|
{"2", XCB_BUTTON_INDEX_2},
|
||||||
{"3", Button3},
|
{"3", XCB_BUTTON_INDEX_3},
|
||||||
{"4", Button4},
|
{"4", XCB_BUTTON_INDEX_4},
|
||||||
{"5", Button5},
|
{"5", XCB_BUTTON_INDEX_5},
|
||||||
{"6", Button6},
|
{"6", XCB_BUTTON_INDEX_6},
|
||||||
{"7", Button7},
|
{"7", XCB_BUTTON_INDEX_7},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
|
@ -123,7 +126,7 @@ mouse_button_lookup(const char *button)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Button *
|
static Button *
|
||||||
parse_mouse_bindings(cfg_t * cfg, const char *secname, Bool handle_arg)
|
parse_mouse_bindings(cfg_t * cfg, const char *secname, bool handle_arg)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
cfg_t *cfgsectmp;
|
cfg_t *cfgsectmp;
|
||||||
|
@ -168,7 +171,8 @@ set_key_info(Key *key, cfg_t *cfg)
|
||||||
static void
|
static void
|
||||||
config_key_store(Key *key, char *str)
|
config_key_store(Key *key, char *str)
|
||||||
{
|
{
|
||||||
KeyCode kc;
|
xcb_keycode_t kc;
|
||||||
|
xcb_keysym_t ks;
|
||||||
int ikc;
|
int ikc;
|
||||||
|
|
||||||
if(!a_strlen(str))
|
if(!a_strlen(str))
|
||||||
|
@ -269,7 +273,7 @@ statusbar_widgets_create(cfg_t *cfg_statusbar, Statusbar *statusbar)
|
||||||
widget = widget_new(statusbar, wptr);
|
widget = widget_new(statusbar, wptr);
|
||||||
widget_list_append(&statusbar->widgets, widget);
|
widget_list_append(&statusbar->widgets, widget);
|
||||||
widget->buttons = parse_mouse_bindings(wptr, "mouse",
|
widget->buttons = parse_mouse_bindings(wptr, "mouse",
|
||||||
a_strcmp(cfg_name(wptr), "taglist") ? True : False);
|
a_strcmp(cfg_name(wptr), "taglist") ? true : false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
warn("ignoring unknown widget: %s.\n", cfg_name(widgets + i));
|
warn("ignoring unknown widget: %s.\n", cfg_name(widgets + i));
|
||||||
|
@ -288,15 +292,15 @@ config_section_titlebar_init(cfg_t *cfg_titlebar, Titlebar *tb, int screen)
|
||||||
tb->text_align = cfg_getalignment(cfg_titlebar, "text_align");
|
tb->text_align = cfg_getalignment(cfg_titlebar, "text_align");
|
||||||
tb->width = cfg_getint(cfg_titlebar, "width");
|
tb->width = cfg_getint(cfg_titlebar, "width");
|
||||||
tb->height = cfg_getint(cfg_titlebar, "height");
|
tb->height = cfg_getint(cfg_titlebar, "height");
|
||||||
draw_style_init(globalconf.display, phys_screen,
|
draw_style_init(globalconf.connection, phys_screen,
|
||||||
cfg_getsec(cfg_styles, "normal"),
|
cfg_getsec(cfg_styles, "normal"),
|
||||||
&tb->styles.normal,
|
&tb->styles.normal,
|
||||||
&globalconf.screens[screen].styles.normal);
|
&globalconf.screens[screen].styles.normal);
|
||||||
draw_style_init(globalconf.display, phys_screen,
|
draw_style_init(globalconf.connection, phys_screen,
|
||||||
cfg_getsec(cfg_styles, "focus"),
|
cfg_getsec(cfg_styles, "focus"),
|
||||||
&tb->styles.focus,
|
&tb->styles.focus,
|
||||||
&globalconf.screens[screen].styles.focus);
|
&globalconf.screens[screen].styles.focus);
|
||||||
draw_style_init(globalconf.display, phys_screen,
|
draw_style_init(globalconf.connection, phys_screen,
|
||||||
cfg_getsec(cfg_styles, "urgent"),
|
cfg_getsec(cfg_styles, "urgent"),
|
||||||
&tb->styles.urgent,
|
&tb->styles.urgent,
|
||||||
&globalconf.screens[screen].styles.urgent);
|
&globalconf.screens[screen].styles.urgent);
|
||||||
|
@ -378,11 +382,11 @@ config_parse_screen(cfg_t *cfg, int screen)
|
||||||
if(!(cfg_styles_urgent = cfg_getsec(cfg_styles, "urgent")))
|
if(!(cfg_styles_urgent = cfg_getsec(cfg_styles, "urgent")))
|
||||||
eprint("no urgent colors section found\n");
|
eprint("no urgent colors section found\n");
|
||||||
|
|
||||||
draw_style_init(globalconf.display, phys_screen,
|
draw_style_init(globalconf.connection, phys_screen,
|
||||||
cfg_styles_normal, &virtscreen->styles.normal, NULL);
|
cfg_styles_normal, &virtscreen->styles.normal, NULL);
|
||||||
draw_style_init(globalconf.display, phys_screen,
|
draw_style_init(globalconf.connection, phys_screen,
|
||||||
cfg_styles_focus, &virtscreen->styles.focus, &virtscreen->styles.normal);
|
cfg_styles_focus, &virtscreen->styles.focus, &virtscreen->styles.normal);
|
||||||
draw_style_init(globalconf.display, phys_screen,
|
draw_style_init(globalconf.connection, phys_screen,
|
||||||
cfg_styles_urgent, &virtscreen->styles.urgent, &virtscreen->styles.normal);
|
cfg_styles_urgent, &virtscreen->styles.urgent, &virtscreen->styles.normal);
|
||||||
|
|
||||||
if(!virtscreen->styles.normal.font)
|
if(!virtscreen->styles.normal.font)
|
||||||
|
@ -464,8 +468,8 @@ config_parse_screen(cfg_t *cfg, int screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* select first tag by default */
|
/* select first tag by default */
|
||||||
virtscreen->tags[0].selected = True;
|
virtscreen->tags[0].selected = true;
|
||||||
virtscreen->tags[0].was_selected = True;
|
virtscreen->tags[0].was_selected = true;
|
||||||
|
|
||||||
/* padding */
|
/* padding */
|
||||||
virtscreen->padding.top = cfg_getint(cfg_padding, "top");
|
virtscreen->padding.top = cfg_getint(cfg_padding, "top");
|
||||||
|
@ -549,16 +553,16 @@ config_parse(const char *confpatharg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mouse: root window click bindings */
|
/* Mouse: root window click bindings */
|
||||||
globalconf.buttons.root = parse_mouse_bindings(cfg_mouse, "root", True);
|
globalconf.buttons.root = parse_mouse_bindings(cfg_mouse, "root", true);
|
||||||
|
|
||||||
/* Mouse: client windows click bindings */
|
/* Mouse: client windows click bindings */
|
||||||
globalconf.buttons.client = parse_mouse_bindings(cfg_mouse, "client", True);
|
globalconf.buttons.client = parse_mouse_bindings(cfg_mouse, "client", true);
|
||||||
|
|
||||||
/* Mouse: titlebar windows click bindings */
|
/* Mouse: titlebar windows click bindings */
|
||||||
globalconf.buttons.titlebar = parse_mouse_bindings(cfg_mouse, "titlebar", True);
|
globalconf.buttons.titlebar = parse_mouse_bindings(cfg_mouse, "titlebar", true);
|
||||||
|
|
||||||
/* Keys */
|
/* Keys */
|
||||||
globalconf.numlockmask = xgetnumlockmask(globalconf.display);
|
globalconf.numlockmask = xgetnumlockmask(globalconf.connection);
|
||||||
|
|
||||||
globalconf.keys = section_keys(cfg_keys);
|
globalconf.keys = section_keys(cfg_keys);
|
||||||
|
|
||||||
|
|
25
configure.ac
25
configure.ac
|
@ -113,10 +113,6 @@ PKG_CHECK_MODULES([pangocairo], [pangocairo],,
|
||||||
[AC_MSG_ERROR([awesome requires pangocairo.])])
|
[AC_MSG_ERROR([awesome requires pangocairo.])])
|
||||||
PKG_CHECK_MODULES([confuse], [libconfuse >= 2.6],,
|
PKG_CHECK_MODULES([confuse], [libconfuse >= 2.6],,
|
||||||
[AC_MSG_ERROR([awesome requires libconfuse >= 2.6.])])
|
[AC_MSG_ERROR([awesome requires libconfuse >= 2.6.])])
|
||||||
PKG_CHECK_MODULES([xinerama], [xinerama],,
|
|
||||||
[AC_MSG_ERROR([awesome requires Xinerama.])])
|
|
||||||
PKG_CHECK_MODULES([xrandr], [xrandr],,
|
|
||||||
[AC_MSG_ERROR([awesome requires Xrandr.])])
|
|
||||||
AC_ARG_WITH([gtk], AS_HELP_STRING([--with-gtk], [Build with gtk library (default: disabled)]))
|
AC_ARG_WITH([gtk], AS_HELP_STRING([--with-gtk], [Build with gtk library (default: disabled)]))
|
||||||
|
|
||||||
if test "x$with_gtk" == "xyes"; then
|
if test "x$with_gtk" == "xyes"; then
|
||||||
|
@ -127,9 +123,28 @@ else
|
||||||
PKG_CHECK_MODULES([imlib2], [imlib2],,
|
PKG_CHECK_MODULES([imlib2], [imlib2],,
|
||||||
[AC_MSG_ERROR([awesome requires Imlib2.])])
|
[AC_MSG_ERROR([awesome requires Imlib2.])])
|
||||||
fi
|
fi
|
||||||
|
PKG_CHECK_MODULES([xcb], [xcb],,
|
||||||
|
[AC_MSG_ERROR([awesome requires xcb.])])
|
||||||
|
PKG_CHECK_MODULES([xcb_event], [xcb-event],,
|
||||||
|
[AC_MSG_ERROR([awesome requires xcb-event.])])
|
||||||
|
PKG_CHECK_MODULES([xcb_randr], [xcb-randr],,
|
||||||
|
[AC_MSG_ERROR([awesome requires xcb-randr.])])
|
||||||
|
PKG_CHECK_MODULES([xcb_xinerama], [xcb-xinerama],,
|
||||||
|
[AC_MSG_ERROR([awesome requires xcb-xinerama.])])
|
||||||
|
PKG_CHECK_MODULES([xcb_shape], [xcb-shape],,
|
||||||
|
[AC_MSG_ERROR([awesome requires xcb-shape.])])
|
||||||
|
PKG_CHECK_MODULES([xcb_aux], [xcb-aux],,
|
||||||
|
[AC_MSG_ERROR([awesome requires xcb-aux.])])
|
||||||
|
PKG_CHECK_MODULES([xcb_atom], [xcb-atom],,
|
||||||
|
[AC_MSG_ERROR([awesome requires xcb-atom.])])
|
||||||
|
PKG_CHECK_MODULES([xcb_keysyms], [xcb-keysyms],,
|
||||||
|
[AC_MSG_ERROR([awesome requires xcb-keysyms.])])
|
||||||
|
PKG_CHECK_MODULES([xcb_render], [xcb-render],,
|
||||||
|
[AC_MSG_ERROR([awesome requires xcb-render.])])
|
||||||
|
PKG_CHECK_MODULES([xcb_icccm], [xcb-icccm],,
|
||||||
|
[AC_MSG_ERROR([awesome requires xcb-icccm.])])
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_PATH_X
|
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_HEADER_SYS_WAIT
|
AC_HEADER_SYS_WAIT
|
||||||
AC_CHECK_HEADERS([fcntl.h limits.h locale.h stdlib.h string.h sys/socket.h unistd.h])
|
AC_CHECK_HEADERS([fcntl.h limits.h locale.h stdlib.h string.h sys/socket.h unistd.h])
|
||||||
|
|
455
event.c
455
event.c
|
@ -19,11 +19,12 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <X11/keysym.h>
|
#include <xcb/xcb_keysyms.h>
|
||||||
#include <X11/Xatom.h>
|
#include <xcb/xcb_icccm.h>
|
||||||
#include <X11/Xutil.h>
|
#include <xcb/xcb_atom.h>
|
||||||
#include <X11/extensions/shape.h>
|
#include <xcb/xcb_aux.h>
|
||||||
#include <X11/extensions/Xrandr.h>
|
#include <xcb/shape.h>
|
||||||
|
#include <xcb/randr.h>
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
#include "layouts/tile.h"
|
#include "layouts/tile.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
#include "common/xscreen.h"
|
#include "common/xscreen.h"
|
||||||
|
#include "common/xutil.h"
|
||||||
|
|
||||||
extern AwesomeConf globalconf;
|
extern AwesomeConf globalconf;
|
||||||
|
|
||||||
|
@ -51,7 +53,7 @@ extern AwesomeConf globalconf;
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
event_handle_mouse_button_press(int screen, unsigned int button, unsigned int state,
|
event_handle_mouse_button_press(int screen, unsigned int button, unsigned int state,
|
||||||
Button *buttons, char *arg)
|
Button *buttons, char *arg)
|
||||||
{
|
{
|
||||||
Button *b;
|
Button *b;
|
||||||
|
|
||||||
|
@ -66,139 +68,140 @@ event_handle_mouse_button_press(int screen, unsigned int button, unsigned int st
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XButtonPressed events
|
/** Handle XButtonPressed events
|
||||||
* \param e XEvent
|
* \param connection connection to the X server
|
||||||
|
* \param ev ButtonPress event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_buttonpress(XEvent *e)
|
event_handle_buttonpress(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection, xcb_button_press_event_t *ev)
|
||||||
{
|
{
|
||||||
int i, screen, x = 0, y = 0;
|
int screen;
|
||||||
unsigned int udummy;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
Window wdummy;
|
|
||||||
Widget *widget;
|
Widget *widget;
|
||||||
Statusbar *statusbar;
|
Statusbar *statusbar;
|
||||||
XButtonPressedEvent *ev = &e->xbutton;
|
xcb_query_pointer_reply_t *qr;
|
||||||
|
|
||||||
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
||||||
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
||||||
if(statusbar->sw->window == ev->window || statusbar->sw->window == ev->subwindow)
|
if(statusbar->sw->window == ev->event || statusbar->sw->window == ev->child)
|
||||||
{
|
{
|
||||||
switch(statusbar->position)
|
switch(statusbar->position)
|
||||||
{
|
{
|
||||||
case Top:
|
case Top:
|
||||||
case Bottom:
|
case Bottom:
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||||
if(ev->x >= widget->area.x && ev->x < widget->area.x + widget->area.width
|
if(ev->event_x >= widget->area.x && ev->event_x < widget->area.x + widget->area.width
|
||||||
&& ev->y >= widget->area.y && ev->y < widget->area.y + widget->area.height)
|
&& ev->event_y >= widget->area.y && ev->event_y < widget->area.y + widget->area.height)
|
||||||
{
|
{
|
||||||
widget->button_press(widget, ev);
|
widget->button_press(widget, ev);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||||
if(ev->y >= widget->area.x && ev->y < widget->area.x + widget->area.width
|
if(ev->event_y >= widget->area.x && ev->event_y < widget->area.x + widget->area.width
|
||||||
&& statusbar->sw->geometry.width - ev->x >= widget->area.y
|
&& statusbar->sw->geometry.width - ev->event_x >= widget->area.y
|
||||||
&& statusbar->sw->geometry.width - ev->x
|
&& statusbar->sw->geometry.width - ev->event_x
|
||||||
< widget->area.y + widget->area.height)
|
< widget->area.y + widget->area.height)
|
||||||
{
|
{
|
||||||
widget->button_press(widget, ev);
|
widget->button_press(widget, ev);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||||
if(statusbar->sw->geometry.height - ev->y >= widget->area.x
|
if(statusbar->sw->geometry.height - ev->event_y >= widget->area.x
|
||||||
&& statusbar->sw->geometry.height - ev->y
|
&& statusbar->sw->geometry.height - ev->event_y
|
||||||
< widget->area.x + widget->area.width
|
< widget->area.x + widget->area.width
|
||||||
&& ev->x >= widget->area.y && ev->x < widget->area.y + widget->area.height)
|
&& ev->event_x >= widget->area.y && ev->event_x < widget->area.y + widget->area.height)
|
||||||
{
|
{
|
||||||
widget->button_press(widget, ev);
|
widget->button_press(widget, ev);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* return if no widget match */
|
/* return if no widget match */
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(c->titlebar.sw && c->titlebar.sw->window == ev->window)
|
if(c->titlebar.sw && c->titlebar.sw->window == ev->event)
|
||||||
{
|
{
|
||||||
if(!client_focus(c, c->screen, True))
|
if(!client_focus(c, c->screen, true))
|
||||||
client_stack(c);
|
client_stack(c);
|
||||||
if(CLEANMASK(ev->state) == NoSymbol
|
if(CLEANMASK(ev->state) == XCB_NO_SYMBOL
|
||||||
&& ev->button == Button1)
|
&& ev->detail == XCB_BUTTON_INDEX_1)
|
||||||
window_grabbuttons(c->win, c->phys_screen);
|
window_grabbuttons(c->win, c->phys_screen);
|
||||||
event_handle_mouse_button_press(c->screen, ev->button, ev->state,
|
event_handle_mouse_button_press(c->screen, ev->detail, ev->state,
|
||||||
globalconf.buttons.titlebar, NULL);
|
globalconf.buttons.titlebar, NULL);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_get_bywin(globalconf.clients, ev->event)))
|
||||||
{
|
{
|
||||||
if(!client_focus(c, c->screen, True))
|
if(!client_focus(c, c->screen, true))
|
||||||
client_stack(c);
|
client_stack(c);
|
||||||
if(CLEANMASK(ev->state) == NoSymbol
|
if(CLEANMASK(ev->state) == XCB_NO_SYMBOL
|
||||||
&& ev->button == Button1)
|
&& ev->detail == XCB_BUTTON_INDEX_1)
|
||||||
{
|
{
|
||||||
XAllowEvents(globalconf.display, ReplayPointer, CurrentTime);
|
xcb_allow_events(globalconf.connection, XCB_ALLOW_REPLAY_POINTER, XCB_CURRENT_TIME);
|
||||||
window_grabbuttons(c->win, c->phys_screen);
|
window_grabbuttons(c->win, c->phys_screen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
event_handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL);
|
event_handle_mouse_button_press(c->screen, ev->detail, ev->state, globalconf.buttons.client, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
for(screen = 0; screen < xcb_setup_roots_length(xcb_get_setup (connection)); screen++)
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
if(root_window(connection, screen) == ev->event
|
||||||
if(RootWindow(e->xany.display, screen) == ev->window
|
&& (qr = xcb_query_pointer_reply(connection,
|
||||||
&& XQueryPointer(e->xany.display,
|
xcb_query_pointer(connection, ev->event),
|
||||||
ev->window, &wdummy,
|
NULL)) != NULL)
|
||||||
&wdummy, &x, &y, &i,
|
|
||||||
&i, &udummy))
|
|
||||||
{
|
{
|
||||||
screen = screen_get_bycoord(globalconf.screens_info, screen, x, y);
|
screen = screen_get_bycoord(globalconf.screens_info, screen, qr->root_x, qr->root_y);
|
||||||
event_handle_mouse_button_press(screen, ev->button, ev->state,
|
event_handle_mouse_button_press(screen, ev->detail, ev->state,
|
||||||
globalconf.buttons.root, NULL);
|
globalconf.buttons.root, NULL);
|
||||||
return;
|
|
||||||
|
p_delete(&qr);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XConfigureRequest events
|
/** Handle XConfigureRequest events
|
||||||
* \param e XEvent
|
* \param connection connection to the X server
|
||||||
|
* \param ev ConfigureRequest event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_configurerequest(XEvent * e)
|
event_handle_configurerequest(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection, xcb_configure_request_event_t *ev)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
|
||||||
XWindowChanges wc;
|
|
||||||
area_t geometry;
|
area_t geometry;
|
||||||
|
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
||||||
{
|
{
|
||||||
geometry = c->geometry;
|
geometry = c->geometry;
|
||||||
|
|
||||||
if(ev->value_mask & CWX)
|
if(ev->value_mask & XCB_CONFIG_WINDOW_X)
|
||||||
geometry.x = ev->x;
|
geometry.x = ev->x;
|
||||||
if(ev->value_mask & CWY)
|
if(ev->value_mask & XCB_CONFIG_WINDOW_Y)
|
||||||
geometry.y = ev->y;
|
geometry.y = ev->y;
|
||||||
if(ev->value_mask & CWWidth)
|
if(ev->value_mask & XCB_CONFIG_WINDOW_WIDTH)
|
||||||
geometry.width = ev->width;
|
geometry.width = ev->width;
|
||||||
if(ev->value_mask & CWHeight)
|
if(ev->value_mask & XCB_CONFIG_WINDOW_HEIGHT)
|
||||||
geometry.height = ev->height;
|
geometry.height = ev->height;
|
||||||
|
|
||||||
if(geometry.x != c->geometry.x || geometry.y != c->geometry.y
|
if(geometry.x != c->geometry.x || geometry.y != c->geometry.y
|
||||||
|| geometry.width != c->geometry.width || geometry.height != c->geometry.height)
|
|| geometry.width != c->geometry.width || geometry.height != c->geometry.height)
|
||||||
{
|
{
|
||||||
if(c->isfloating || layout_get_current(c->screen)->arrange == layout_floating)
|
if(c->isfloating || layout_get_current(c->screen)->arrange == layout_floating)
|
||||||
client_resize(c, geometry, False);
|
client_resize(c, geometry, false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
globalconf.screens[c->screen].need_arrange = True;
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
/* If we do not resize the client, at least tell it that it
|
/* If we do not resize the client, at least tell it that it
|
||||||
* has its new configuration. That fixes at least
|
* has its new configuration. That fixes at least
|
||||||
* gnome-terminal */
|
* gnome-terminal */
|
||||||
|
@ -213,95 +216,108 @@ event_handle_configurerequest(XEvent * e)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wc.x = ev->x;
|
const uint32_t configure_values[] = {
|
||||||
wc.y = ev->y;
|
ev->x, ev->y, ev->width, ev->height, ev->border_width,
|
||||||
wc.width = ev->width;
|
ev->sibling, ev->stack_mode };
|
||||||
wc.height = ev->height;
|
|
||||||
wc.border_width = ev->border_width;
|
xcb_configure_window(connection, ev->window, ev->value_mask,
|
||||||
wc.sibling = ev->above;
|
configure_values);
|
||||||
wc.stack_mode = ev->detail;
|
|
||||||
XConfigureWindow(e->xany.display, ev->window, ev->value_mask, &wc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XConfigure events
|
/** Handle XConfigure events
|
||||||
* \param e XEvent
|
* \param connection connection to the X server
|
||||||
|
* \param ev ConfigureNotify event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_configurenotify(XEvent * e)
|
event_handle_configurenotify(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection, xcb_configure_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
XConfigureEvent *ev = &e->xconfigure;
|
int screen_nbr;
|
||||||
int screen;
|
const xcb_screen_t *screen;
|
||||||
|
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
for(screen_nbr = 0; screen_nbr < xcb_setup_roots_length (xcb_get_setup (connection)); screen_nbr++)
|
||||||
if(ev->window == RootWindow(e->xany.display, screen)
|
if(ev->window == root_window(connection, screen_nbr)
|
||||||
&& (ev->width != DisplayWidth(e->xany.display, screen)
|
&& (screen = xcb_aux_get_screen(connection, screen_nbr)) != NULL
|
||||||
|| ev->height != DisplayHeight(e->xany.display, screen)))
|
&& (ev->width != screen->width_in_pixels
|
||||||
|
|| ev->height != screen->height_in_pixels))
|
||||||
/* it's not that we panic, but restart */
|
/* it's not that we panic, but restart */
|
||||||
uicb_restart(0, NULL);
|
uicb_restart(0, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XDestroyWindow events
|
/** Handle XDestroyWindow events
|
||||||
* \param e XEvent
|
* \param connection connection to the X server
|
||||||
|
* \param ev DestroyNotify event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_destroynotify(XEvent *e)
|
event_handle_destroynotify(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection __attribute__ ((unused)),
|
||||||
|
xcb_destroy_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
|
||||||
|
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
||||||
client_unmanage(c);
|
client_unmanage(c);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XCrossing events on enter
|
/** Handle XCrossing events
|
||||||
* \param e XEvent
|
* \param connection connection to the X server
|
||||||
|
* \param ev Crossing event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_enternotify(XEvent *e)
|
event_handle_enternotify(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection, xcb_enter_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
XCrossingEvent *ev = &e->xcrossing;
|
|
||||||
int screen;
|
int screen;
|
||||||
|
|
||||||
if(ev->mode != NotifyNormal
|
if(ev->mode != XCB_NOTIFY_MODE_NORMAL
|
||||||
|| (ev->x_root == globalconf.pointer_x
|
|| (ev->root_x == globalconf.pointer_x
|
||||||
&& ev->y_root == globalconf.pointer_y))
|
&& ev->root_y == globalconf.pointer_y))
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(c->titlebar.sw && c->titlebar.sw->window == ev->window)
|
if(c->titlebar.sw && c->titlebar.sw->window == ev->event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(c || (c = client_get_bywin(globalconf.clients, ev->window)))
|
if(c || (c = client_get_bywin(globalconf.clients, ev->event)))
|
||||||
{
|
{
|
||||||
window_grabbuttons(c->win, c->phys_screen);
|
window_grabbuttons(c->win, c->phys_screen);
|
||||||
/* the idea behind saving pointer_x and pointer_y is Bob Marley powered
|
/* the idea behind saving pointer_x and pointer_y is Bob Marley powered
|
||||||
* this will allow us top drop some EnterNotify events and thus not giving
|
* this will allow us top drop some EnterNotify events and thus not giving
|
||||||
* focus to windows appering under the cursor without a cursor move */
|
* focus to windows appering under the cursor without a cursor move */
|
||||||
globalconf.pointer_x = ev->x_root;
|
globalconf.pointer_x = ev->root_x;
|
||||||
globalconf.pointer_y = ev->y_root;
|
globalconf.pointer_y = ev->root_y;
|
||||||
|
|
||||||
if(globalconf.screens[c->screen].sloppy_focus)
|
if(globalconf.screens[c->screen].sloppy_focus)
|
||||||
client_focus(c, c->screen,
|
client_focus(c, c->screen,
|
||||||
globalconf.screens[c->screen].sloppy_focus_raise);
|
globalconf.screens[c->screen].sloppy_focus_raise);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
for(screen = 0; screen < xcb_setup_roots_length(xcb_get_setup(connection)); screen++)
|
||||||
if(ev->window == RootWindow(e->xany.display, screen))
|
if(ev->event == root_window(connection, screen))
|
||||||
{
|
{
|
||||||
window_root_grabbuttons(screen);
|
window_root_grabbuttons(screen);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XExpose events
|
/** Handle XExpose events
|
||||||
* \param e XEvent
|
* \param ev Expose event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_expose(XEvent *e)
|
event_handle_expose(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection __attribute__ ((unused)),
|
||||||
|
xcb_expose_event_t *ev)
|
||||||
{
|
{
|
||||||
XExposeEvent *ev = &e->xexpose;
|
|
||||||
int screen;
|
int screen;
|
||||||
Statusbar *statusbar;
|
Statusbar *statusbar;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
@ -313,174 +329,249 @@ event_handle_expose(XEvent *e)
|
||||||
if(statusbar->sw->window == ev->window)
|
if(statusbar->sw->window == ev->window)
|
||||||
{
|
{
|
||||||
statusbar_display(statusbar);
|
statusbar_display(statusbar);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(c->titlebar.sw && c->titlebar.sw->window == ev->window)
|
if(c->titlebar.sw && c->titlebar.sw->window == ev->window)
|
||||||
{
|
{
|
||||||
simplewindow_refresh_drawable(c->titlebar.sw, c->phys_screen);
|
simplewindow_refresh_drawable(c->titlebar.sw, c->phys_screen);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XKey events
|
/** Handle XKey events
|
||||||
* \param e XEvent
|
* \param connection connection to the X server
|
||||||
|
* \param ev KeyPress event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_keypress(XEvent *e)
|
event_handle_keypress(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection, xcb_key_press_event_t *ev)
|
||||||
{
|
{
|
||||||
int screen, x, y, d;
|
int screen;
|
||||||
unsigned int m;
|
xcb_query_pointer_reply_t *qpr = NULL;
|
||||||
XKeyEvent *ev = &e->xkey;
|
xcb_key_symbols_t *keysyms;
|
||||||
KeySym keysym;
|
xcb_keysym_t keysym;
|
||||||
Window dummy;
|
|
||||||
Key *k;
|
Key *k;
|
||||||
|
|
||||||
/* find the right screen for this event */
|
/* find the right screen for this event */
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
for(screen = 0; screen < xcb_setup_roots_length (xcb_get_setup (connection)); screen++)
|
||||||
if(XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen), &dummy, &dummy, &x, &y, &d, &d, &m))
|
if((qpr = xcb_query_pointer_reply(connection,
|
||||||
|
xcb_query_pointer(connection,
|
||||||
|
root_window(connection, screen)),
|
||||||
|
NULL)) != NULL)
|
||||||
{
|
{
|
||||||
/* if screen is 0, we are on first Zaphod screen or on the
|
/* if screen is 0, we are on first Zaphod screen or on the
|
||||||
* only screen in Xinerama, so we can ask for a better screen
|
* only screen in Xinerama, so we can ask for a better screen
|
||||||
* number with screen_get_bycoord: we'll get 0 in Zaphod mode
|
* number with screen_get_bycoord: we'll get 0 in Zaphod mode
|
||||||
* so it's the same, or maybe the real Xinerama screen */
|
* so it's the same, or maybe the real Xinerama screen */
|
||||||
screen = screen_get_bycoord(globalconf.screens_info, screen, x, y);
|
screen = screen_get_bycoord(globalconf.screens_info, screen, qpr->root_x, qpr->root_y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
keysym = XKeycodeToKeysym(globalconf.display, (KeyCode) ev->keycode, 0);
|
keysyms = xcb_key_symbols_alloc(globalconf.connection);
|
||||||
|
keysym = xcb_key_symbols_get_keysym(keysyms, ev->detail, 0);
|
||||||
|
|
||||||
for(k = globalconf.keys; k; k = k->next)
|
for(k = globalconf.keys; k; k = k->next)
|
||||||
if(((k->keycode && ev->keycode == k->keycode) || (k->keysym && keysym == k->keysym)) &&
|
if(((k->keycode && ev->detail == k->keycode) || (k->keysym && keysym == k->keysym))
|
||||||
k->func && CLEANMASK(k->mod) == CLEANMASK(ev->state))
|
&& k->func && CLEANMASK(k->mod) == CLEANMASK(ev->state))
|
||||||
k->func(screen, k->arg);
|
k->func(screen, k->arg);
|
||||||
|
|
||||||
|
xcb_key_symbols_free(keysyms);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XMapping events
|
/** Handle XMapping events
|
||||||
* \param e XEvent
|
* \param connection connection to the X server
|
||||||
|
* \param ev MappingNotify event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_mappingnotify(XEvent *e)
|
event_handle_mappingnotify(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection, xcb_mapping_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
XMappingEvent *ev = &e->xmapping;
|
|
||||||
int screen;
|
int screen;
|
||||||
|
xcb_key_symbols_t *keysyms = xcb_key_symbols_alloc(connection);
|
||||||
|
|
||||||
XRefreshKeyboardMapping(ev);
|
xcb_refresh_keyboard_mapping(keysyms, ev);
|
||||||
if(ev->request == MappingKeyboard)
|
xcb_key_symbols_free(keysyms);
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
|
||||||
|
if(ev->request == XCB_MAPPING_KEYBOARD)
|
||||||
|
for(screen = 0; screen < xcb_setup_roots_length(xcb_get_setup(connection)); screen++)
|
||||||
window_root_grabkeys(screen);
|
window_root_grabkeys(screen);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XMapRequest events
|
/** Handle XMapRequest events
|
||||||
* \param e XEvent
|
* \param connection connection to the X server
|
||||||
|
* \param ev MapRequest event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_maprequest(XEvent *e)
|
event_handle_maprequest(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection, xcb_map_request_event_t *ev)
|
||||||
{
|
{
|
||||||
static XWindowAttributes wa;
|
static xcb_get_window_attributes_reply_t *wa;
|
||||||
XMapRequestEvent *ev = &e->xmaprequest;
|
int screen_nbr = 0;
|
||||||
int screen = 0, x, y, d;
|
xcb_query_pointer_reply_t *qpr = NULL;
|
||||||
unsigned int m;
|
xcb_get_geometry_reply_t *wgeom;
|
||||||
Window dummy;
|
xcb_screen_iterator_t iter;
|
||||||
|
|
||||||
if(!XGetWindowAttributes(e->xany.display, ev->window, &wa))
|
if((wa = xcb_get_window_attributes_reply(connection,
|
||||||
return;
|
xcb_get_window_attributes(connection, ev->window),
|
||||||
if(wa.override_redirect)
|
NULL)) == NULL)
|
||||||
return;
|
return -1;
|
||||||
|
if(wa->override_redirect)
|
||||||
|
{
|
||||||
|
p_delete(&wa);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if(!client_get_bywin(globalconf.clients, ev->window))
|
if(!client_get_bywin(globalconf.clients, ev->window))
|
||||||
{
|
{
|
||||||
if(globalconf.screens_info->xinerama_is_active
|
if((wgeom = xcb_get_geometry_reply(connection,
|
||||||
&& XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen),
|
xcb_get_geometry(connection, ev->window), NULL)) == NULL)
|
||||||
&dummy, &dummy, &x, &y, &d, &d, &m))
|
return -1;
|
||||||
screen = screen_get_bycoord(globalconf.screens_info, screen, x, y);
|
|
||||||
else
|
|
||||||
for(screen = 0; wa.screen != ScreenOfDisplay(e->xany.display, screen); screen++);
|
|
||||||
|
|
||||||
client_manage(ev->window, &wa, screen);
|
if(globalconf.screens_info->xinerama_is_active
|
||||||
|
&& (qpr = xcb_query_pointer_reply(connection,
|
||||||
|
xcb_query_pointer(connection,
|
||||||
|
root_window(globalconf.connection, screen_nbr)),
|
||||||
|
NULL)) != NULL)
|
||||||
|
screen_nbr = screen_get_bycoord(globalconf.screens_info, screen_nbr, qpr->root_x, qpr->root_y);
|
||||||
|
else
|
||||||
|
for (iter = xcb_setup_roots_iterator (xcb_get_setup (connection)), screen_nbr = 0;
|
||||||
|
iter.rem && iter.data->root != wgeom->root; xcb_screen_next (&iter), ++screen_nbr);
|
||||||
|
|
||||||
|
if(qpr)
|
||||||
|
p_delete(&qpr);
|
||||||
|
|
||||||
|
client_manage(ev->window, wgeom, screen_nbr);
|
||||||
|
p_delete(&wgeom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XProperty events
|
/** Handle XProperty events
|
||||||
* \param e XEvent
|
* \param connection connection to the X server
|
||||||
|
* \param ev PropertyNotify event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_propertynotify(XEvent * e)
|
event_handle_propertynotify(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection, xcb_property_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
Window trans;
|
xcb_window_t trans;
|
||||||
XPropertyEvent *ev = &e->xproperty;
|
|
||||||
|
|
||||||
if(ev->state == PropertyDelete)
|
if(ev->state == XCB_PROPERTY_DELETE)
|
||||||
return; /* ignore */
|
return 0; /* ignore */
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
||||||
{
|
{
|
||||||
switch (ev->atom)
|
if(ev->atom == WM_TRANSIENT_FOR)
|
||||||
{
|
{
|
||||||
case XA_WM_TRANSIENT_FOR:
|
x_get_transient_for_hint(connection, c->win, &trans);
|
||||||
XGetTransientForHint(e->xany.display, c->win, &trans);
|
|
||||||
if(!c->isfloating
|
if(!c->isfloating
|
||||||
&& (c->isfloating = (client_get_bywin(globalconf.clients, trans) != NULL)))
|
&& (c->isfloating = (client_get_bywin(globalconf.clients, trans) != NULL)))
|
||||||
globalconf.screens[c->screen].need_arrange = True;
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
break;
|
|
||||||
case XA_WM_NORMAL_HINTS:
|
|
||||||
client_updatesizehints(c);
|
|
||||||
break;
|
|
||||||
case XA_WM_HINTS:
|
|
||||||
client_updatewmhints(c);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(globalconf.display, "_NET_WM_NAME", False))
|
else if (ev->atom == WM_NORMAL_HINTS)
|
||||||
|
client_updatesizehints(c);
|
||||||
|
else if (ev->atom == WM_HINTS)
|
||||||
|
client_updatewmhints(c);
|
||||||
|
|
||||||
|
if(ev->atom == WM_NAME || ev->atom == x_intern_atom(globalconf.connection, "_NET_WM_NAME"))
|
||||||
client_updatetitle(c);
|
client_updatetitle(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XUnmap events
|
/** Handle XUnmap events
|
||||||
* \param e XEvent
|
* \param connection connection to the X server
|
||||||
|
* \param ev UnmapNotify event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_unmapnotify(XEvent * e)
|
event_handle_unmapnotify(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection, xcb_unmap_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
XUnmapEvent *ev = &e->xunmap;
|
|
||||||
|
/*
|
||||||
|
* event->send_event (Xlib) is quivalent to (ev->response_type &
|
||||||
|
* 0x80) in XCB because the SendEvent bit is available in the
|
||||||
|
* response_type field
|
||||||
|
*/
|
||||||
|
bool send_event = ((ev->response_type & 0x80) >> 7);
|
||||||
|
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window))
|
if((c = client_get_bywin(globalconf.clients, ev->window))
|
||||||
&& ev->event == RootWindow(e->xany.display, c->phys_screen)
|
&& ev->event == root_window(connection, c->phys_screen)
|
||||||
&& ev->send_event && window_getstate(c->win) == NormalState)
|
&& send_event && window_getstate(c->win) == XCB_WM_NORMAL_STATE)
|
||||||
client_unmanage(c);
|
client_unmanage(c);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XShape events
|
/** Handle XShape events
|
||||||
* \param e XEvent
|
* \param ev Shape event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_shape(XEvent * e)
|
event_handle_shape(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection __attribute__ ((unused)),
|
||||||
|
xcb_shape_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
XShapeEvent *ev = (XShapeEvent *) e;
|
Client *c = client_get_bywin(globalconf.clients, ev->affected_window);
|
||||||
Client *c = client_get_bywin(globalconf.clients, ev->window);
|
|
||||||
|
|
||||||
if(c)
|
if(c)
|
||||||
window_setshape(c->win, c->phys_screen);
|
window_setshape(c->win, c->phys_screen);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XRandR events
|
/** Handle XRandR events
|
||||||
* \param e XEvent
|
* \param ev RandrScreenChangeNotify event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_randr_screen_change_notify(XEvent *e)
|
event_handle_randr_screen_change_notify(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection __attribute__ ((unused)),
|
||||||
|
xcb_randr_screen_change_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
XRRUpdateConfiguration(e);
|
if(!globalconf.have_randr)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Code of XRRUpdateConfiguration Xlib function ported to XCB
|
||||||
|
* (only the code relevant to RRScreenChangeNotify) as the latter
|
||||||
|
* doesn't provide this kind of function */
|
||||||
|
if(ev->rotation & (XCB_RANDR_ROTATION_ROTATE_90 | XCB_RANDR_ROTATION_ROTATE_270))
|
||||||
|
xcb_randr_set_screen_size(connection, ev->root, ev->height, ev->width,
|
||||||
|
ev->mheight, ev->mwidth);
|
||||||
|
else
|
||||||
|
xcb_randr_set_screen_size(connection, ev->root, ev->width, ev->height,
|
||||||
|
ev->mwidth, ev->mheight);
|
||||||
|
|
||||||
|
/* TODO:
|
||||||
|
* XRRUpdateConfiguration also executes the following instruction
|
||||||
|
* but I don't know yet how to port it to XCB
|
||||||
|
*
|
||||||
|
* XRenderSetSubpixelOrder(dpy, snum, scevent->subpixel_order);
|
||||||
|
*/
|
||||||
|
|
||||||
uicb_restart(0, NULL);
|
uicb_restart(0, NULL);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle XClientMessage events
|
/** Handle XClientMessage events
|
||||||
* \param e XEvent
|
* \param ev ClientMessage event
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
event_handle_clientmessage(XEvent *e)
|
event_handle_clientmessage(void *data __attribute__ ((unused)),
|
||||||
|
xcb_connection_t *connection __attribute__ ((unused)),
|
||||||
|
xcb_client_message_event_t *ev)
|
||||||
{
|
{
|
||||||
ewmh_process_client_message(&e->xclient);
|
ewmh_process_client_message(ev);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
34
event.h
34
event.h
|
@ -22,24 +22,26 @@
|
||||||
#ifndef AWESOME_EVENT_H
|
#ifndef AWESOME_EVENT_H
|
||||||
#define AWESOME_EVENT_H
|
#define AWESOME_EVENT_H
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/randr.h>
|
||||||
|
#include <xcb/shape.h>
|
||||||
|
|
||||||
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | LockMask))
|
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | XCB_MOD_MASK_LOCK))
|
||||||
|
|
||||||
void event_handle_buttonpress(XEvent *);
|
int event_handle_buttonpress(void *, xcb_connection_t *, xcb_button_press_event_t *);
|
||||||
void event_handle_configurerequest(XEvent *);
|
int event_handle_configurerequest(void *, xcb_connection_t *, xcb_configure_request_event_t *);
|
||||||
void event_handle_configurenotify(XEvent *);
|
int event_handle_configurenotify(void *, xcb_connection_t *, xcb_configure_notify_event_t *);
|
||||||
void event_handle_destroynotify(XEvent *);
|
int event_handle_destroynotify(void *, xcb_connection_t *, xcb_destroy_notify_event_t *);
|
||||||
void event_handle_enternotify(XEvent *);
|
int event_handle_enternotify(void *, xcb_connection_t *, xcb_enter_notify_event_t *);
|
||||||
void event_handle_expose(XEvent *);
|
int event_handle_expose(void *, xcb_connection_t *, xcb_expose_event_t *);
|
||||||
void event_handle_keypress(XEvent *);
|
int event_handle_keypress(void *, xcb_connection_t *, xcb_key_press_event_t *);
|
||||||
void event_handle_mappingnotify(XEvent *);
|
int event_handle_mappingnotify(void *, xcb_connection_t *, xcb_mapping_notify_event_t *);
|
||||||
void event_handle_maprequest(XEvent *);
|
int event_handle_maprequest(void *, xcb_connection_t *, xcb_map_request_event_t *);
|
||||||
void event_handle_propertynotify(XEvent *);
|
int event_handle_propertynotify(void *, xcb_connection_t *, xcb_property_notify_event_t *);
|
||||||
void event_handle_unmapnotify(XEvent *);
|
int event_handle_unmapnotify(void *, xcb_connection_t *, xcb_unmap_notify_event_t *);
|
||||||
void event_handle_shape(XEvent *);
|
int event_handle_shape(void *, xcb_connection_t *, xcb_shape_notify_event_t *);
|
||||||
void event_handle_randr_screen_change_notify(XEvent *);
|
int event_handle_randr_screen_change_notify(void *, xcb_connection_t *, xcb_randr_screen_change_notify_event_t *);
|
||||||
void event_handle_clientmessage(XEvent *);
|
int event_handle_clientmessage(void *, xcb_connection_t *, xcb_client_message_event_t *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// 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
|
||||||
|
|
264
ewmh.c
264
ewmh.c
|
@ -19,8 +19,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <X11/Xatom.h>
|
#include <xcb/xcb.h>
|
||||||
#include <X11/Xmd.h>
|
#include <xcb/xcb_atom.h>
|
||||||
|
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
|
@ -32,36 +32,34 @@
|
||||||
|
|
||||||
extern AwesomeConf globalconf;
|
extern AwesomeConf globalconf;
|
||||||
|
|
||||||
static Atom net_supported;
|
static xcb_atom_t net_supported;
|
||||||
static Atom net_client_list;
|
static xcb_atom_t net_client_list;
|
||||||
static Atom net_number_of_desktops;
|
static xcb_atom_t net_number_of_desktops;
|
||||||
static Atom net_current_desktop;
|
static xcb_atom_t net_current_desktop;
|
||||||
static Atom net_desktop_names;
|
static xcb_atom_t net_desktop_names;
|
||||||
static Atom net_active_window;
|
static xcb_atom_t net_active_window;
|
||||||
|
static xcb_atom_t net_close_window;
|
||||||
|
static xcb_atom_t net_wm_name;
|
||||||
|
static xcb_atom_t net_wm_icon_name;
|
||||||
|
static xcb_atom_t net_wm_window_type;
|
||||||
|
static xcb_atom_t net_wm_window_type_normal;
|
||||||
|
static xcb_atom_t net_wm_window_type_dock;
|
||||||
|
static xcb_atom_t net_wm_window_type_splash;
|
||||||
|
static xcb_atom_t net_wm_window_type_dialog;
|
||||||
|
static xcb_atom_t net_wm_icon;
|
||||||
|
static xcb_atom_t net_wm_state;
|
||||||
|
static xcb_atom_t net_wm_state_sticky;
|
||||||
|
static xcb_atom_t net_wm_state_skip_taskbar;
|
||||||
|
static xcb_atom_t net_wm_state_fullscreen;
|
||||||
|
static xcb_atom_t net_wm_state_above;
|
||||||
|
static xcb_atom_t net_wm_state_below;
|
||||||
|
|
||||||
static Atom net_close_window;
|
static xcb_atom_t utf8_string;
|
||||||
|
|
||||||
static Atom net_wm_name;
|
|
||||||
static Atom net_wm_icon_name;
|
|
||||||
static Atom net_wm_window_type;
|
|
||||||
static Atom net_wm_window_type_normal;
|
|
||||||
static Atom net_wm_window_type_dock;
|
|
||||||
static Atom net_wm_window_type_splash;
|
|
||||||
static Atom net_wm_window_type_dialog;
|
|
||||||
static Atom net_wm_icon;
|
|
||||||
static Atom net_wm_state;
|
|
||||||
static Atom net_wm_state_sticky;
|
|
||||||
static Atom net_wm_state_skip_taskbar;
|
|
||||||
static Atom net_wm_state_fullscreen;
|
|
||||||
static Atom net_wm_state_above;
|
|
||||||
static Atom net_wm_state_below;
|
|
||||||
|
|
||||||
static Atom utf8_string;
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
Atom *atom;
|
xcb_atom_t *atom;
|
||||||
} AtomItem;
|
} AtomItem;
|
||||||
|
|
||||||
static AtomItem AtomNames[] =
|
static AtomItem AtomNames[] =
|
||||||
|
@ -103,20 +101,35 @@ void
|
||||||
ewmh_init_atoms(void)
|
ewmh_init_atoms(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char *names[ATOM_NUMBER];
|
xcb_intern_atom_cookie_t cs[ATOM_NUMBER];
|
||||||
Atom atoms[ATOM_NUMBER];
|
xcb_intern_atom_reply_t *r;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the atom and get the reply in a XCB way (e.g. send all
|
||||||
|
* the requests at the same time and then get the replies)
|
||||||
|
*/
|
||||||
|
for(i = 0; i < ATOM_NUMBER; i++)
|
||||||
|
cs[i] = xcb_intern_atom_unchecked(globalconf.connection,
|
||||||
|
false,
|
||||||
|
strlen(AtomNames[i].name),
|
||||||
|
AtomNames[i].name);
|
||||||
|
|
||||||
for(i = 0; i < ATOM_NUMBER; i++)
|
for(i = 0; i < ATOM_NUMBER; i++)
|
||||||
names[i] = (char *) AtomNames[i].name;
|
{
|
||||||
XInternAtoms(globalconf.display, names, ATOM_NUMBER, False, atoms);
|
r = xcb_intern_atom_reply(globalconf.connection, cs[i], NULL);
|
||||||
for(i = 0; i < ATOM_NUMBER; i++)
|
if(!r)
|
||||||
*AtomNames[i].atom = atoms[i];
|
/* An error occured, get reply for next atom */
|
||||||
|
continue;
|
||||||
|
|
||||||
|
*AtomNames[i].atom = r->atom;
|
||||||
|
p_delete(&r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ewmh_set_supported_hints(int phys_screen)
|
ewmh_set_supported_hints(int phys_screen)
|
||||||
{
|
{
|
||||||
Atom atom[ATOM_NUMBER];
|
xcb_atom_t atom[ATOM_NUMBER];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
atom[i++] = net_supported;
|
atom[i++] = net_supported;
|
||||||
|
@ -143,29 +156,30 @@ ewmh_set_supported_hints(int phys_screen)
|
||||||
atom[i++] = net_wm_state_above;
|
atom[i++] = net_wm_state_above;
|
||||||
atom[i++] = net_wm_state_below;
|
atom[i++] = net_wm_state_below;
|
||||||
|
|
||||||
XChangeProperty(globalconf.display, RootWindow(globalconf.display, phys_screen),
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||||
net_supported, XA_ATOM, 32,
|
root_window(globalconf.connection, phys_screen),
|
||||||
PropModeReplace, (unsigned char *) atom, i);
|
net_supported, ATOM, 32, i, atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ewmh_update_net_client_list(int phys_screen)
|
ewmh_update_net_client_list(int phys_screen)
|
||||||
{
|
{
|
||||||
Window *wins;
|
xcb_window_t *wins;
|
||||||
Client *c;
|
Client *c;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
wins = p_new(Window, n);
|
wins = p_new(xcb_window_t, n);
|
||||||
|
|
||||||
for(n = 0, c = globalconf.clients; c; c = c->next, n++)
|
for(n = 0, c = globalconf.clients; c; c = c->next, n++)
|
||||||
if(c->phys_screen == phys_screen)
|
if(c->phys_screen == phys_screen)
|
||||||
wins[n] = c->win;
|
wins[n] = c->win;
|
||||||
|
|
||||||
XChangeProperty(globalconf.display, RootWindow(globalconf.display, phys_screen),
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||||
net_client_list, XA_WINDOW, 32, PropModeReplace, (unsigned char *) wins, n);
|
root_window(globalconf.connection, phys_screen),
|
||||||
|
net_client_list, WINDOW, 32, n, wins);
|
||||||
|
|
||||||
p_delete(&wins);
|
p_delete(&wins);
|
||||||
}
|
}
|
||||||
|
@ -173,27 +187,29 @@ ewmh_update_net_client_list(int phys_screen)
|
||||||
void
|
void
|
||||||
ewmh_update_net_numbers_of_desktop(int phys_screen)
|
ewmh_update_net_numbers_of_desktop(int phys_screen)
|
||||||
{
|
{
|
||||||
CARD32 count = 0;
|
uint32_t count = 0;
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
|
|
||||||
for(tag = globalconf.screens[phys_screen].tags; tag; tag = tag->next)
|
for(tag = globalconf.screens[phys_screen].tags; tag; tag = tag->next)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
XChangeProperty(globalconf.display, RootWindow(globalconf.display, phys_screen),
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||||
net_number_of_desktops, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &count, 1);
|
root_window(globalconf.connection, phys_screen),
|
||||||
|
net_number_of_desktops, CARDINAL, 32, 1, &count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ewmh_update_net_current_desktop(int phys_screen)
|
ewmh_update_net_current_desktop(int phys_screen)
|
||||||
{
|
{
|
||||||
CARD32 count = 0;
|
uint32_t count = 0;
|
||||||
Tag *tag, **curtags = tags_get_current(phys_screen);
|
Tag *tag, **curtags = tags_get_current(phys_screen);
|
||||||
|
|
||||||
for(tag = globalconf.screens[phys_screen].tags; tag != curtags[0]; tag = tag->next)
|
for(tag = globalconf.screens[phys_screen].tags; tag != curtags[0]; tag = tag->next)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
XChangeProperty(globalconf.display, RootWindow(globalconf.display, phys_screen),
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||||
net_current_desktop, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &count, 1);
|
root_window(globalconf.connection, phys_screen),
|
||||||
|
net_current_desktop, CARDINAL, 32, 1, &count);
|
||||||
|
|
||||||
p_delete(&curtags);
|
p_delete(&curtags);
|
||||||
}
|
}
|
||||||
|
@ -215,25 +231,29 @@ ewmh_update_net_desktop_names(int phys_screen)
|
||||||
len += curr_size + 1;
|
len += curr_size + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
XChangeProperty(globalconf.display, RootWindow(globalconf.display, phys_screen),
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||||
net_desktop_names, utf8_string, 8, PropModeReplace, (unsigned char *) buf, len);
|
root_window(globalconf.connection, phys_screen),
|
||||||
|
net_desktop_names, utf8_string, 8, len, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ewmh_update_net_active_window(int phys_screen)
|
ewmh_update_net_active_window(int phys_screen)
|
||||||
{
|
{
|
||||||
Window win;
|
xcb_window_t win;
|
||||||
Client *sel = focus_get_current_client(phys_screen);
|
Client *sel = focus_get_current_client(phys_screen);
|
||||||
|
|
||||||
win = sel ? sel->win : None;
|
win = sel ? sel->win : XCB_NONE;
|
||||||
|
|
||||||
XChangeProperty(globalconf.display, RootWindow(globalconf.display, phys_screen),
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||||
net_active_window, XA_WINDOW, 32, PropModeReplace, (unsigned char *) &win, 1);
|
root_window(globalconf.connection, phys_screen),
|
||||||
|
net_active_window, WINDOW, 32, 1, &win);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ewmh_process_state_atom(Client *c, Atom state, int set)
|
ewmh_process_state_atom(Client *c, xcb_atom_t state, int set)
|
||||||
{
|
{
|
||||||
|
const uint32_t raise_window_val = XCB_STACK_MODE_ABOVE;
|
||||||
|
|
||||||
if(state == net_wm_state_sticky)
|
if(state == net_wm_state_sticky)
|
||||||
{
|
{
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
|
@ -244,13 +264,13 @@ ewmh_process_state_atom(Client *c, Atom state, int set)
|
||||||
{
|
{
|
||||||
if(set == _NET_WM_STATE_REMOVE)
|
if(set == _NET_WM_STATE_REMOVE)
|
||||||
{
|
{
|
||||||
c->skiptb = False;
|
c->skiptb = false;
|
||||||
c->skip = False;
|
c->skip = false;
|
||||||
}
|
}
|
||||||
else if(set == _NET_WM_STATE_ADD)
|
else if(set == _NET_WM_STATE_ADD)
|
||||||
{
|
{
|
||||||
c->skiptb = True;
|
c->skiptb = true;
|
||||||
c->skip = True;
|
c->skip = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(state == net_wm_state_fullscreen)
|
else if(state == net_wm_state_fullscreen)
|
||||||
|
@ -263,7 +283,7 @@ ewmh_process_state_atom(Client *c, Atom state, int set)
|
||||||
/* restore borders and titlebar */
|
/* restore borders and titlebar */
|
||||||
titlebar_position_set(&c->titlebar, c->titlebar.dposition);
|
titlebar_position_set(&c->titlebar, c->titlebar.dposition);
|
||||||
c->border = c->oldborder;
|
c->border = c->oldborder;
|
||||||
c->ismax = False;
|
c->ismax = false;
|
||||||
client_setfloating(c, c->wasfloating, c->oldlayer);
|
client_setfloating(c, c->wasfloating, c->oldlayer);
|
||||||
}
|
}
|
||||||
else if(set == _NET_WM_STATE_ADD)
|
else if(set == _NET_WM_STATE_ADD)
|
||||||
|
@ -276,12 +296,12 @@ ewmh_process_state_atom(Client *c, Atom state, int set)
|
||||||
titlebar_position_set(&c->titlebar, Off);
|
titlebar_position_set(&c->titlebar, Off);
|
||||||
c->oldborder = c->border;
|
c->oldborder = c->border;
|
||||||
c->border = 0;
|
c->border = 0;
|
||||||
c->ismax = True;
|
c->ismax = true;
|
||||||
client_setfloating(c, True, LAYER_FULLSCREEN);
|
client_setfloating(c, true, LAYER_FULLSCREEN);
|
||||||
}
|
}
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
client_resize(c, geometry, False);
|
client_resize(c, geometry, false);
|
||||||
XRaiseWindow(globalconf.display, c->win);
|
xcb_configure_window(globalconf.connection, c->win, XCB_CONFIG_WINDOW_STACK_MODE, &raise_window_val);
|
||||||
}
|
}
|
||||||
else if(state == net_wm_state_above)
|
else if(state == net_wm_state_above)
|
||||||
{
|
{
|
||||||
|
@ -311,7 +331,7 @@ ewmh_process_state_atom(Client *c, Atom state, int set)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ewmh_process_window_type_atom(Client *c, Atom state)
|
ewmh_process_window_type_atom(Client *c, xcb_atom_t state)
|
||||||
{
|
{
|
||||||
if(state == net_wm_window_type_normal)
|
if(state == net_wm_window_type_normal)
|
||||||
{
|
{
|
||||||
|
@ -321,40 +341,47 @@ ewmh_process_window_type_atom(Client *c, Atom state)
|
||||||
|| state == net_wm_window_type_splash)
|
|| state == net_wm_window_type_splash)
|
||||||
{
|
{
|
||||||
c->border = 0;
|
c->border = 0;
|
||||||
c->skip = True;
|
c->skip = true;
|
||||||
c->isfixed = True;
|
c->isfixed = true;
|
||||||
titlebar_position_set(&c->titlebar, Off);
|
titlebar_position_set(&c->titlebar, Off);
|
||||||
client_setfloating(c, True, LAYER_ABOVE);
|
client_setfloating(c, true, LAYER_ABOVE);
|
||||||
}
|
}
|
||||||
else if (state == net_wm_window_type_dialog)
|
else if (state == net_wm_window_type_dialog)
|
||||||
{
|
client_setfloating(c, true, LAYER_ABOVE);
|
||||||
client_setfloating(c, True, LAYER_ABOVE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ewmh_process_client_message(XClientMessageEvent *ev)
|
ewmh_process_client_message(xcb_client_message_event_t *ev)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
int screen;
|
int screen;
|
||||||
|
|
||||||
if(ev->message_type == net_current_desktop)
|
/* TODO: check whether it's correct to use 'type' this way */
|
||||||
for(screen = 0; screen < ScreenCount(globalconf.display); screen++)
|
if(ev->type == net_current_desktop)
|
||||||
if(ev->window == RootWindow(globalconf.display, screen))
|
for(screen = 0;
|
||||||
tag_view_only_byindex(screen, ev->data.l[0]);
|
screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
|
||||||
|
screen++)
|
||||||
|
{
|
||||||
|
if(ev->window == root_window(globalconf.connection, screen))
|
||||||
|
tag_view_only_byindex(screen, ev->data.data32[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if(ev->message_type == net_close_window)
|
if(ev->type == net_close_window)
|
||||||
{
|
{
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
||||||
client_kill(c);
|
client_kill(c);
|
||||||
}
|
}
|
||||||
else if(ev->message_type == net_wm_state)
|
else if(ev->type == net_wm_state)
|
||||||
{
|
{
|
||||||
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
||||||
{
|
{
|
||||||
ewmh_process_state_atom(c, (Atom) ev->data.l[1], ev->data.l[0]);
|
ewmh_process_state_atom(c, (xcb_atom_t) ev->data.data32[1], ev->data.data32[0]);
|
||||||
if(ev->data.l[2])
|
/* TODO: is data32[2] really useful because it doesn't
|
||||||
ewmh_process_state_atom(c, (Atom) ev->data.l[2], ev->data.l[0]);
|
* seem to be used when sending a ClientMessage in
|
||||||
|
* event.c:897 */
|
||||||
|
if(ev->data.data32[2])
|
||||||
|
ewmh_process_state_atom(c, (xcb_atom_t) ev->data.data32[2],
|
||||||
|
ev->data.data32[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,53 +389,66 @@ ewmh_process_client_message(XClientMessageEvent *ev)
|
||||||
void
|
void
|
||||||
ewmh_check_client_hints(Client *c)
|
ewmh_check_client_hints(Client *c)
|
||||||
{
|
{
|
||||||
int format;
|
xcb_atom_t *state;
|
||||||
Atom real, *state;
|
void *data = NULL;
|
||||||
unsigned char *data = NULL;
|
int i;
|
||||||
unsigned long i, n, extra;
|
|
||||||
|
|
||||||
if(XGetWindowProperty(globalconf.display, c->win, net_wm_state, 0L, LONG_MAX, False,
|
xcb_get_property_cookie_t c1, c2;
|
||||||
XA_ATOM, &real, &format, &n, &extra,
|
xcb_get_property_reply_t *reply;
|
||||||
(unsigned char **) &data) == Success && data)
|
|
||||||
|
/* Send the GetProperty requests which will be processed later */
|
||||||
|
c1 = xcb_get_property_unchecked(globalconf.connection, false, c->win,
|
||||||
|
net_wm_state, ATOM, 0, UINT32_MAX);
|
||||||
|
|
||||||
|
c2 = xcb_get_property_unchecked(globalconf.connection, false, c->win,
|
||||||
|
net_wm_window_type, ATOM, 0, UINT32_MAX);
|
||||||
|
|
||||||
|
reply = xcb_get_property_reply(globalconf.connection, c1, NULL);
|
||||||
|
if(reply && (data = xcb_get_property_value(reply)))
|
||||||
{
|
{
|
||||||
state = (Atom *) data;
|
state = (xcb_atom_t *) data;
|
||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < xcb_get_property_value_length(reply); i++)
|
||||||
ewmh_process_state_atom(c, state[i], _NET_WM_STATE_ADD);
|
ewmh_process_state_atom(c, state[i], _NET_WM_STATE_ADD);
|
||||||
|
|
||||||
XFree(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(XGetWindowProperty(globalconf.display, c->win, net_wm_window_type, 0L, LONG_MAX, False,
|
p_delete(&reply);
|
||||||
XA_ATOM, &real, &format, &n, &extra,
|
|
||||||
(unsigned char **) &data) == Success && data)
|
reply = xcb_get_property_reply(globalconf.connection, c2, NULL);
|
||||||
|
if(reply && (data = xcb_get_property_value(reply)))
|
||||||
{
|
{
|
||||||
state = (Atom *) data;
|
state = (xcb_atom_t *) data;
|
||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < xcb_get_property_value_length(reply); i++)
|
||||||
ewmh_process_window_type_atom(c, state[i]);
|
ewmh_process_window_type_atom(c, state[i]);
|
||||||
|
|
||||||
XFree(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p_delete(&reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetWMIcon *
|
NetWMIcon *
|
||||||
ewmh_get_window_icon(Window w)
|
ewmh_get_window_icon(xcb_window_t w)
|
||||||
{
|
{
|
||||||
double alpha;
|
double alpha;
|
||||||
NetWMIcon *icon;
|
NetWMIcon *icon;
|
||||||
Atom type;
|
int size, i;
|
||||||
int format, size, i;
|
unsigned long *data;
|
||||||
unsigned long items, rest, *data;
|
|
||||||
unsigned char *imgdata, *wdata;
|
unsigned char *imgdata, *wdata;
|
||||||
|
xcb_get_property_reply_t *r;
|
||||||
|
|
||||||
if(XGetWindowProperty(globalconf.display, w,
|
r = xcb_get_property_reply(globalconf.connection,
|
||||||
net_wm_icon, 0L, LONG_MAX, False, XA_CARDINAL, &type, &format,
|
xcb_get_property_unchecked(globalconf.connection, false, w,
|
||||||
&items, &rest, &wdata) != Success
|
net_wm_icon, CARDINAL, 0, UINT32_MAX),
|
||||||
|| !wdata)
|
NULL);
|
||||||
return NULL;
|
if(!r || !(wdata = (unsigned char *) xcb_get_property_value(r)))
|
||||||
|
|
||||||
if(type != XA_CARDINAL || format != 32 || items < 2)
|
|
||||||
{
|
{
|
||||||
XFree(wdata);
|
if(r)
|
||||||
|
p_delete(&r);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(r->type != CARDINAL || r->format != 32 || r->length < 2)
|
||||||
|
{
|
||||||
|
p_delete(&r);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +463,7 @@ ewmh_get_window_icon(Window w)
|
||||||
if(!size)
|
if(!size)
|
||||||
{
|
{
|
||||||
p_delete(&icon);
|
p_delete(&icon);
|
||||||
XFree(wdata);
|
p_delete(&r);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,7 +477,7 @@ ewmh_get_window_icon(Window w)
|
||||||
imgdata[0] = (data[i] & 0xff) * alpha; /* B */
|
imgdata[0] = (data[i] & 0xff) * alpha; /* B */
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(wdata);
|
p_delete(&r);
|
||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
4
ewmh.h
4
ewmh.h
|
@ -38,9 +38,9 @@ void ewmh_update_net_numbers_of_desktop(int);
|
||||||
void ewmh_update_net_current_desktop(int);
|
void ewmh_update_net_current_desktop(int);
|
||||||
void ewmh_update_net_desktop_names(int);
|
void ewmh_update_net_desktop_names(int);
|
||||||
void ewmh_update_net_active_window(int);
|
void ewmh_update_net_active_window(int);
|
||||||
void ewmh_process_client_message(XClientMessageEvent *);
|
void ewmh_process_client_message(xcb_client_message_event_t *);
|
||||||
void ewmh_check_client_hints(Client *);
|
void ewmh_check_client_hints(Client *);
|
||||||
NetWMIcon * ewmh_get_window_icon(Window);
|
NetWMIcon * ewmh_get_window_icon(xcb_window_t);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// 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
|
||||||
|
|
4
focus.c
4
focus.c
|
@ -122,7 +122,7 @@ uicb_focus_history(int screen, char *arg)
|
||||||
c = focus_get_latest_client_for_tags(curtags, i);
|
c = focus_get_latest_client_for_tags(curtags, i);
|
||||||
p_delete(&curtags);
|
p_delete(&curtags);
|
||||||
if(c)
|
if(c)
|
||||||
client_focus(c, screen, True);
|
client_focus(c, screen, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ uicb_focus_client_byname(int screen, char *arg)
|
||||||
if((c = client_get_byname(globalconf.clients, arg)))
|
if((c = client_get_byname(globalconf.clients, arg)))
|
||||||
for(tag = curtags; *tag; tag++)
|
for(tag = curtags; *tag; tag++)
|
||||||
if(is_client_tagged(c, *tag))
|
if(is_client_tagged(c, *tag))
|
||||||
client_focus(c, screen, True);
|
client_focus(c, screen, true);
|
||||||
p_delete(&curtags);
|
p_delete(&curtags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
34
layout.c
34
layout.c
|
@ -19,8 +19,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <X11/Xatom.h>
|
#include <xcb/xcb.h>
|
||||||
#include <X11/Xutil.h>
|
#include <xcb/xcb_atom.h>
|
||||||
|
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
|
@ -45,9 +45,8 @@ arrange(int screen)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
Layout *curlay = layout_get_current(screen);
|
Layout *curlay = layout_get_current(screen);
|
||||||
unsigned int dui;
|
int phys_screen = screen_virttophys(screen);
|
||||||
int di, x, y, phys_screen = screen_virttophys(screen);
|
xcb_query_pointer_reply_t *xqp;
|
||||||
Window rootwin, childwin;
|
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
{
|
{
|
||||||
|
@ -63,12 +62,12 @@ arrange(int screen)
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(c->newcomer && client_isvisible(c, screen))
|
if(c->newcomer && client_isvisible(c, screen))
|
||||||
{
|
{
|
||||||
c->newcomer = False;
|
c->newcomer = false;
|
||||||
client_unban(c);
|
client_unban(c);
|
||||||
if(globalconf.screens[screen].new_get_focus
|
if(globalconf.screens[screen].new_get_focus
|
||||||
&& !c->skip
|
&& !c->skip
|
||||||
&& (!globalconf.focus->client || !globalconf.focus->client->ismax))
|
&& (!globalconf.focus->client || !globalconf.focus->client->ismax))
|
||||||
client_focus(c, screen, True);
|
client_focus(c, screen, true);
|
||||||
else if(globalconf.focus->client && globalconf.focus->client->ismax)
|
else if(globalconf.focus->client && globalconf.focus->client->ismax)
|
||||||
client_stack(globalconf.focus->client);
|
client_stack(globalconf.focus->client);
|
||||||
}
|
}
|
||||||
|
@ -76,22 +75,23 @@ arrange(int screen)
|
||||||
/* if we have a valid client that could be focused but currently no window
|
/* if we have a valid client that could be focused but currently no window
|
||||||
* are focused, then set the focus on this window */
|
* are focused, then set the focus on this window */
|
||||||
if((c = focus_get_current_client(screen)) && globalconf.focus->client != c)
|
if((c = focus_get_current_client(screen)) && globalconf.focus->client != c)
|
||||||
client_focus(c, screen, True);
|
client_focus(c, screen, true);
|
||||||
|
|
||||||
/* check that the mouse is on a window or not */
|
/* check that the mouse is on a window or not */
|
||||||
if(XQueryPointer(globalconf.display,
|
if((xqp = xcb_query_pointer_reply(globalconf.connection,
|
||||||
RootWindow(globalconf.display, phys_screen),
|
xcb_query_pointer_unchecked(globalconf.connection,
|
||||||
&rootwin, &childwin, &x, &y, &di, &di, &dui))
|
root_window(globalconf.connection,
|
||||||
|
phys_screen)),
|
||||||
|
NULL)) != NULL
|
||||||
|
&& (xqp->root == XCB_NONE || xqp->child == XCB_NONE || xqp->root == xqp->child))
|
||||||
{
|
{
|
||||||
if(rootwin == None || childwin == None || childwin == rootwin)
|
window_root_grabbuttons(phys_screen);
|
||||||
window_root_grabbuttons(phys_screen);
|
globalconf.pointer_x = xqp->root_x;
|
||||||
|
globalconf.pointer_y = xqp->root_y;
|
||||||
globalconf.pointer_x = x;
|
|
||||||
globalconf.pointer_y = y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset status */
|
/* reset status */
|
||||||
globalconf.screens[screen].need_arrange = False;
|
globalconf.screens[screen].need_arrange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Refresh the screen disposition
|
/** Refresh the screen disposition
|
||||||
|
|
2
layout.h
2
layout.h
|
@ -22,8 +22,6 @@
|
||||||
#ifndef AWESOME_LAYOUT_H
|
#ifndef AWESOME_LAYOUT_H
|
||||||
#define AWESOME_LAYOUT_H
|
#define AWESOME_LAYOUT_H
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
|
|
||||||
#include "uicb.h"
|
#include "uicb.h"
|
||||||
#include "common/list.h"
|
#include "common/list.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
|
|
@ -43,7 +43,7 @@ layout_fibonacci(int screen, int shape)
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(IS_TILED(c, screen))
|
if(IS_TILED(c, screen))
|
||||||
{
|
{
|
||||||
c->ismax = False;
|
c->ismax = false;
|
||||||
if((i % 2 && geometry.height / 2 > 2 * c->border)
|
if((i % 2 && geometry.height / 2 > 2 * c->border)
|
||||||
|| (!(i % 2) && geometry.width / 2 > 2 * c->border))
|
|| (!(i % 2) && geometry.width / 2 > 2 * c->border))
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,6 @@ layout_floating(int screen)
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(client_isvisible(c, screen) && !c->ismax)
|
if(client_isvisible(c, screen) && !c->ismax)
|
||||||
client_resize(c, c->f_geometry, False);
|
client_resize(c, c->f_geometry, false);
|
||||||
}
|
}
|
||||||
// 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
|
||||||
|
|
|
@ -40,7 +40,7 @@ layout_max(int screen)
|
||||||
{
|
{
|
||||||
area.width -= 2 * c->border;
|
area.width -= 2 * c->border;
|
||||||
area.height -= 2 * c->border;
|
area.height -= 2 * c->border;
|
||||||
client_resize(c, area, False);
|
client_resize(c, area, false);
|
||||||
area.width += 2 * c->border;
|
area.width += 2 * c->border;
|
||||||
area.height += 2 * c->border;
|
area.height += 2 * c->border;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ uicb_tag_setnmaster(int screen, char * arg)
|
||||||
|
|
||||||
p_delete(&curtags);
|
p_delete(&curtags);
|
||||||
|
|
||||||
globalconf.screens[screen].need_arrange = True;
|
globalconf.screens[screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -87,7 +87,7 @@ uicb_tag_setncol(int screen, char * arg)
|
||||||
|
|
||||||
p_delete(&curtags);
|
p_delete(&curtags);
|
||||||
|
|
||||||
globalconf.screens[screen].need_arrange = True;
|
globalconf.screens[screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -121,7 +121,7 @@ uicb_tag_setmwfact(int screen, char *arg)
|
||||||
|
|
||||||
p_delete(&newarg);
|
p_delete(&newarg);
|
||||||
p_delete(&curtags);
|
p_delete(&curtags);
|
||||||
globalconf.screens[screen].need_arrange = True;
|
globalconf.screens[screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
329
mouse.c
329
mouse.c
|
@ -31,7 +31,7 @@
|
||||||
#include "layouts/tile.h"
|
#include "layouts/tile.h"
|
||||||
#include "common/xscreen.h"
|
#include "common/xscreen.h"
|
||||||
|
|
||||||
#define MOUSEMASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
|
#define MOUSEMASK (XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION)
|
||||||
|
|
||||||
extern AwesomeConf globalconf;
|
extern AwesomeConf globalconf;
|
||||||
|
|
||||||
|
@ -133,115 +133,141 @@ mouse_resizebar_draw(DrawCtx *ctx, style_t style, SimpleWindow *sw, area_t geome
|
||||||
void
|
void
|
||||||
uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
|
uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int x, y, ocx, ocy, di, newscreen;
|
int ocx, ocy, newscreen;
|
||||||
unsigned int dui;
|
|
||||||
Window dummy, child;
|
|
||||||
XEvent ev;
|
|
||||||
area_t geometry;
|
area_t geometry;
|
||||||
Client *c = globalconf.focus->client, *target;
|
Client *c = globalconf.focus->client, *target;
|
||||||
Layout *layout = layout_get_current(screen);
|
Layout *layout = layout_get_current(screen);
|
||||||
SimpleWindow *sw = NULL;
|
SimpleWindow *sw = NULL;
|
||||||
DrawCtx *ctx;
|
DrawCtx *ctx;
|
||||||
style_t style;
|
style_t style;
|
||||||
|
bool ignore_motion_events = false;
|
||||||
|
xcb_generic_event_t *ev = NULL;
|
||||||
|
xcb_motion_notify_event_t *ev_motion = NULL;
|
||||||
|
xcb_grab_pointer_reply_t *grab_pointer_r = NULL;
|
||||||
|
xcb_query_pointer_reply_t *query_pointer_r = NULL, *mquery_pointer_r = NULL;
|
||||||
|
|
||||||
if(!c
|
if(!c
|
||||||
|| XGrabPointer(globalconf.display,
|
|| xcb_grab_pointer_reply(globalconf.connection,
|
||||||
RootWindow(globalconf.display, c->phys_screen),
|
xcb_grab_pointer(globalconf.connection, false,
|
||||||
False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
root_window(globalconf.connection, c->phys_screen),
|
||||||
RootWindow(globalconf.display, c->phys_screen),
|
MOUSEMASK, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC,
|
||||||
globalconf.cursor[CurMove], CurrentTime) != GrabSuccess)
|
root_window(globalconf.connection, c->phys_screen),
|
||||||
|
globalconf.cursor[CurMove], XCB_CURRENT_TIME),
|
||||||
|
NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XQueryPointer(globalconf.display,
|
query_pointer_r = xcb_query_pointer_reply(globalconf.connection,
|
||||||
RootWindow(globalconf.display, c->phys_screen),
|
xcb_query_pointer_unchecked(globalconf.connection,
|
||||||
&dummy, &dummy, &x, &y, &di, &di, &dui);
|
root_window(globalconf.connection, c->phys_screen)),
|
||||||
|
NULL);
|
||||||
|
|
||||||
geometry = c->geometry;
|
geometry = c->geometry;
|
||||||
ocx = geometry.x;
|
ocx = geometry.x;
|
||||||
ocy = geometry.y;
|
ocy = geometry.y;
|
||||||
c->ismax = False;
|
c->ismax = false;
|
||||||
|
|
||||||
style = globalconf.screens[c->screen].styles.focus;
|
style = globalconf.screens[c->screen].styles.focus;
|
||||||
|
|
||||||
if(c->isfloating || layout->arrange == layout_floating)
|
if(c->isfloating || layout->arrange == layout_floating)
|
||||||
{
|
{
|
||||||
sw = simplewindow_new(globalconf.display, c->phys_screen, 0, 0,
|
sw = simplewindow_new(globalconf.connection, c->phys_screen, 0, 0,
|
||||||
draw_textwidth(globalconf.display,
|
draw_textwidth(globalconf.connection,
|
||||||
|
globalconf.default_screen,
|
||||||
globalconf.screens[c->screen].styles.focus.font,
|
globalconf.screens[c->screen].styles.focus.font,
|
||||||
"0000x0000+0000+0000") + style.font->height,
|
"0000x0000+0000+0000") + style.font->height,
|
||||||
1.5 * style.font->height, 0);
|
1.5 * style.font->height, 0);
|
||||||
|
|
||||||
ctx = draw_context_new(globalconf.display, sw->phys_screen,
|
ctx = draw_context_new(globalconf.connection, sw->phys_screen,
|
||||||
sw->geometry.width, sw->geometry.height,
|
sw->geometry.width, sw->geometry.height,
|
||||||
sw->drawable);
|
sw->drawable);
|
||||||
XMapRaised(globalconf.display, sw->window);
|
xutil_map_raised(globalconf.connection, sw->window);
|
||||||
mouse_resizebar_draw(ctx, style, sw, geometry, c->border);
|
mouse_resizebar_draw(ctx, style, sw, geometry, c->border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p_delete(&grab_pointer_r);
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
XMaskEvent(globalconf.display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
/* TODO: need a review
|
||||||
switch (ev.type)
|
*
|
||||||
|
* XMaskEvent allows to retrieve only specified events from
|
||||||
|
* the queue and requeue the other events...
|
||||||
|
*/
|
||||||
|
while((ev = xcb_poll_for_event(globalconf.connection)))
|
||||||
{
|
{
|
||||||
case ButtonRelease:
|
switch((ev->response_type & 0x7f))
|
||||||
XUngrabPointer(globalconf.display, CurrentTime);
|
|
||||||
if(sw)
|
|
||||||
{
|
{
|
||||||
draw_context_delete(&ctx);
|
case XCB_BUTTON_RELEASE:
|
||||||
simplewindow_delete(&sw);
|
xcb_ungrab_pointer(globalconf.connection, XCB_CURRENT_TIME);
|
||||||
}
|
|
||||||
return;
|
|
||||||
case ConfigureRequest:
|
|
||||||
event_handle_configurerequest(&ev);
|
|
||||||
break;
|
|
||||||
case Expose:
|
|
||||||
event_handle_expose(&ev);
|
|
||||||
break;
|
|
||||||
case MapRequest:
|
|
||||||
event_handle_maprequest(&ev);
|
|
||||||
break;
|
|
||||||
case EnterNotify:
|
|
||||||
event_handle_enternotify(&ev);
|
|
||||||
break;
|
|
||||||
case MotionNotify:
|
|
||||||
if(c->isfloating || layout->arrange == layout_floating)
|
|
||||||
{
|
|
||||||
geometry.x = ocx + (ev.xmotion.x - x);
|
|
||||||
geometry.y = ocy + (ev.xmotion.y - y);
|
|
||||||
|
|
||||||
geometry = mouse_snapclient(c, geometry);
|
|
||||||
|
|
||||||
c->ismoving = True;
|
|
||||||
client_resize(c, geometry, False);
|
|
||||||
c->ismoving = False;
|
|
||||||
if(sw)
|
if(sw)
|
||||||
mouse_resizebar_draw(ctx, style, sw, c->geometry, c->border);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
XQueryPointer(globalconf.display,
|
|
||||||
RootWindow(globalconf.display, c->phys_screen),
|
|
||||||
&dummy, &child, &x, &y, &di, &di, &dui);
|
|
||||||
if((newscreen = screen_get_bycoord(globalconf.screens_info, c->screen, x, y)) != c->screen)
|
|
||||||
{
|
{
|
||||||
move_client_to_screen(c, newscreen, True);
|
draw_context_delete(&ctx);
|
||||||
globalconf.screens[c->screen].need_arrange = True;
|
simplewindow_delete(&sw);
|
||||||
if(layout_get_current(newscreen)->arrange != layout_floating)
|
|
||||||
globalconf.screens[newscreen].need_arrange = True;
|
|
||||||
layout_refresh();
|
|
||||||
}
|
}
|
||||||
if((target = client_get_bywin(globalconf.clients, child))
|
|
||||||
&& target != c && !target->isfloating)
|
p_delete(&query_pointer_r);
|
||||||
|
p_delete(&ev);
|
||||||
|
return;
|
||||||
|
case XCB_MOTION_NOTIFY:
|
||||||
|
if(ignore_motion_events)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(c->isfloating || layout->arrange == layout_floating)
|
||||||
{
|
{
|
||||||
client_list_swap(&globalconf.clients, c, target);
|
ev_motion = (xcb_motion_notify_event_t *) ev;
|
||||||
globalconf.screens[c->screen].need_arrange = True;
|
|
||||||
layout_refresh();
|
geometry.x = ocx + (ev_motion->event_x - query_pointer_r->root_x);
|
||||||
|
geometry.y = ocy + (ev_motion->event_y - query_pointer_r->root_y);
|
||||||
|
|
||||||
|
geometry = mouse_snapclient(c, geometry);
|
||||||
|
|
||||||
|
if(sw)
|
||||||
|
mouse_resizebar_draw(ctx, style, sw, c->geometry, c->border);
|
||||||
|
|
||||||
|
p_delete(&ev);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mquery_pointer_r = xcb_query_pointer_reply(globalconf.connection,
|
||||||
|
xcb_query_pointer_unchecked(globalconf.connection,
|
||||||
|
root_window(globalconf.connection, c->phys_screen)),
|
||||||
|
NULL);
|
||||||
|
if((newscreen = screen_get_bycoord(globalconf.screens_info, c->screen,
|
||||||
|
mquery_pointer_r->root_x,
|
||||||
|
mquery_pointer_r->root_y)) != c->screen)
|
||||||
|
{
|
||||||
|
move_client_to_screen(c, newscreen, true);
|
||||||
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
|
globalconf.screens[newscreen].need_arrange = true;
|
||||||
|
layout_refresh();
|
||||||
|
}
|
||||||
|
if((target = client_get_bywin(globalconf.clients, mquery_pointer_r->child))
|
||||||
|
&& target != c && !target->isfloating)
|
||||||
|
{
|
||||||
|
client_list_swap(&globalconf.clients, c, target);
|
||||||
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
|
layout_refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
p_delete(&mquery_pointer_r);
|
||||||
|
}
|
||||||
|
ignore_motion_events = true;
|
||||||
|
break;
|
||||||
|
case XCB_CONFIGURE_REQUEST:
|
||||||
|
case XCB_EXPOSE:
|
||||||
|
case XCB_MAP_REQUEST:
|
||||||
|
case XCB_ENTER_NOTIFY:
|
||||||
|
/* Handle errors */
|
||||||
|
case 0:
|
||||||
|
xcb_handle_event(globalconf.evenths, ev);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
while(XCheckMaskEvent(globalconf.display, PointerMotionMask, &ev));
|
|
||||||
break;
|
p_delete(&ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p_delete(&query_pointer_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resize the focused window with the mouse.
|
/** Resize the focused window with the mouse.
|
||||||
|
@ -253,7 +279,9 @@ void
|
||||||
uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
|
uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int ocx = 0, ocy = 0, n;
|
int ocx = 0, ocy = 0, n;
|
||||||
XEvent ev;
|
xcb_generic_event_t *ev = NULL;
|
||||||
|
xcb_motion_notify_event_t *ev_motion = NULL;
|
||||||
|
bool ignore_motion_events = false;
|
||||||
Client *c = globalconf.focus->client;
|
Client *c = globalconf.focus->client;
|
||||||
Tag **curtags = tags_get_current(screen);
|
Tag **curtags = tags_get_current(screen);
|
||||||
Layout *layout = curtags[0]->layout;
|
Layout *layout = curtags[0]->layout;
|
||||||
|
@ -262,6 +290,8 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
|
||||||
SimpleWindow *sw = NULL;
|
SimpleWindow *sw = NULL;
|
||||||
DrawCtx *ctx = NULL;
|
DrawCtx *ctx = NULL;
|
||||||
style_t style;
|
style_t style;
|
||||||
|
xcb_grab_pointer_cookie_t grab_pointer_c;
|
||||||
|
xcb_grab_pointer_reply_t *grab_pointer_r = NULL;
|
||||||
|
|
||||||
/* only handle floating and tiled layouts */
|
/* only handle floating and tiled layouts */
|
||||||
if(!c || c->isfixed)
|
if(!c || c->isfixed)
|
||||||
|
@ -273,19 +303,20 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
ocx = c->geometry.x;
|
ocx = c->geometry.x;
|
||||||
ocy = c->geometry.y;
|
ocy = c->geometry.y;
|
||||||
c->ismax = False;
|
c->ismax = false;
|
||||||
|
|
||||||
sw = simplewindow_new(globalconf.display, c->phys_screen, 0, 0,
|
sw = simplewindow_new(globalconf.connection, c->phys_screen, 0, 0,
|
||||||
draw_textwidth(globalconf.display,
|
draw_textwidth(globalconf.connection,
|
||||||
|
globalconf.default_screen,
|
||||||
globalconf.screens[c->screen].styles.focus.font,
|
globalconf.screens[c->screen].styles.focus.font,
|
||||||
"0000x0000+0000+0000") + style.font->height,
|
"0000x0000+0000+0000") + style.font->height,
|
||||||
1.5 * style.font->height, 0);
|
1.5 * style.font->height, 0);
|
||||||
|
|
||||||
ctx = draw_context_new(globalconf.display, sw->phys_screen,
|
ctx = draw_context_new(globalconf.connection, sw->phys_screen,
|
||||||
sw->geometry.width, sw->geometry.height,
|
sw->geometry.width, sw->geometry.height,
|
||||||
sw->drawable);
|
sw->drawable);
|
||||||
XMapRaised(globalconf.display, sw->window);
|
xutil_map_raised(globalconf.connection, sw->window);
|
||||||
mouse_resizebar_draw(ctx, style, sw, c->geometry, c->border);
|
mouse_resizebar_draw(ctx, style, sw, geometry, c->border);
|
||||||
}
|
}
|
||||||
else if (layout->arrange == layout_tile || layout->arrange == layout_tileleft
|
else if (layout->arrange == layout_tile || layout->arrange == layout_tileleft
|
||||||
|| layout->arrange == layout_tilebottom || layout->arrange == layout_tiletop)
|
|| layout->arrange == layout_tilebottom || layout->arrange == layout_tiletop)
|
||||||
|
@ -306,84 +337,104 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(XGrabPointer(globalconf.display,
|
grab_pointer_c = xcb_grab_pointer(globalconf.connection, false,
|
||||||
RootWindow(globalconf.display, c->phys_screen),
|
root_window(globalconf.connection, c->phys_screen),
|
||||||
False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
MOUSEMASK, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC,
|
||||||
RootWindow(globalconf.display, c->phys_screen),
|
root_window(globalconf.connection, c->phys_screen),
|
||||||
globalconf.cursor[CurResize], CurrentTime) != GrabSuccess)
|
globalconf.cursor[CurResize], XCB_CURRENT_TIME);
|
||||||
|
|
||||||
|
if((grab_pointer_r = xcb_grab_pointer_reply(globalconf.connection,
|
||||||
|
grab_pointer_c, NULL)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
p_delete(&grab_pointer_r);
|
||||||
|
|
||||||
if(curtags[0]->layout->arrange == layout_tileleft)
|
if(curtags[0]->layout->arrange == layout_tileleft)
|
||||||
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0, 0,
|
xcb_warp_pointer(globalconf.connection, XCB_NONE, c->win, 0, 0,
|
||||||
c->geometry.height + c->border - 1);
|
0, 0, 0, c->geometry.height + c->border - 1);
|
||||||
else if(curtags[0]->layout->arrange == layout_tilebottom)
|
else if(curtags[0]->layout->arrange == layout_tilebottom)
|
||||||
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0,
|
xcb_warp_pointer(globalconf.connection, XCB_NONE, c->win,
|
||||||
c->geometry.width + c->border - 1, c->geometry.height + c->border - 1);
|
0, 0, 0, 0, c->geometry.width + c->border - 1,
|
||||||
|
c->geometry.height + c->border - 1);
|
||||||
else if(curtags[0]->layout->arrange == layout_tiletop)
|
else if(curtags[0]->layout->arrange == layout_tiletop)
|
||||||
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0,
|
xcb_warp_pointer(globalconf.connection, XCB_NONE, c->win, 0, 0,
|
||||||
c->geometry.width + c->border - 1, 0);
|
0, 0, c->geometry.width + c->border - 1, 0);
|
||||||
else
|
else
|
||||||
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0,
|
xcb_warp_pointer(globalconf.connection, XCB_NONE, c->win, 0, 0,
|
||||||
c->geometry.width + c->border - 1, c->geometry.height + c->border - 1);
|
0, 0, c->geometry.width + c->border - 1,
|
||||||
|
c->geometry.height + c->border - 1);
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
XMaskEvent(globalconf.display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
/* TODO: need a review
|
||||||
switch (ev.type)
|
*
|
||||||
|
* XMaskEvent allows to retrieve only specified events from
|
||||||
|
* the queue and requeue the other events...
|
||||||
|
*/
|
||||||
|
while((ev = xcb_poll_for_event(globalconf.connection)))
|
||||||
{
|
{
|
||||||
case ButtonRelease:
|
switch((ev->response_type & 0x7f))
|
||||||
XUngrabPointer(globalconf.display, CurrentTime);
|
|
||||||
if(sw)
|
|
||||||
{
|
{
|
||||||
draw_context_delete(&ctx);
|
case XCB_BUTTON_RELEASE:
|
||||||
simplewindow_delete(&sw);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
case ConfigureRequest:
|
|
||||||
event_handle_configurerequest(&ev);
|
|
||||||
break;
|
|
||||||
case Expose:
|
|
||||||
event_handle_expose(&ev);
|
|
||||||
break;
|
|
||||||
case MapRequest:
|
|
||||||
event_handle_maprequest(&ev);
|
|
||||||
break;
|
|
||||||
case MotionNotify:
|
|
||||||
if(layout->arrange == layout_floating || c->isfloating)
|
|
||||||
{
|
|
||||||
if((geometry.width = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0)
|
|
||||||
geometry.width = 1;
|
|
||||||
if((geometry.height = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
|
|
||||||
geometry.height = 1;
|
|
||||||
geometry.x = c->geometry.x;
|
|
||||||
geometry.y = c->geometry.y;
|
|
||||||
client_resize(c, geometry, True);
|
|
||||||
if(sw)
|
if(sw)
|
||||||
mouse_resizebar_draw(ctx, style, sw, c->geometry, c->border);
|
|
||||||
}
|
|
||||||
else if(layout->arrange == layout_tile || layout->arrange == layout_tileleft
|
|
||||||
|| layout->arrange == layout_tiletop || layout->arrange == layout_tilebottom)
|
|
||||||
{
|
|
||||||
if(layout->arrange == layout_tile)
|
|
||||||
mwfact = (double) (ev.xmotion.x - area.x) / area.width;
|
|
||||||
else if(curtags[0]->layout->arrange == layout_tileleft)
|
|
||||||
mwfact = 1 - (double) (ev.xmotion.x - area.x) / area.width;
|
|
||||||
else if(curtags[0]->layout->arrange == layout_tilebottom)
|
|
||||||
mwfact = (double) (ev.xmotion.y - area.y) / area.height;
|
|
||||||
else
|
|
||||||
mwfact = 1 - (double) (ev.xmotion.y - area.y) / area.height;
|
|
||||||
mwfact = MAX(globalconf.screens[screen].mwfact_lower_limit,
|
|
||||||
MIN(globalconf.screens[screen].mwfact_upper_limit, mwfact));
|
|
||||||
if(fabs(curtags[0]->mwfact - mwfact) >= 0.01)
|
|
||||||
{
|
{
|
||||||
curtags[0]->mwfact = mwfact;
|
draw_context_delete(&ctx);
|
||||||
globalconf.screens[screen].need_arrange = True;
|
simplewindow_delete(&sw);
|
||||||
layout_refresh();
|
|
||||||
while(XCheckMaskEvent(globalconf.display, PointerMotionMask, &ev));
|
|
||||||
}
|
}
|
||||||
|
xcb_ungrab_pointer(globalconf.connection, XCB_CURRENT_TIME);
|
||||||
|
p_delete(&ev);
|
||||||
|
return;
|
||||||
|
case XCB_MOTION_NOTIFY:
|
||||||
|
if(ignore_motion_events)
|
||||||
|
break;
|
||||||
|
|
||||||
|
ev_motion = (xcb_motion_notify_event_t *) ev;
|
||||||
|
|
||||||
|
if(layout->arrange == layout_floating || c->isfloating)
|
||||||
|
{
|
||||||
|
if((geometry.width = ev_motion->event_x - ocx - 2 * c->border + 1) <= 0)
|
||||||
|
geometry.width = 1;
|
||||||
|
if((geometry.height = ev_motion->event_y - ocy - 2 * c->border + 1) <= 0)
|
||||||
|
geometry.height = 1;
|
||||||
|
geometry.x = c->geometry.x;
|
||||||
|
geometry.y = c->geometry.y;
|
||||||
|
client_resize(c, geometry, true);
|
||||||
|
if(sw)
|
||||||
|
mouse_resizebar_draw(ctx, style, sw, c->geometry, c->border);
|
||||||
|
}
|
||||||
|
else if(layout->arrange == layout_tile || layout->arrange == layout_tileleft
|
||||||
|
|| layout->arrange == layout_tiletop || layout->arrange == layout_tilebottom)
|
||||||
|
{
|
||||||
|
if(layout->arrange == layout_tile)
|
||||||
|
mwfact = (double) (ev_motion->event_x - area.x) / area.width;
|
||||||
|
else if(curtags[0]->layout->arrange == layout_tileleft)
|
||||||
|
mwfact = 1 - (double) (ev_motion->event_x - area.x) / area.width;
|
||||||
|
else if(curtags[0]->layout->arrange == layout_tilebottom)
|
||||||
|
mwfact = (double) (ev_motion->event_y - area.y) / area.height;
|
||||||
|
else
|
||||||
|
mwfact = 1 - (double) (ev_motion->event_y - area.y) / area.height;
|
||||||
|
mwfact = MAX(globalconf.screens[screen].mwfact_lower_limit,
|
||||||
|
MIN(globalconf.screens[screen].mwfact_upper_limit, mwfact));
|
||||||
|
if(fabs(curtags[0]->mwfact - mwfact) >= 0.01)
|
||||||
|
{
|
||||||
|
curtags[0]->mwfact = mwfact;
|
||||||
|
globalconf.screens[screen].need_arrange = true;
|
||||||
|
layout_refresh();
|
||||||
|
ignore_motion_events = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case XCB_CONFIGURE_REQUEST:
|
||||||
|
case XCB_EXPOSE:
|
||||||
|
case XCB_MAP_REQUEST:
|
||||||
|
/* Handle errors */
|
||||||
|
case 0:
|
||||||
|
xcb_handle_event(globalconf.evenths, ev);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
p_delete(&ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p_delete(&curtags);
|
p_delete(&curtags);
|
||||||
|
|
18
placement.c
18
placement.c
|
@ -68,7 +68,7 @@ placement_smart(Client *c)
|
||||||
Client *client;
|
Client *client;
|
||||||
area_t newgeometry = { 0, 0, 0, 0, NULL, NULL };
|
area_t newgeometry = { 0, 0, 0, 0, NULL, NULL };
|
||||||
area_t *screen_geometry, *arealist = NULL, *r;
|
area_t *screen_geometry, *arealist = NULL, *r;
|
||||||
Bool found = False;
|
bool found = false;
|
||||||
Layout *layout;
|
Layout *layout;
|
||||||
|
|
||||||
screen_geometry = p_new(area_t, 1);
|
screen_geometry = p_new(area_t, 1);
|
||||||
|
@ -101,7 +101,7 @@ placement_smart(Client *c)
|
||||||
if(r->width >= c->f_geometry.width && r->height >= c->f_geometry.height
|
if(r->width >= c->f_geometry.width && r->height >= c->f_geometry.height
|
||||||
&& r->width * r->height > newgeometry.width * newgeometry.height)
|
&& r->width * r->height > newgeometry.width * newgeometry.height)
|
||||||
{
|
{
|
||||||
found = True;
|
found = true;
|
||||||
newgeometry = *r;
|
newgeometry = *r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,16 +128,16 @@ placement_smart(Client *c)
|
||||||
area_t
|
area_t
|
||||||
placement_under_mouse(Client *c)
|
placement_under_mouse(Client *c)
|
||||||
{
|
{
|
||||||
Window dummy;
|
xcb_query_pointer_reply_t *xqp;
|
||||||
unsigned int m;
|
|
||||||
int x, y, d;
|
|
||||||
area_t finalgeometry = c->f_geometry;
|
area_t finalgeometry = c->f_geometry;
|
||||||
|
|
||||||
if(XQueryPointer(globalconf.display, RootWindow(globalconf.display, c->phys_screen),
|
if((xqp = xcb_query_pointer_reply(globalconf.connection,
|
||||||
&dummy, &dummy, &x, &y, &d, &d, &m))
|
xcb_query_pointer(globalconf.connection,
|
||||||
|
root_window(globalconf.connection, c->phys_screen)),
|
||||||
|
NULL)) != NULL)
|
||||||
{
|
{
|
||||||
finalgeometry.x = x - c->f_geometry.width / 2;
|
finalgeometry.x = xqp->root_x - c->f_geometry.width / 2;
|
||||||
finalgeometry.y = y - c->f_geometry.height / 2;
|
finalgeometry.y = xqp->root_y - c->f_geometry.height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
finalgeometry = titlebar_geometry_add(&c->titlebar, finalgeometry);
|
finalgeometry = titlebar_geometry_add(&c->titlebar, finalgeometry);
|
||||||
|
|
38
rules.c
38
rules.c
|
@ -19,8 +19,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
|
|
||||||
#include "rules.h"
|
#include "rules.h"
|
||||||
#include "common/xutil.h"
|
#include "common/xutil.h"
|
||||||
|
|
||||||
|
@ -43,59 +41,63 @@ rules_compile_regex(char *val)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static bool
|
||||||
client_match_rule(Client *c, Rule *r)
|
client_match_rule(Client *c, Rule *r)
|
||||||
{
|
{
|
||||||
char *prop, buf[512];
|
char *prop, buf[512];
|
||||||
regmatch_t tmp;
|
regmatch_t tmp;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
XClassHint ch = { 0, 0 };
|
class_hint_t *ch = NULL;
|
||||||
Bool ret = False;
|
bool ret = false;
|
||||||
|
|
||||||
if(r->prop_r)
|
if(r->prop_r)
|
||||||
{
|
{
|
||||||
/* first try to match on name */
|
/* first try to match on name */
|
||||||
XGetClassHint(globalconf.display, c->win, &ch);
|
ch = x_get_class_hint(globalconf.connection, c->win);
|
||||||
|
if (!ch)
|
||||||
|
return false;
|
||||||
|
|
||||||
len = a_strlen(ch.res_class) + a_strlen(ch.res_name) + a_strlen(c->name);
|
len = a_strlen(ch->res_class) + a_strlen(ch->res_name) + a_strlen(c->name);
|
||||||
prop = p_new(char, len + 3);
|
prop = p_new(char, len + 3);
|
||||||
|
|
||||||
/* rule matching */
|
/* rule matching */
|
||||||
snprintf(prop, len + 3, "%s:%s:%s",
|
snprintf(prop, len + 3, "%s:%s:%s",
|
||||||
ch.res_class ? ch.res_class : "", ch.res_name ? ch.res_name : "", c->name);
|
ch->res_class ? ch->res_class : "", ch->res_name ? ch->res_name : "", c->name);
|
||||||
|
|
||||||
ret = !regexec(r->prop_r, prop, 1, &tmp, 0);
|
ret = !regexec(r->prop_r, prop, 1, &tmp, 0);
|
||||||
|
|
||||||
p_delete(&prop);
|
p_delete(&prop);
|
||||||
|
|
||||||
if(ch.res_class)
|
if(ch->res_class)
|
||||||
XFree(ch.res_class);
|
p_delete(&ch->res_class);
|
||||||
if(ch.res_name)
|
if(ch->res_name)
|
||||||
XFree(ch.res_name);
|
p_delete(&ch->res_name);
|
||||||
|
|
||||||
|
p_delete(&ch);
|
||||||
|
|
||||||
if(ret)
|
if(ret)
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(r->xprop
|
if(r->xprop
|
||||||
&& r->xpropval_r
|
&& r->xpropval_r
|
||||||
&& xgettextprop(globalconf.display, c->win,
|
&& xgettextprop(globalconf.connection, c->win,
|
||||||
XInternAtom(globalconf.display, r->xprop, False),
|
x_intern_atom(globalconf.connection, r->xprop),
|
||||||
buf, ssizeof(buf)))
|
buf, ssizeof(buf)))
|
||||||
ret = !regexec(r->xpropval_r, buf, 1, &tmp, 0);
|
ret = !regexec(r->xpropval_r, buf, 1, &tmp, 0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
bool
|
||||||
tag_match_rule(Tag *t, Rule *r)
|
tag_match_rule(Tag *t, Rule *r)
|
||||||
{
|
{
|
||||||
regmatch_t tmp;
|
regmatch_t tmp;
|
||||||
|
|
||||||
if(r->tags_r && !regexec(r->tags_r, t->name, 1, &tmp, 0))
|
if(r->tags_r && !regexec(r->tags_r, t->name, 1, &tmp, 0))
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rule *
|
Rule *
|
||||||
|
|
2
rules.h
2
rules.h
|
@ -27,7 +27,7 @@
|
||||||
#define RULE_NOSCREEN -1
|
#define RULE_NOSCREEN -1
|
||||||
|
|
||||||
regex_t * rules_compile_regex(char *);
|
regex_t * rules_compile_regex(char *);
|
||||||
Bool tag_match_rule(Tag *, Rule *);
|
bool tag_match_rule(Tag *, Rule *);
|
||||||
Fuzzy rules_get_fuzzy_from_str(const char *);
|
Fuzzy rules_get_fuzzy_from_str(const char *);
|
||||||
Rule * rule_matching_client(Client *);
|
Rule * rule_matching_client(Client *);
|
||||||
|
|
||||||
|
|
48
screen.c
48
screen.c
|
@ -19,6 +19,11 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
|
@ -79,9 +84,10 @@ get_display_area(int screen, Statusbar *statusbar, Padding *padding)
|
||||||
{
|
{
|
||||||
area_t area = { 0, 0, 0, 0, NULL, NULL };
|
area_t area = { 0, 0, 0, 0, NULL, NULL };
|
||||||
Statusbar *sb;
|
Statusbar *sb;
|
||||||
|
xcb_screen_t *s = xcb_aux_get_screen(globalconf.connection, screen);
|
||||||
|
|
||||||
area.width = DisplayWidth(globalconf.display, screen);
|
area.width = s->width_in_pixels;
|
||||||
area.height = DisplayHeight(globalconf.display, screen);
|
area.height = s->height_in_pixels;
|
||||||
|
|
||||||
for(sb = statusbar; sb; sb = sb->next)
|
for(sb = statusbar; sb; sb = sb->next)
|
||||||
{
|
{
|
||||||
|
@ -109,18 +115,18 @@ int
|
||||||
screen_virttophys(int screen)
|
screen_virttophys(int screen)
|
||||||
{
|
{
|
||||||
if(globalconf.screens_info->xinerama_is_active)
|
if(globalconf.screens_info->xinerama_is_active)
|
||||||
return DefaultScreen(globalconf.display);
|
return globalconf.default_screen;
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Move a client to a virtual screen
|
/** Move a client to a virtual screen
|
||||||
* \param c the client
|
* \param c the client
|
||||||
* \param new_screen The destinatiuon screen
|
* \param new_screen The destinatiuon screen
|
||||||
* \param doresize set to True if we also move the client to the new x and
|
* \param doresize set to true if we also move the client to the new x and
|
||||||
* y of the new screen
|
* y of the new screen
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
move_client_to_screen(Client *c, int new_screen, Bool doresize)
|
move_client_to_screen(Client *c, int new_screen, bool doresize)
|
||||||
{
|
{
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
int old_screen = c->screen;
|
int old_screen = c->screen;
|
||||||
|
@ -189,17 +195,17 @@ move_client_to_screen(Client *c, int new_screen, Bool doresize)
|
||||||
if(c->m_geometry.y + c->m_geometry.height >= to.y + to.height)
|
if(c->m_geometry.y + c->m_geometry.height >= to.y + to.height)
|
||||||
c->m_geometry.y = to.y + to.height - c->m_geometry.height - 2 * c->border;
|
c->m_geometry.y = to.y + to.height - c->m_geometry.height - 2 * c->border;
|
||||||
|
|
||||||
client_resize(c, new_geometry, False);
|
client_resize(c, new_geometry, false);
|
||||||
}
|
}
|
||||||
/* if floating, move to this new coords */
|
/* if floating, move to this new coords */
|
||||||
else if(c->isfloating)
|
else if(c->isfloating)
|
||||||
client_resize(c, new_f_geometry, False);
|
client_resize(c, new_f_geometry, false);
|
||||||
/* otherwise just register them */
|
/* otherwise just register them */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c->f_geometry = new_f_geometry;
|
c->f_geometry = new_f_geometry;
|
||||||
globalconf.screens[old_screen].need_arrange = True;
|
globalconf.screens[old_screen].need_arrange = true;
|
||||||
globalconf.screens[c->screen].need_arrange = True;
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,19 +216,21 @@ move_client_to_screen(Client *c, int new_screen, Bool doresize)
|
||||||
static void
|
static void
|
||||||
move_mouse_pointer_to_screen(int phys_screen)
|
move_mouse_pointer_to_screen(int phys_screen)
|
||||||
{
|
{
|
||||||
|
xcb_screen_t *s = xcb_aux_get_screen(globalconf.connection, phys_screen);
|
||||||
|
|
||||||
if(globalconf.screens_info->xinerama_is_active)
|
if(globalconf.screens_info->xinerama_is_active)
|
||||||
{
|
{
|
||||||
area_t area = screen_get_area(phys_screen, NULL, NULL);
|
area_t area = screen_get_area(phys_screen, NULL, NULL);
|
||||||
XWarpPointer(globalconf.display,
|
xcb_warp_pointer(globalconf.connection,
|
||||||
None,
|
XCB_NONE,
|
||||||
DefaultRootWindow(globalconf.display),
|
s->root,
|
||||||
0, 0, 0, 0, area.x, area.y);
|
0, 0, 0, 0, area.x, area.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
XWarpPointer(globalconf.display,
|
xcb_warp_pointer(globalconf.connection,
|
||||||
None,
|
XCB_NONE,
|
||||||
RootWindow(globalconf.display, phys_screen),
|
root_window(globalconf.connection, phys_screen),
|
||||||
0, 0, 0, 0, 0, 0);
|
0, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,7 +255,7 @@ uicb_screen_focus(int screen, char *arg)
|
||||||
if (new_screen > (globalconf.screens_info->nscreen - 1))
|
if (new_screen > (globalconf.screens_info->nscreen - 1))
|
||||||
new_screen = 0;
|
new_screen = 0;
|
||||||
|
|
||||||
client_focus(NULL, new_screen, True);
|
client_focus(NULL, new_screen, true);
|
||||||
|
|
||||||
move_mouse_pointer_to_screen(new_screen);
|
move_mouse_pointer_to_screen(new_screen);
|
||||||
}
|
}
|
||||||
|
@ -278,8 +286,8 @@ uicb_client_movetoscreen(int screen __attribute__ ((unused)), char *arg)
|
||||||
new_screen = globalconf.screens_info->nscreen - 1;
|
new_screen = globalconf.screens_info->nscreen - 1;
|
||||||
|
|
||||||
prev_screen = sel->screen;
|
prev_screen = sel->screen;
|
||||||
move_client_to_screen(sel, new_screen, True);
|
move_client_to_screen(sel, new_screen, true);
|
||||||
move_mouse_pointer_to_screen(new_screen);
|
move_mouse_pointer_to_screen(new_screen);
|
||||||
client_focus(sel, sel->screen, True);
|
client_focus(sel, sel->screen, true);
|
||||||
}
|
}
|
||||||
// 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
screen.h
2
screen.h
|
@ -27,7 +27,7 @@
|
||||||
area_t screen_get_area(int, Statusbar *, Padding *);
|
area_t screen_get_area(int, Statusbar *, Padding *);
|
||||||
area_t get_display_area(int, Statusbar *, Padding *);
|
area_t get_display_area(int, Statusbar *, Padding *);
|
||||||
int screen_virttophys(int);
|
int screen_virttophys(int);
|
||||||
void move_client_to_screen(Client *, int, Bool);
|
void move_client_to_screen(Client *, int, bool);
|
||||||
|
|
||||||
Uicb uicb_screen_focus;
|
Uicb uicb_screen_focus;
|
||||||
Uicb uicb_client_movetoscreen;
|
Uicb uicb_client_movetoscreen;
|
||||||
|
|
42
statusbar.c
42
statusbar.c
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
@ -38,11 +40,11 @@ statusbar_position_update(Statusbar *statusbar)
|
||||||
|
|
||||||
if(statusbar->position == Off)
|
if(statusbar->position == Off)
|
||||||
{
|
{
|
||||||
XUnmapWindow(globalconf.display, statusbar->sw->window);
|
xcb_unmap_window(globalconf.connection, statusbar->sw->window);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XMapRaised(globalconf.display, statusbar->sw->window);
|
xutil_map_raised(globalconf.connection, statusbar->sw->window);
|
||||||
|
|
||||||
/* Top and Bottom Statusbar have prio */
|
/* Top and Bottom Statusbar have prio */
|
||||||
if(statusbar->position == Top || statusbar->position == Bottom)
|
if(statusbar->position == Top || statusbar->position == Bottom)
|
||||||
|
@ -113,13 +115,13 @@ statusbar_draw(Statusbar *statusbar)
|
||||||
|
|
||||||
rectangle.width = statusbar->width;
|
rectangle.width = statusbar->width;
|
||||||
rectangle.height = statusbar->height;
|
rectangle.height = statusbar->height;
|
||||||
draw_rectangle(statusbar->ctx, rectangle, 1.0, True,
|
draw_rectangle(statusbar->ctx, rectangle, 1.0, true,
|
||||||
globalconf.screens[statusbar->screen].styles.normal.bg);
|
globalconf.screens[statusbar->screen].styles.normal.bg);
|
||||||
|
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||||
if (widget->alignment == AlignLeft)
|
if (widget->alignment == AlignLeft)
|
||||||
{
|
{
|
||||||
widget->cache.needs_update = False;
|
widget->cache.needs_update = false;
|
||||||
left += widget->draw(widget, statusbar->ctx, left, (left + right));
|
left += widget->draw(widget, statusbar->ctx, left, (left + right));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,14 +131,14 @@ statusbar_draw(Statusbar *statusbar)
|
||||||
widget = widget_list_prev(&statusbar->widgets, widget))
|
widget = widget_list_prev(&statusbar->widgets, widget))
|
||||||
if (widget->alignment == AlignRight)
|
if (widget->alignment == AlignRight)
|
||||||
{
|
{
|
||||||
widget->cache.needs_update = False;
|
widget->cache.needs_update = false;
|
||||||
right += widget->draw(widget, statusbar->ctx, right, (left + right));
|
right += widget->draw(widget, statusbar->ctx, right, (left + right));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||||
if (widget->alignment == AlignFlex)
|
if (widget->alignment == AlignFlex)
|
||||||
{
|
{
|
||||||
widget->cache.needs_update = False;
|
widget->cache.needs_update = false;
|
||||||
left += widget->draw(widget, statusbar->ctx, left, (left + right));
|
left += widget->draw(widget, statusbar->ctx, left, (left + right));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,11 +183,12 @@ void
|
||||||
statusbar_init(Statusbar *statusbar)
|
statusbar_init(Statusbar *statusbar)
|
||||||
{
|
{
|
||||||
Statusbar *sb;
|
Statusbar *sb;
|
||||||
Drawable dw;
|
xcb_drawable_t dw;
|
||||||
|
xcb_screen_t *s = NULL;
|
||||||
int phys_screen = screen_virttophys(statusbar->screen);
|
int phys_screen = screen_virttophys(statusbar->screen);
|
||||||
area_t area = screen_get_area(statusbar->screen,
|
area_t area = screen_get_area(statusbar->screen,
|
||||||
globalconf.screens[statusbar->screen].statusbar,
|
globalconf.screens[statusbar->screen].statusbar,
|
||||||
&globalconf.screens[statusbar->screen].padding);
|
&globalconf.screens[statusbar->screen].padding);
|
||||||
|
|
||||||
statusbar->phys_screen = phys_screen;
|
statusbar->phys_screen = phys_screen;
|
||||||
|
|
||||||
|
@ -214,12 +217,12 @@ statusbar_init(Statusbar *statusbar)
|
||||||
case Right:
|
case Right:
|
||||||
case Left:
|
case Left:
|
||||||
statusbar->sw =
|
statusbar->sw =
|
||||||
simplewindow_new(globalconf.display, phys_screen, 0, 0,
|
simplewindow_new(globalconf.connection, phys_screen, 0, 0,
|
||||||
statusbar->height, statusbar->width, 0);
|
statusbar->height, statusbar->width, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
statusbar->sw =
|
statusbar->sw =
|
||||||
simplewindow_new(globalconf.display, phys_screen, 0, 0,
|
simplewindow_new(globalconf.connection, phys_screen, 0, 0,
|
||||||
statusbar->width, statusbar->height, 0);
|
statusbar->width, statusbar->height, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -234,19 +237,22 @@ statusbar_init(Statusbar *statusbar)
|
||||||
return;
|
return;
|
||||||
case Right:
|
case Right:
|
||||||
case Left:
|
case Left:
|
||||||
|
s = xcb_aux_get_screen(globalconf.connection, phys_screen);
|
||||||
|
|
||||||
/* we need a new pixmap this way [ ] to render */
|
/* we need a new pixmap this way [ ] to render */
|
||||||
dw = XCreatePixmap(globalconf.display,
|
dw = xcb_generate_id(globalconf.connection);
|
||||||
RootWindow(globalconf.display, phys_screen),
|
xcb_create_pixmap(globalconf.connection,
|
||||||
statusbar->width, statusbar->height,
|
s->root_depth, dw,
|
||||||
DefaultDepth(globalconf.display, phys_screen));
|
root_window(globalconf.connection, phys_screen),
|
||||||
statusbar->ctx = draw_context_new(globalconf.display,
|
statusbar->width, statusbar->height);
|
||||||
|
statusbar->ctx = draw_context_new(globalconf.connection,
|
||||||
phys_screen,
|
phys_screen,
|
||||||
statusbar->width,
|
statusbar->width,
|
||||||
statusbar->height,
|
statusbar->height,
|
||||||
dw);
|
dw);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
statusbar->ctx = draw_context_new(globalconf.display,
|
statusbar->ctx = draw_context_new(globalconf.connection,
|
||||||
phys_screen,
|
phys_screen,
|
||||||
statusbar->width,
|
statusbar->width,
|
||||||
statusbar->height,
|
statusbar->height,
|
||||||
|
@ -297,7 +303,7 @@ statusbar_toggle(Statusbar *statusbar)
|
||||||
else
|
else
|
||||||
statusbar->position = Off;
|
statusbar->position = Off;
|
||||||
|
|
||||||
globalconf.screens[statusbar->screen].need_arrange = True;
|
globalconf.screens[statusbar->screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Toggle the statusbar on or off.
|
/** Toggle the statusbar on or off.
|
||||||
|
|
94
structs.h
94
structs.h
|
@ -22,6 +22,8 @@
|
||||||
#ifndef AWESOME_STRUCTS_H
|
#ifndef AWESOME_STRUCTS_H
|
||||||
#define AWESOME_STRUCTS_H
|
#define AWESOME_STRUCTS_H
|
||||||
|
|
||||||
|
#include <xcb/xcb_event.h>
|
||||||
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "common/draw.h"
|
#include "common/draw.h"
|
||||||
|
@ -42,8 +44,8 @@ typedef enum
|
||||||
/** Rules for floating rule */
|
/** Rules for floating rule */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
No = False,
|
No = false,
|
||||||
Yes = True,
|
Yes = true,
|
||||||
Maybe
|
Maybe
|
||||||
} Fuzzy;
|
} Fuzzy;
|
||||||
|
|
||||||
|
@ -91,8 +93,8 @@ typedef struct Key Key;
|
||||||
struct Key
|
struct Key
|
||||||
{
|
{
|
||||||
unsigned long mod;
|
unsigned long mod;
|
||||||
KeySym keysym;
|
xcb_keysym_t keysym;
|
||||||
KeyCode keycode;
|
xcb_keycode_t keycode;
|
||||||
Uicb *func;
|
Uicb *func;
|
||||||
char *arg;
|
char *arg;
|
||||||
/** Next and previous keys */
|
/** Next and previous keys */
|
||||||
|
@ -136,16 +138,16 @@ struct Widget
|
||||||
/** Update function */
|
/** Update function */
|
||||||
widget_tell_status_t (*tell)(Widget *, char *, char *);
|
widget_tell_status_t (*tell)(Widget *, char *, char *);
|
||||||
/** ButtonPressedEvent handler */
|
/** ButtonPressedEvent handler */
|
||||||
void (*button_press)(Widget *, XButtonPressedEvent *);
|
void (*button_press)(Widget *, xcb_button_press_event_t *);
|
||||||
/** Statusbar */
|
/** Statusbar */
|
||||||
Statusbar *statusbar;
|
Statusbar *statusbar;
|
||||||
/** Alignement */
|
/** Alignement */
|
||||||
Alignment alignment;
|
Alignment alignment;
|
||||||
/** Misc private data */
|
/** Misc private data */
|
||||||
void *data;
|
void *data;
|
||||||
/** True if user supplied coords */
|
/** true if user supplied coords */
|
||||||
Bool user_supplied_x;
|
bool user_supplied_x;
|
||||||
Bool user_supplied_y;
|
bool user_supplied_y;
|
||||||
/** area_t */
|
/** area_t */
|
||||||
area_t area;
|
area_t area;
|
||||||
/** Buttons bindings */
|
/** Buttons bindings */
|
||||||
|
@ -153,7 +155,7 @@ struct Widget
|
||||||
/** Cache */
|
/** Cache */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
Bool needs_update;
|
bool needs_update;
|
||||||
int flags;
|
int flags;
|
||||||
} cache;
|
} cache;
|
||||||
/** Next and previous widgets */
|
/** Next and previous widgets */
|
||||||
|
@ -203,31 +205,31 @@ struct Client
|
||||||
int minax, maxax, minay, maxay;
|
int minax, maxax, minay, maxay;
|
||||||
int border, oldborder;
|
int border, oldborder;
|
||||||
/** Has urgency hint */
|
/** Has urgency hint */
|
||||||
Bool isurgent;
|
bool isurgent;
|
||||||
/** Store previous floating state before maximizing */
|
/** Store previous floating state before maximizing */
|
||||||
Bool wasfloating;
|
bool wasfloating;
|
||||||
/** True if the window is floating */
|
/** true if the window is floating */
|
||||||
Bool isfloating;
|
bool isfloating;
|
||||||
/** True if the window is fixed */
|
/** true if the window is fixed */
|
||||||
Bool isfixed;
|
bool isfixed;
|
||||||
/** True if the window is maximized */
|
/** true if the window is maximized */
|
||||||
Bool ismax;
|
bool ismax;
|
||||||
/** True if the client must be skipped from client list */
|
/** true if the client must be skipped from client list */
|
||||||
Bool skip;
|
bool skip;
|
||||||
/** True if the client is moving */
|
/** true if the client is moving */
|
||||||
Bool ismoving;
|
bool ismoving;
|
||||||
/** True if the client must be skipped from task bar client list */
|
/** true if the client must be skipped from task bar client list */
|
||||||
Bool skiptb;
|
bool skiptb;
|
||||||
/** Next and previous clients */
|
/** Next and previous clients */
|
||||||
Client *prev, *next;
|
Client *prev, *next;
|
||||||
/** Window of the client */
|
/** Window of the client */
|
||||||
Window win;
|
xcb_window_t win;
|
||||||
/** Client logical screen */
|
/** Client logical screen */
|
||||||
int screen;
|
int screen;
|
||||||
/** Client physical screen */
|
/** Client physical screen */
|
||||||
int phys_screen;
|
int phys_screen;
|
||||||
/** True if the client is a new one */
|
/** True if the client is a new one */
|
||||||
Bool newcomer;
|
bool newcomer;
|
||||||
/** Titlebar */
|
/** Titlebar */
|
||||||
Titlebar titlebar;
|
Titlebar titlebar;
|
||||||
/** layer in the stacking order */
|
/** layer in the stacking order */
|
||||||
|
@ -251,10 +253,10 @@ struct Tag
|
||||||
char *name;
|
char *name;
|
||||||
/** Screen */
|
/** Screen */
|
||||||
int screen;
|
int screen;
|
||||||
/** True if selected */
|
/** true if selected */
|
||||||
Bool selected;
|
bool selected;
|
||||||
/** True if was selected before selecting others tags */
|
/** true if was selected before selecting others tags */
|
||||||
Bool was_selected;
|
bool was_selected;
|
||||||
/** Current tag layout */
|
/** Current tag layout */
|
||||||
Layout *layout;
|
Layout *layout;
|
||||||
/** Master width factor */
|
/** Master width factor */
|
||||||
|
@ -304,17 +306,17 @@ typedef struct
|
||||||
/** Floating window placement algo */
|
/** Floating window placement algo */
|
||||||
FloatingPlacement *floating_placement;
|
FloatingPlacement *floating_placement;
|
||||||
/** Respect resize hints */
|
/** Respect resize hints */
|
||||||
Bool resize_hints;
|
bool resize_hints;
|
||||||
/** Sloppy focus: focus follow mouse */
|
/** Sloppy focus: focus follow mouse */
|
||||||
Bool sloppy_focus;
|
bool sloppy_focus;
|
||||||
/** True if we should raise windows on focus */
|
/** true if we should raise windows on focus */
|
||||||
Bool sloppy_focus_raise;
|
bool sloppy_focus_raise;
|
||||||
/** Focus new clients */
|
/** Focus new clients */
|
||||||
Bool new_get_focus;
|
bool new_get_focus;
|
||||||
/** True if new clients should become master */
|
/** true if new clients should become master */
|
||||||
Bool new_become_master;
|
bool new_become_master;
|
||||||
/** True if we need to arrange() */
|
/** true if we need to arrange() */
|
||||||
Bool need_arrange;
|
bool need_arrange;
|
||||||
/** Colors */
|
/** Colors */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -340,8 +342,12 @@ typedef struct
|
||||||
typedef struct AwesomeConf AwesomeConf;
|
typedef struct AwesomeConf AwesomeConf;
|
||||||
struct AwesomeConf
|
struct AwesomeConf
|
||||||
{
|
{
|
||||||
/** Display ref */
|
/** Connection ref */
|
||||||
Display *display;
|
xcb_connection_t *connection;
|
||||||
|
/** Event and error handlers */
|
||||||
|
xcb_event_handlers_t *evenths;
|
||||||
|
/** Default screen number */
|
||||||
|
int default_screen;
|
||||||
/** Logical screens */
|
/** Logical screens */
|
||||||
VirtScreen *screens;
|
VirtScreen *screens;
|
||||||
/** Screens info */
|
/** Screens info */
|
||||||
|
@ -360,18 +366,18 @@ struct AwesomeConf
|
||||||
/** Numlock mask */
|
/** Numlock mask */
|
||||||
unsigned int numlockmask;
|
unsigned int numlockmask;
|
||||||
/** Check for XShape extension */
|
/** Check for XShape extension */
|
||||||
Bool have_shape;
|
bool have_shape;
|
||||||
/** Check for XRandR extension */
|
/** Check for XRandR extension */
|
||||||
Bool have_randr;
|
bool have_randr;
|
||||||
/** Cursors */
|
/** Cursors */
|
||||||
Cursor cursor[CurLast];
|
xcb_cursor_t cursor[CurLast];
|
||||||
/** Clients list */
|
/** Clients list */
|
||||||
Client *clients;
|
Client *clients;
|
||||||
/** Scratch client */
|
/** Scratch client */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
Client *client;
|
Client *client;
|
||||||
Bool isvisible;
|
bool isvisible;
|
||||||
} scratch;
|
} scratch;
|
||||||
/** Path to config file */
|
/** Path to config file */
|
||||||
char *configpath;
|
char *configpath;
|
||||||
|
|
30
tag.c
30
tag.c
|
@ -109,7 +109,7 @@ tag_client(Client *c, Tag *t)
|
||||||
|
|
||||||
client_saveprops(c);
|
client_saveprops(c);
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
globalconf.screens[c->screen].need_arrange = True;
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Untag a client with specified tag.
|
/** Untag a client with specified tag.
|
||||||
|
@ -138,19 +138,19 @@ untag_client(Client *c, Tag *t)
|
||||||
* \param t the tag
|
* \param t the tag
|
||||||
* \return true if the client is tagged with the tag, false otherwise.
|
* \return true if the client is tagged with the tag, false otherwise.
|
||||||
*/
|
*/
|
||||||
Bool
|
bool
|
||||||
is_client_tagged(Client *c, Tag *t)
|
is_client_tagged(Client *c, Tag *t)
|
||||||
{
|
{
|
||||||
tag_client_node_t *tc;
|
tag_client_node_t *tc;
|
||||||
|
|
||||||
if(!c)
|
if(!c)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
for(tc = globalconf.tclink; tc; tc = tc->next)
|
for(tc = globalconf.tclink; tc; tc = tc->next)
|
||||||
if(tc->client == c && tc->tag == t)
|
if(tc->client == c && tc->tag == t)
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Tag the client with the currently selected (visible) tags.
|
/** Tag the client with the currently selected (visible) tags.
|
||||||
|
@ -177,7 +177,7 @@ void
|
||||||
tag_client_with_rule(Client *c, Rule *r)
|
tag_client_with_rule(Client *c, Rule *r)
|
||||||
{
|
{
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
Bool matched = False;
|
bool matched = false;
|
||||||
|
|
||||||
if(!r) return;
|
if(!r) return;
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ tag_client_with_rule(Client *c, Rule *r)
|
||||||
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
||||||
if(tag_match_rule(tag, r))
|
if(tag_match_rule(tag, r))
|
||||||
{
|
{
|
||||||
matched = True;
|
matched = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ tag_view_only(Tag *target)
|
||||||
* \param view the view value
|
* \param view the view value
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
tag_view_byindex(int screen, int dindex, Bool view)
|
tag_view_byindex(int screen, int dindex, bool view)
|
||||||
{
|
{
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
|
|
||||||
|
@ -394,13 +394,13 @@ tag_view_only_byindex(int screen, int dindex)
|
||||||
* \param view set visible or not
|
* \param view set visible or not
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
tag_view(Tag *tag, Bool view)
|
tag_view(Tag *tag, bool view)
|
||||||
{
|
{
|
||||||
tag->was_selected = tag->selected;
|
tag->was_selected = tag->selected;
|
||||||
tag->selected = view;
|
tag->selected = view;
|
||||||
ewmh_update_net_current_desktop(screen_virttophys(tag->screen));
|
ewmh_update_net_current_desktop(screen_virttophys(tag->screen));
|
||||||
widget_invalidate_cache(tag->screen, WIDGET_CACHE_TAGS);
|
widget_invalidate_cache(tag->screen, WIDGET_CACHE_TAGS);
|
||||||
globalconf.screens[tag->screen].need_arrange = True;
|
globalconf.screens[tag->screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** View only this tag.
|
/** View only this tag.
|
||||||
|
@ -417,7 +417,7 @@ uicb_tag_view(int screen, char *arg)
|
||||||
tag_view_only_byindex(screen, atoi(arg) - 1);
|
tag_view_only_byindex(screen, atoi(arg) - 1);
|
||||||
else
|
else
|
||||||
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
||||||
tag_view(tag, True);
|
tag_view(tag, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** View the previously selected tags.
|
/** View the previously selected tags.
|
||||||
|
@ -446,8 +446,8 @@ uicb_tag_viewnext(int screen, char *arg __attribute__ ((unused)))
|
||||||
|
|
||||||
tag = tag_list_next_cycle(&globalconf.screens[screen].tags, curtags[0]);
|
tag = tag_list_next_cycle(&globalconf.screens[screen].tags, curtags[0]);
|
||||||
|
|
||||||
tag_view(curtags[0], False);
|
tag_view(curtags[0], false);
|
||||||
tag_view(tag, True);
|
tag_view(tag, true);
|
||||||
|
|
||||||
p_delete(&curtags);
|
p_delete(&curtags);
|
||||||
}
|
}
|
||||||
|
@ -464,8 +464,8 @@ uicb_tag_viewprev(int screen, char *arg __attribute__ ((unused)))
|
||||||
|
|
||||||
tag = tag_list_prev_cycle(&globalconf.screens[screen].tags, curtags[0]);
|
tag = tag_list_prev_cycle(&globalconf.screens[screen].tags, curtags[0]);
|
||||||
|
|
||||||
tag_view(curtags[0], False);
|
tag_view(curtags[0], false);
|
||||||
tag_view(tag, True);
|
tag_view(tag, true);
|
||||||
|
|
||||||
p_delete(&curtags);
|
p_delete(&curtags);
|
||||||
}
|
}
|
||||||
|
|
6
tag.h
6
tag.h
|
@ -28,13 +28,13 @@
|
||||||
#define IS_TILED(client, screen) (client && !client->isfloating && !client->ismax && client_isvisible(client, screen))
|
#define IS_TILED(client, screen) (client && !client->isfloating && !client->ismax && client_isvisible(client, screen))
|
||||||
|
|
||||||
Tag * tag_new(const char *, Layout *, double, int, int);
|
Tag * tag_new(const char *, Layout *, double, int, int);
|
||||||
void tag_view(Tag *, Bool);
|
void tag_view(Tag *, bool);
|
||||||
void tag_view_byindex(int, int, Bool);
|
void tag_view_byindex(int, int, bool);
|
||||||
void tag_push_to_screen(Tag *, int);
|
void tag_push_to_screen(Tag *, int);
|
||||||
Tag ** tags_get_current(int);
|
Tag ** tags_get_current(int);
|
||||||
void tag_client(Client *, Tag *);
|
void tag_client(Client *, Tag *);
|
||||||
void untag_client(Client *, Tag *);
|
void untag_client(Client *, Tag *);
|
||||||
Bool is_client_tagged(Client *, Tag *);
|
bool is_client_tagged(Client *, Tag *);
|
||||||
void tag_client_with_rule(Client *, Rule *r);
|
void tag_client_with_rule(Client *, Rule *r);
|
||||||
void tag_client_with_current_selected(Client *);
|
void tag_client_with_current_selected(Client *);
|
||||||
void tag_view_only_byindex(int, int);
|
void tag_view_only_byindex(int, int);
|
||||||
|
|
40
titlebar.c
40
titlebar.c
|
@ -19,6 +19,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "titlebar.h"
|
#include "titlebar.h"
|
||||||
|
@ -54,7 +57,7 @@ titlebar_init(Client *c)
|
||||||
width = c->geometry.width + 2 * c->border;
|
width = c->geometry.width + 2 * c->border;
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, c->geometry.width);
|
width = MIN(c->titlebar.width, c->geometry.width);
|
||||||
c->titlebar.sw = simplewindow_new(globalconf.display,
|
c->titlebar.sw = simplewindow_new(globalconf.connection,
|
||||||
c->phys_screen, 0, 0,
|
c->phys_screen, 0, 0,
|
||||||
width, c->titlebar.height, 0);
|
width, c->titlebar.height, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -64,14 +67,14 @@ titlebar_init(Client *c)
|
||||||
width = c->geometry.height + 2 * c->border;
|
width = c->geometry.height + 2 * c->border;
|
||||||
else
|
else
|
||||||
width = MIN(c->titlebar.width, c->geometry.height);
|
width = MIN(c->titlebar.width, c->geometry.height);
|
||||||
c->titlebar.sw = simplewindow_new(globalconf.display,
|
c->titlebar.sw = simplewindow_new(globalconf.connection,
|
||||||
c->phys_screen, 0, 0,
|
c->phys_screen, 0, 0,
|
||||||
c->titlebar.height, width, 0);
|
c->titlebar.height, width, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XMapWindow(globalconf.display, c->titlebar.sw->window);
|
xcb_map_window(globalconf.connection, c->titlebar.sw->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add the titlebar geometry to a geometry.
|
/** Add the titlebar geometry to a geometry.
|
||||||
|
@ -148,26 +151,31 @@ titlebar_geometry_remove(Titlebar *t, area_t geometry)
|
||||||
void
|
void
|
||||||
titlebar_draw(Client *c)
|
titlebar_draw(Client *c)
|
||||||
{
|
{
|
||||||
Drawable dw = 0;
|
xcb_drawable_t dw = 0;
|
||||||
DrawCtx *ctx;
|
DrawCtx *ctx;
|
||||||
style_t style;
|
style_t style;
|
||||||
area_t geometry;
|
area_t geometry;
|
||||||
|
xcb_screen_t *s;
|
||||||
|
|
||||||
if(!c->titlebar.sw)
|
if(!c->titlebar.sw)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
s = xcb_aux_get_screen(globalconf.connection,
|
||||||
|
c->titlebar.sw->phys_screen);
|
||||||
|
|
||||||
switch(c->titlebar.position)
|
switch(c->titlebar.position)
|
||||||
{
|
{
|
||||||
case Off:
|
case Off:
|
||||||
return;
|
return;
|
||||||
case Right:
|
case Right:
|
||||||
case Left:
|
case Left:
|
||||||
dw = XCreatePixmap(globalconf.display,
|
dw = xcb_generate_id(globalconf.connection);
|
||||||
RootWindow(globalconf.display, c->titlebar.sw->phys_screen),
|
xcb_create_pixmap(globalconf.connection, s->root_depth,
|
||||||
c->titlebar.sw->geometry.height,
|
dw,
|
||||||
c->titlebar.sw->geometry.width,
|
root_window(globalconf.connection, c->titlebar.sw->phys_screen),
|
||||||
DefaultDepth(globalconf.display, c->titlebar.sw->phys_screen));
|
c->titlebar.sw->geometry.height,
|
||||||
ctx = draw_context_new(globalconf.display, c->titlebar.sw->phys_screen,
|
c->titlebar.sw->geometry.width);
|
||||||
|
ctx = draw_context_new(globalconf.connection, c->titlebar.sw->phys_screen,
|
||||||
c->titlebar.sw->geometry.height,
|
c->titlebar.sw->geometry.height,
|
||||||
c->titlebar.sw->geometry.width,
|
c->titlebar.sw->geometry.width,
|
||||||
dw);
|
dw);
|
||||||
|
@ -175,7 +183,7 @@ titlebar_draw(Client *c)
|
||||||
geometry.height = c->titlebar.sw->geometry.width;
|
geometry.height = c->titlebar.sw->geometry.width;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ctx = draw_context_new(globalconf.display, c->titlebar.sw->phys_screen,
|
ctx = draw_context_new(globalconf.connection, c->titlebar.sw->phys_screen,
|
||||||
c->titlebar.sw->geometry.width,
|
c->titlebar.sw->geometry.width,
|
||||||
c->titlebar.sw->geometry.height,
|
c->titlebar.sw->geometry.height,
|
||||||
c->titlebar.sw->drawable);
|
c->titlebar.sw->drawable);
|
||||||
|
@ -201,12 +209,12 @@ titlebar_draw(Client *c)
|
||||||
case Left:
|
case Left:
|
||||||
draw_rotate(ctx, c->titlebar.sw->drawable, ctx->height, ctx->width,
|
draw_rotate(ctx, c->titlebar.sw->drawable, ctx->height, ctx->width,
|
||||||
- M_PI_2, 0, c->titlebar.sw->geometry.height);
|
- M_PI_2, 0, c->titlebar.sw->geometry.height);
|
||||||
XFreePixmap(globalconf.display, dw);
|
xcb_free_pixmap(globalconf.connection, dw);
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
draw_rotate(ctx, c->titlebar.sw->drawable, ctx->height, ctx->width,
|
draw_rotate(ctx, c->titlebar.sw->drawable, ctx->height, ctx->width,
|
||||||
M_PI_2, c->titlebar.sw->geometry.width, 0);
|
M_PI_2, c->titlebar.sw->geometry.width, 0);
|
||||||
XFreePixmap(globalconf.display, dw);
|
xcb_free_pixmap(globalconf.connection, dw);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -447,9 +455,9 @@ titlebar_position_set(Titlebar *t, Position p)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if((t->position = p))
|
if((t->position = p))
|
||||||
XMapWindow(globalconf.display, t->sw->window);
|
xcb_map_window(globalconf.connection, t->sw->window);
|
||||||
else
|
else
|
||||||
XUnmapWindow(globalconf.display, t->sw->window);
|
xcb_unmap_window(globalconf.connection, t->sw->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Toggle the visibility of the focused window's titlebar.
|
/** Toggle the visibility of the focused window's titlebar.
|
||||||
|
@ -473,7 +481,7 @@ uicb_client_toggletitlebar(int screen __attribute__ ((unused)), char *arg __attr
|
||||||
if(c->isfloating || layout_get_current(screen)->arrange == layout_floating)
|
if(c->isfloating || layout_get_current(screen)->arrange == layout_floating)
|
||||||
titlebar_update_geometry_floating(c);
|
titlebar_update_geometry_floating(c);
|
||||||
else
|
else
|
||||||
globalconf.screens[c->screen].need_arrange = True;
|
globalconf.screens[c->screen].need_arrange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
11
uicb.c
11
uicb.c
|
@ -28,6 +28,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
|
||||||
#include "awesome.h"
|
#include "awesome.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
|
@ -69,8 +72,8 @@ uicb_exec(int screen __attribute__ ((unused)), char *cmd)
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
client_unban(c);
|
client_unban(c);
|
||||||
|
|
||||||
XSync(globalconf.display, False);
|
xcb_aux_sync(globalconf.connection);
|
||||||
XCloseDisplay(globalconf.display);
|
xcb_disconnect(globalconf.connection);
|
||||||
|
|
||||||
/* Ignore the leading spaces if any */
|
/* Ignore the leading spaces if any */
|
||||||
while(cmd[0] && cmd[0] == ' ')
|
while(cmd[0] && cmd[0] == ' ')
|
||||||
|
@ -123,8 +126,8 @@ uicb_spawn(int screen, char *arg)
|
||||||
{
|
{
|
||||||
if(fork() == 0)
|
if(fork() == 0)
|
||||||
{
|
{
|
||||||
if(globalconf.display)
|
if(globalconf.connection)
|
||||||
close(ConnectionNumber(globalconf.display));
|
close(xcb_get_file_descriptor(globalconf.connection));
|
||||||
setsid();
|
setsid();
|
||||||
execl(shell, shell, "-c", arg, NULL);
|
execl(shell, shell, "-c", arg, NULL);
|
||||||
warn("execl '%s -c %s' failed: %s\n", shell, arg, strerror(errno));
|
warn("execl '%s -c %s' failed: %s\n", shell, arg, strerror(errno));
|
||||||
|
|
8
widget.c
8
widget.c
|
@ -110,12 +110,12 @@ widget_getbyname(Statusbar *sb, char *name)
|
||||||
* \param ev the XButtonPressedEvent the widget received
|
* \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, xcb_button_press_event_t *ev)
|
||||||
{
|
{
|
||||||
Button *b;
|
Button *b;
|
||||||
|
|
||||||
for(b = widget->buttons; b; b = b->next)
|
for(b = widget->buttons; b; b = b->next)
|
||||||
if(ev->button == b->button && CLEANMASK(ev->state) == b->mod && b->func)
|
if(ev->detail == b->button && CLEANMASK(ev->state) == b->mod && b->func)
|
||||||
{
|
{
|
||||||
b->func(widget->statusbar->screen, b->arg);
|
b->func(widget->statusbar->screen, b->arg);
|
||||||
break;
|
break;
|
||||||
|
@ -171,7 +171,7 @@ widget_invalidate_cache(int screen, int flags)
|
||||||
statusbar = statusbar->next)
|
statusbar = statusbar->next)
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||||
if(widget->cache.flags & flags)
|
if(widget->cache.flags & flags)
|
||||||
widget->cache.needs_update = True;
|
widget->cache.needs_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send commands to widgets.
|
/** Send commands to widgets.
|
||||||
|
@ -251,7 +251,7 @@ uicb_widget_tell(int screen, char *arg)
|
||||||
property, widget->name);
|
property, widget->name);
|
||||||
break;
|
break;
|
||||||
case WIDGET_NOERROR:
|
case WIDGET_NOERROR:
|
||||||
widget->cache.needs_update = True;
|
widget->cache.needs_update = true;
|
||||||
break;
|
break;
|
||||||
case WIDGET_ERROR_CUSTOM:
|
case WIDGET_ERROR_CUSTOM:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
extern AwesomeConf globalconf;
|
extern AwesomeConf globalconf;
|
||||||
|
|
||||||
widget_tell_status_t
|
widget_tell_status_t
|
||||||
widget_set_color_for_data(Widget *widget, XColor *color, char *command, int data_items, char ** data_title)
|
widget_set_color_for_data(Widget *widget, xcolor_t *color, char *command, int data_items, char ** data_title)
|
||||||
{
|
{
|
||||||
char *title, *setting;
|
char *title, *setting;
|
||||||
int i;
|
int i;
|
||||||
|
@ -35,7 +35,7 @@ widget_set_color_for_data(Widget *widget, XColor *color, char *command, int data
|
||||||
for(i = 0; i < data_items; i++)
|
for(i = 0; i < data_items; i++)
|
||||||
if(!a_strcmp(title, data_title[i]))
|
if(!a_strcmp(title, data_title[i]))
|
||||||
{
|
{
|
||||||
if(draw_color_new(globalconf.display,
|
if(draw_color_new(globalconf.connection,
|
||||||
widget->statusbar->phys_screen,
|
widget->statusbar->phys_screen,
|
||||||
setting, &color[i]))
|
setting, &color[i]))
|
||||||
return WIDGET_NOERROR;
|
return WIDGET_NOERROR;
|
||||||
|
@ -45,24 +45,24 @@ widget_set_color_for_data(Widget *widget, XColor *color, char *command, int data
|
||||||
return WIDGET_ERROR_FORMAT_SECTION;
|
return WIDGET_ERROR_FORMAT_SECTION;
|
||||||
}
|
}
|
||||||
widget_tell_status_t
|
widget_tell_status_t
|
||||||
widget_set_color_pointer_for_data(Widget *widget, XColor **color, char *command, int data_items, char ** data_title)
|
widget_set_color_pointer_for_data(Widget *widget, xcolor_t **color, char *command, int data_items, char ** data_title)
|
||||||
{
|
{
|
||||||
char *title, *setting;
|
char *title, *setting;
|
||||||
int i;
|
int i;
|
||||||
Bool flag;
|
bool flag;
|
||||||
title = strtok(command, " ");
|
title = strtok(command, " ");
|
||||||
if(!(setting = strtok(NULL, " ")))
|
if(!(setting = strtok(NULL, " ")))
|
||||||
return WIDGET_ERROR_NOVALUE;
|
return WIDGET_ERROR_NOVALUE;
|
||||||
for(i = 0; i < data_items; i++)
|
for(i = 0; i < data_items; i++)
|
||||||
if(!a_strcmp(title, data_title[i]))
|
if(!a_strcmp(title, data_title[i]))
|
||||||
{
|
{
|
||||||
flag = False;
|
flag = false;
|
||||||
if(!color[i])
|
if(!color[i])
|
||||||
{
|
{
|
||||||
flag = True; /* p_delete && restore to NULL, if draw_color_new unsuccessful */
|
flag = true; /* p_delete && restore to NULL, if draw_color_new unsuccessful */
|
||||||
color[i] = p_new(XColor, 1);
|
color[i] = p_new(xcolor_t, 1);
|
||||||
}
|
}
|
||||||
if(!(draw_color_new(globalconf.display,
|
if(!(draw_color_new(globalconf.connection,
|
||||||
widget->statusbar->phys_screen,
|
widget->statusbar->phys_screen,
|
||||||
setting, color[i])))
|
setting, color[i])))
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
#define AWESOME_WIDGETS_COMMON_H
|
#define AWESOME_WIDGETS_COMMON_H
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
|
|
||||||
widget_tell_status_t widget_set_color_for_data(Widget *, XColor *, char *, int, char **);
|
widget_tell_status_t widget_set_color_for_data(Widget *, xcolor_t *, char *, int, char **);
|
||||||
widget_tell_status_t widget_set_color_pointer_for_data(Widget *, XColor **, char *, int, char **);
|
widget_tell_status_t widget_set_color_pointer_for_data(Widget *, xcolor_t **, char *, int, char **);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// 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
|
||||||
|
|
|
@ -43,7 +43,7 @@ emptybox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
if(!widget->user_supplied_y)
|
if(!widget->user_supplied_y)
|
||||||
widget->area.y = 0;
|
widget->area.y = 0;
|
||||||
|
|
||||||
draw_rectangle(ctx, widget->area, 1.0, True, d->style.bg);
|
draw_rectangle(ctx, widget->area, 1.0, true, d->style.bg);
|
||||||
|
|
||||||
return widget->area.width;
|
return widget->area.width;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ emptybox_new(Statusbar *statusbar, cfg_t *config)
|
||||||
|
|
||||||
w->data = d = p_new(Data, 1);
|
w->data = d = p_new(Data, 1);
|
||||||
|
|
||||||
draw_style_init(globalconf.display, statusbar->phys_screen,
|
draw_style_init(globalconf.connection, statusbar->phys_screen,
|
||||||
cfg_getsec(config, "style"),
|
cfg_getsec(config, "style"),
|
||||||
&d->style,
|
&d->style,
|
||||||
&globalconf.screens[statusbar->screen].styles.normal);
|
&globalconf.screens[statusbar->screen].styles.normal);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "common/draw.h"
|
#include "common/draw.h"
|
||||||
#include "common/configopts.h"
|
#include "common/configopts.h"
|
||||||
|
#include "common/xutil.h"
|
||||||
|
|
||||||
extern AwesomeConf globalconf;
|
extern AwesomeConf globalconf;
|
||||||
|
|
||||||
|
@ -38,8 +39,8 @@ typedef struct
|
||||||
float height; /** Height of graph (0-1; 1 = height of statusbar) */
|
float height; /** Height of graph (0-1; 1 = height of statusbar) */
|
||||||
int box_height; /** Height of the innerbox in pixels */
|
int box_height; /** Height of the innerbox in pixels */
|
||||||
int size; /** Size of lines-array (also innerbox-lenght) */
|
int size; /** Size of lines-array (also innerbox-lenght) */
|
||||||
XColor bg; /** Background color */
|
xcolor_t bg; /** Background color */
|
||||||
XColor bordercolor; /** Border color */
|
xcolor_t bordercolor; /** Border color */
|
||||||
Position grow; /** grow: Left or Right */
|
Position grow; /** grow: Left or Right */
|
||||||
|
|
||||||
/* markers... */
|
/* markers... */
|
||||||
|
@ -56,24 +57,24 @@ typedef struct
|
||||||
int **fillbottom; /** Data array pointer (like *lines) */
|
int **fillbottom; /** Data array pointer (like *lines) */
|
||||||
int **fillbottom_index; /** Points to some index[i] */
|
int **fillbottom_index; /** Points to some index[i] */
|
||||||
int fillbottom_total; /** Total of them */
|
int fillbottom_total; /** Total of them */
|
||||||
Bool *fillbottom_vertical_grad; /** Create a vertical color gradient */
|
bool *fillbottom_vertical_grad; /** Create a vertical color gradient */
|
||||||
XColor *fillbottom_color; /** Color of them */
|
xcolor_t *fillbottom_color; /** Color of them */
|
||||||
XColor **fillbottom_pcolor_center; /** Color at middle of graph */
|
xcolor_t **fillbottom_pcolor_center; /** Color at middle of graph */
|
||||||
XColor **fillbottom_pcolor_end; /** Color at end of graph */
|
xcolor_t **fillbottom_pcolor_end; /** Color at end of graph */
|
||||||
int **filltop; /** Data array pointer (like *lines) */
|
int **filltop; /** Data array pointer (like *lines) */
|
||||||
int **filltop_index; /** Points to some index[i] */
|
int **filltop_index; /** Points to some index[i] */
|
||||||
int filltop_total; /** Total of them */
|
int filltop_total; /** Total of them */
|
||||||
Bool *filltop_vertical_grad; /** Create a vertical color gradient */
|
bool *filltop_vertical_grad; /** Create a vertical color gradient */
|
||||||
XColor *filltop_color; /** Color of them */
|
xcolor_t *filltop_color; /** Color of them */
|
||||||
XColor **filltop_pcolor_center; /** Color at center of graph */
|
xcolor_t **filltop_pcolor_center; /** Color at center of graph */
|
||||||
XColor **filltop_pcolor_end; /** Color at end of graph */
|
xcolor_t **filltop_pcolor_end; /** Color at end of graph */
|
||||||
int **drawline; /** Data array pointer (like *lines) */
|
int **drawline; /** Data array pointer (like *lines) */
|
||||||
int **drawline_index; /** Points to some index[i] */
|
int **drawline_index; /** Points to some index[i] */
|
||||||
int drawline_total; /** Total of them */
|
int drawline_total; /** Total of them */
|
||||||
Bool *drawline_vertical_grad; /** Create a vertical color gradient */
|
bool *drawline_vertical_grad; /** Create a vertical color gradient */
|
||||||
XColor *drawline_color; /** Color of them */
|
xcolor_t *drawline_color; /** Color of them */
|
||||||
XColor **drawline_pcolor_center; /** Color at middle of graph */
|
xcolor_t **drawline_pcolor_center; /** Color at middle of graph */
|
||||||
XColor **drawline_pcolor_end; /** Color at end of graph */
|
xcolor_t **drawline_pcolor_end; /** Color at end of graph */
|
||||||
|
|
||||||
int *draw_from; /** Preparation/tmp array for draw_graph(); */
|
int *draw_from; /** Preparation/tmp array for draw_graph(); */
|
||||||
int *draw_to; /** Preparation/tmp array for draw_graph(); */
|
int *draw_to; /** Preparation/tmp array for draw_graph(); */
|
||||||
|
@ -111,7 +112,7 @@ graph_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
rectangle.y = margin_top + 1;
|
rectangle.y = margin_top + 1;
|
||||||
rectangle.width = d->size;
|
rectangle.width = d->size;
|
||||||
rectangle.height = d->box_height;
|
rectangle.height = d->box_height;
|
||||||
draw_rectangle(ctx, rectangle, 1.0, True, d->bg);
|
draw_rectangle(ctx, rectangle, 1.0, true, d->bg);
|
||||||
|
|
||||||
/* for graph drawing */
|
/* for graph drawing */
|
||||||
rectangle.y = margin_top + d->box_height + 1; /* bottom left corner as starting point */
|
rectangle.y = margin_top + d->box_height + 1; /* bottom left corner as starting point */
|
||||||
|
@ -267,7 +268,7 @@ graph_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
rectangle.y = margin_top;
|
rectangle.y = margin_top;
|
||||||
rectangle.width = d->size + 2;
|
rectangle.width = d->size + 2;
|
||||||
rectangle.height = d->box_height + 2;
|
rectangle.height = d->box_height + 2;
|
||||||
draw_rectangle(ctx, rectangle, 1.0, False, d->bordercolor);
|
draw_rectangle(ctx, rectangle, 1.0, false, d->bordercolor);
|
||||||
|
|
||||||
widget->area.width = d->width;
|
widget->area.width = d->width;
|
||||||
widget->area.height = widget->statusbar->height;
|
widget->area.height = widget->statusbar->height;
|
||||||
|
@ -349,14 +350,14 @@ graph_tell(Widget *widget, char *property, char *command)
|
||||||
d->height = atof(command);
|
d->height = atof(command);
|
||||||
else if(!a_strcmp(property, "bg"))
|
else if(!a_strcmp(property, "bg"))
|
||||||
{
|
{
|
||||||
if(!draw_color_new(globalconf.display,
|
if(!draw_color_new(globalconf.connection,
|
||||||
widget->statusbar->phys_screen,
|
widget->statusbar->phys_screen,
|
||||||
command, &d->bg))
|
command, &d->bg))
|
||||||
return WIDGET_ERROR_FORMAT_COLOR;
|
return WIDGET_ERROR_FORMAT_COLOR;
|
||||||
}
|
}
|
||||||
else if(!a_strcmp(property, "bordercolor"))
|
else if(!a_strcmp(property, "bordercolor"))
|
||||||
{
|
{
|
||||||
if(!draw_color_new(globalconf.display,
|
if(!draw_color_new(globalconf.connection,
|
||||||
widget->statusbar->phys_screen,
|
widget->statusbar->phys_screen,
|
||||||
command, &d->bordercolor))
|
command, &d->bordercolor))
|
||||||
return WIDGET_ERROR_FORMAT_COLOR;
|
return WIDGET_ERROR_FORMAT_COLOR;
|
||||||
|
@ -387,9 +388,9 @@ graph_new(Statusbar *statusbar, cfg_t *config)
|
||||||
char *color;
|
char *color;
|
||||||
int i;
|
int i;
|
||||||
char *type;
|
char *type;
|
||||||
XColor tmp_color = { 0, 0, 0, 0, 0, 0 };
|
xcolor_t tmp_color = { 0, 0, 0, 0 };
|
||||||
XColor *ptmp_color_center;
|
xcolor_t *ptmp_color_center;
|
||||||
XColor *ptmp_color_end;
|
xcolor_t *ptmp_color_end;
|
||||||
|
|
||||||
w = p_new(Widget, 1);
|
w = p_new(Widget, 1);
|
||||||
widget_common_new(w, statusbar, config);
|
widget_common_new(w, statusbar, config);
|
||||||
|
@ -431,18 +432,18 @@ graph_new(Statusbar *statusbar, cfg_t *config)
|
||||||
d->values = p_new(float *, d->data_items);
|
d->values = p_new(float *, d->data_items);
|
||||||
d->lines = p_new(int *, d->data_items);
|
d->lines = p_new(int *, d->data_items);
|
||||||
|
|
||||||
d->filltop_color = p_new(XColor, d->data_items);
|
d->filltop_color = p_new(xcolor_t, d->data_items);
|
||||||
d->filltop_pcolor_center = p_new(XColor *, d->data_items);
|
d->filltop_pcolor_center = p_new(xcolor_t *, d->data_items);
|
||||||
d->filltop_pcolor_end = p_new(XColor *, d->data_items);
|
d->filltop_pcolor_end = p_new(xcolor_t *, d->data_items);
|
||||||
d->filltop_vertical_grad = p_new(Bool, d->data_items);
|
d->filltop_vertical_grad = p_new(bool, d->data_items);
|
||||||
d->fillbottom_color = p_new(XColor, d->data_items);
|
d->fillbottom_color = p_new(xcolor_t, d->data_items);
|
||||||
d->fillbottom_pcolor_center = p_new(XColor *, d->data_items);
|
d->fillbottom_pcolor_center = p_new(xcolor_t *, d->data_items);
|
||||||
d->fillbottom_pcolor_end = p_new(XColor *, d->data_items);
|
d->fillbottom_pcolor_end = p_new(xcolor_t *, d->data_items);
|
||||||
d->fillbottom_vertical_grad = p_new(Bool, d->data_items);
|
d->fillbottom_vertical_grad = p_new(bool, d->data_items);
|
||||||
d->drawline_color = p_new(XColor, d->data_items);
|
d->drawline_color = p_new(xcolor_t, d->data_items);
|
||||||
d->drawline_pcolor_center = p_new(XColor *, d->data_items);
|
d->drawline_pcolor_center = p_new(xcolor_t *, d->data_items);
|
||||||
d->drawline_pcolor_end = p_new(XColor *, d->data_items);
|
d->drawline_pcolor_end = p_new(xcolor_t *, d->data_items);
|
||||||
d->drawline_vertical_grad = p_new(Bool, d->data_items);
|
d->drawline_vertical_grad = p_new(bool, d->data_items);
|
||||||
|
|
||||||
d->max_index = p_new(int, d->data_items);
|
d->max_index = p_new(int, d->data_items);
|
||||||
d->index = p_new(int, d->data_items);
|
d->index = p_new(int, d->data_items);
|
||||||
|
@ -459,20 +460,20 @@ graph_new(Statusbar *statusbar, cfg_t *config)
|
||||||
d->data_title[i] = a_strdup(cfg_title(cfg));
|
d->data_title[i] = a_strdup(cfg_title(cfg));
|
||||||
|
|
||||||
if((color = cfg_getstr(cfg, "fg")))
|
if((color = cfg_getstr(cfg, "fg")))
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, &tmp_color);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, &tmp_color);
|
||||||
else
|
else
|
||||||
tmp_color = globalconf.screens[statusbar->screen].styles.normal.fg;
|
tmp_color = globalconf.screens[statusbar->screen].styles.normal.fg;
|
||||||
|
|
||||||
if((color = cfg_getstr(cfg, "fg_center")))
|
if((color = cfg_getstr(cfg, "fg_center")))
|
||||||
{
|
{
|
||||||
ptmp_color_center = p_new(XColor, 1);
|
ptmp_color_center = p_new(xcolor_t, 1);
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, ptmp_color_center);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, ptmp_color_center);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((color = cfg_getstr(cfg, "fg_end")))
|
if((color = cfg_getstr(cfg, "fg_end")))
|
||||||
{
|
{
|
||||||
ptmp_color_end = p_new(XColor, 1);
|
ptmp_color_end = p_new(xcolor_t, 1);
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, ptmp_color_end);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, ptmp_color_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg_getbool(cfg, "scale"))
|
if (cfg_getbool(cfg, "scale"))
|
||||||
|
@ -520,12 +521,12 @@ graph_new(Statusbar *statusbar, cfg_t *config)
|
||||||
}
|
}
|
||||||
|
|
||||||
if((color = cfg_getstr(config, "bg")))
|
if((color = cfg_getstr(config, "bg")))
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->bg);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, &d->bg);
|
||||||
else
|
else
|
||||||
d->bg = globalconf.screens[statusbar->screen].styles.normal.bg;
|
d->bg = globalconf.screens[statusbar->screen].styles.normal.bg;
|
||||||
|
|
||||||
if((color = cfg_getstr(config, "bordercolor")))
|
if((color = cfg_getstr(config, "bordercolor")))
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->bordercolor);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, &d->bordercolor);
|
||||||
else
|
else
|
||||||
d->bordercolor = tmp_color;
|
d->bordercolor = tmp_color;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ extern AwesomeConf globalconf;
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char *image;
|
char *image;
|
||||||
Bool resize;
|
bool resize;
|
||||||
} Data;
|
} Data;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -67,7 +67,7 @@ iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
static widget_tell_status_t
|
static widget_tell_status_t
|
||||||
iconbox_tell(Widget *widget, char *property, char *command)
|
iconbox_tell(Widget *widget, char *property, char *command)
|
||||||
{
|
{
|
||||||
Bool b;
|
bool b;
|
||||||
Data *d = widget->data;
|
Data *d = widget->data;
|
||||||
|
|
||||||
if(command == NULL)
|
if(command == NULL)
|
||||||
|
|
|
@ -50,28 +50,28 @@ typedef struct
|
||||||
/** total number of ticks */
|
/** total number of ticks */
|
||||||
int ticks_count;
|
int ticks_count;
|
||||||
/** reverse drawing */
|
/** reverse drawing */
|
||||||
Bool *reverse;
|
bool *reverse;
|
||||||
/** 90 Degree's turned */
|
/** 90 Degree's turned */
|
||||||
Bool vertical;
|
bool vertical;
|
||||||
/** Number of data_items (bars) */
|
/** Number of data_items (bars) */
|
||||||
int data_items;
|
int data_items;
|
||||||
/** Height 0-1, where 1 is height of statusbar */
|
/** Height 0-1, where 1 is height of statusbar */
|
||||||
float height;
|
float height;
|
||||||
/** Foreground color */
|
/** Foreground color */
|
||||||
XColor *fg;
|
xcolor_t *fg;
|
||||||
/** Foreground color of turned-off ticks */
|
/** Foreground color of turned-off ticks */
|
||||||
XColor *fg_off;
|
xcolor_t *fg_off;
|
||||||
/** Foreground color when bar is half-full */
|
/** Foreground color when bar is half-full */
|
||||||
XColor **pfg_center;
|
xcolor_t **pfg_center;
|
||||||
/** Foreground color when bar is full */
|
/** Foreground color when bar is full */
|
||||||
XColor **pfg_end;
|
xcolor_t **pfg_end;
|
||||||
/** Background color */
|
/** Background color */
|
||||||
XColor *bg;
|
xcolor_t *bg;
|
||||||
/** Border color */
|
/** Border color */
|
||||||
XColor *bordercolor;
|
xcolor_t *bordercolor;
|
||||||
} Data;
|
} Data;
|
||||||
|
|
||||||
static Bool
|
static bool
|
||||||
check_settings(Data *d, int status_height)
|
check_settings(Data *d, int status_height)
|
||||||
{
|
{
|
||||||
int tmp, h_total;
|
int tmp, h_total;
|
||||||
|
@ -85,14 +85,14 @@ check_settings(Data *d, int status_height)
|
||||||
|| (!d->ticks_count && tmp < 0))
|
|| (!d->ticks_count && tmp < 0))
|
||||||
{
|
{
|
||||||
warn("progressbar's 'width' is too small for the given configuration options\n");
|
warn("progressbar's 'width' is too small for the given configuration options\n");
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
tmp = h_total - d->data_items * (2 * (d->border_width + d->border_padding) + 1)
|
tmp = h_total - d->data_items * (2 * (d->border_width + d->border_padding) + 1)
|
||||||
- (d->data_items - 1) * d->gap;
|
- (d->data_items - 1) * d->gap;
|
||||||
if(tmp < 0)
|
if(tmp < 0)
|
||||||
{
|
{
|
||||||
warn("progressbar's 'height' is too small for the given configuration options\n");
|
warn("progressbar's 'height' is too small for the given configuration options\n");
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* vertical / standing up */
|
else /* vertical / standing up */
|
||||||
|
@ -102,17 +102,17 @@ check_settings(Data *d, int status_height)
|
||||||
|| (!d->ticks_count && tmp < 0))
|
|| (!d->ticks_count && tmp < 0))
|
||||||
{
|
{
|
||||||
warn("progressbar's 'height' is too small for the given configuration options\n");
|
warn("progressbar's 'height' is too small for the given configuration options\n");
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
tmp = d->width - d->data_items * (2 * (d->border_width + d->border_padding) + 1)
|
tmp = d->width - d->data_items * (2 * (d->border_width + d->border_padding) + 1)
|
||||||
- (d->data_items - 1) * d->gap;
|
- (d->data_items - 1) * d->gap;
|
||||||
if(tmp < 0)
|
if(tmp < 0)
|
||||||
{
|
{
|
||||||
warn("progressbar's 'width' is too small for the given configuration options\n");
|
warn("progressbar's 'width' is too small for the given configuration options\n");
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,8 +208,8 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
rectangle.height = pb_height + 2 * (d->border_padding + d->border_width);
|
rectangle.height = pb_height + 2 * (d->border_padding + d->border_width);
|
||||||
|
|
||||||
if(d->border_padding)
|
if(d->border_padding)
|
||||||
draw_rectangle(ctx, rectangle, 1.0, True, d->bg[i]);
|
draw_rectangle(ctx, rectangle, 1.0, true, d->bg[i]);
|
||||||
draw_rectangle(ctx, rectangle, d->border_width, False, d->bordercolor[i]);
|
draw_rectangle(ctx, rectangle, d->border_width, false, d->bordercolor[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* new value/progress in px + pattern setup */
|
/* new value/progress in px + pattern setup */
|
||||||
|
@ -241,10 +241,10 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
|
|
||||||
/* fg color */
|
/* fg color */
|
||||||
if(!d->reverse[i])
|
if(!d->reverse[i])
|
||||||
draw_rectangle_gradient(ctx, rectangle, 1.0, True, pattern_rect,
|
draw_rectangle_gradient(ctx, rectangle, 1.0, true, pattern_rect,
|
||||||
&(d->fg[i]), d->pfg_center[i], d->pfg_end[i]);
|
&(d->fg[i]), d->pfg_center[i], d->pfg_end[i]);
|
||||||
else /*REV: bg */
|
else /*REV: bg */
|
||||||
draw_rectangle(ctx, rectangle, 1.0, True, d->fg_off[i]);
|
draw_rectangle(ctx, rectangle, 1.0, true, d->fg_off[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* top part */
|
/* top part */
|
||||||
|
@ -257,9 +257,9 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
|
|
||||||
/* bg color */
|
/* bg color */
|
||||||
if(!d->reverse[i])
|
if(!d->reverse[i])
|
||||||
draw_rectangle(ctx, rectangle, 1.0, True, d->fg_off[i]);
|
draw_rectangle(ctx, rectangle, 1.0, true, d->fg_off[i]);
|
||||||
else /* REV: fg */
|
else /* REV: fg */
|
||||||
draw_rectangle_gradient(ctx, rectangle, 1.0, True, pattern_rect,
|
draw_rectangle_gradient(ctx, rectangle, 1.0, true, pattern_rect,
|
||||||
&(d->fg[i]), d->pfg_center[i], d->pfg_end[i]);
|
&(d->fg[i]), d->pfg_center[i], d->pfg_end[i]);
|
||||||
}
|
}
|
||||||
/* draw gaps TODO: improve e.g all in one */
|
/* draw gaps TODO: improve e.g all in one */
|
||||||
|
@ -272,7 +272,7 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
pb_y + pb_height - d->ticks_gap >= rectangle.y;
|
pb_y + pb_height - d->ticks_gap >= rectangle.y;
|
||||||
rectangle.y += unit)
|
rectangle.y += unit)
|
||||||
{
|
{
|
||||||
draw_rectangle(ctx, rectangle, 1.0, True, d->bg[i]);
|
draw_rectangle(ctx, rectangle, 1.0, true, d->bg[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pb_offset += pb_width + d->gap + 2 * (d->border_width + d->border_padding);
|
pb_offset += pb_width + d->gap + 2 * (d->border_width + d->border_padding);
|
||||||
|
@ -309,8 +309,8 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
rectangle.height = pb_height + 2 * (d->border_padding + d->border_width);
|
rectangle.height = pb_height + 2 * (d->border_padding + d->border_width);
|
||||||
|
|
||||||
if(d->border_padding)
|
if(d->border_padding)
|
||||||
draw_rectangle(ctx, rectangle, 1.0, True, d->bg[i]);
|
draw_rectangle(ctx, rectangle, 1.0, true, d->bg[i]);
|
||||||
draw_rectangle(ctx, rectangle, d->border_width, False, d->bordercolor[i]);
|
draw_rectangle(ctx, rectangle, d->border_width, false, d->bordercolor[i]);
|
||||||
}
|
}
|
||||||
/* new value/progress in px + pattern setup */
|
/* new value/progress in px + pattern setup */
|
||||||
if(!d->reverse[i])
|
if(!d->reverse[i])
|
||||||
|
@ -341,10 +341,10 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
|
|
||||||
/* fg color */
|
/* fg color */
|
||||||
if(!d->reverse[i])
|
if(!d->reverse[i])
|
||||||
draw_rectangle_gradient(ctx, rectangle, 1.0, True, pattern_rect,
|
draw_rectangle_gradient(ctx, rectangle, 1.0, true, pattern_rect,
|
||||||
&(d->fg[i]), d->pfg_center[i], d->pfg_end[i]);
|
&(d->fg[i]), d->pfg_center[i], d->pfg_end[i]);
|
||||||
else /* reverse: bg */
|
else /* reverse: bg */
|
||||||
draw_rectangle(ctx, rectangle, 1.0, True, d->fg_off[i]);
|
draw_rectangle(ctx, rectangle, 1.0, true, d->fg_off[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* right part */
|
/* right part */
|
||||||
|
@ -357,9 +357,9 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
|
|
||||||
/* bg color */
|
/* bg color */
|
||||||
if(!d->reverse[i])
|
if(!d->reverse[i])
|
||||||
draw_rectangle(ctx, rectangle, 1.0, True, d->fg_off[i]);
|
draw_rectangle(ctx, rectangle, 1.0, true, d->fg_off[i]);
|
||||||
else /* reverse: fg */
|
else /* reverse: fg */
|
||||||
draw_rectangle_gradient(ctx, rectangle, 1.0, True, pattern_rect,
|
draw_rectangle_gradient(ctx, rectangle, 1.0, true, pattern_rect,
|
||||||
&(d->fg[i]), d->pfg_center[i], d->pfg_end[i]);
|
&(d->fg[i]), d->pfg_center[i], d->pfg_end[i]);
|
||||||
}
|
}
|
||||||
/* draw gaps TODO: improve e.g all in one */
|
/* draw gaps TODO: improve e.g all in one */
|
||||||
|
@ -371,7 +371,7 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
for(rectangle.x = pb_x + (unit - d->ticks_gap);
|
for(rectangle.x = pb_x + (unit - d->ticks_gap);
|
||||||
pb_x + pb_width - d->ticks_gap >= rectangle.x;
|
pb_x + pb_width - d->ticks_gap >= rectangle.x;
|
||||||
rectangle.x += unit)
|
rectangle.x += unit)
|
||||||
draw_rectangle(ctx, rectangle, 1.0, True, d->bg[i]);
|
draw_rectangle(ctx, rectangle, 1.0, true, d->bg[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pb_offset += pb_height + d->gap + 2 * (d->border_width + d->border_padding);
|
pb_offset += pb_height + d->gap + 2 * (d->border_width + d->border_padding);
|
||||||
|
@ -475,7 +475,7 @@ progressbar_new(Statusbar *statusbar, cfg_t *config)
|
||||||
d->border_width = cfg_getint(config, "border_width");
|
d->border_width = cfg_getint(config, "border_width");
|
||||||
|
|
||||||
if(!(d->vertical = cfg_getbool(config, "vertical")))
|
if(!(d->vertical = cfg_getbool(config, "vertical")))
|
||||||
d->vertical = False;
|
d->vertical = false;
|
||||||
|
|
||||||
d->gap = cfg_getint(config, "gap");
|
d->gap = cfg_getint(config, "gap");
|
||||||
|
|
||||||
|
@ -493,14 +493,14 @@ progressbar_new(Statusbar *statusbar, cfg_t *config)
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->fg = p_new(XColor, d->data_items);
|
d->fg = p_new(xcolor_t, d->data_items);
|
||||||
d->pfg_end = p_new(XColor *, d->data_items);
|
d->pfg_end = p_new(xcolor_t *, d->data_items);
|
||||||
d->pfg_center = p_new(XColor *, d->data_items);
|
d->pfg_center = p_new(xcolor_t *, d->data_items);
|
||||||
d->fg_off = p_new(XColor, d->data_items);
|
d->fg_off = p_new(xcolor_t, d->data_items);
|
||||||
d->bg = p_new(XColor, d->data_items);
|
d->bg = p_new(xcolor_t, d->data_items);
|
||||||
d->bordercolor = p_new(XColor, d->data_items);
|
d->bordercolor = p_new(xcolor_t, d->data_items);
|
||||||
d->percent = p_new(int, d->data_items);
|
d->percent = p_new(int, d->data_items);
|
||||||
d->reverse = p_new(Bool, d->data_items);
|
d->reverse = p_new(bool, d->data_items);
|
||||||
d->data_title = p_new(char *, d->data_items);
|
d->data_title = p_new(char *, d->data_items);
|
||||||
|
|
||||||
for(i = 0; i < d->data_items; i++)
|
for(i = 0; i < d->data_items; i++)
|
||||||
|
@ -510,37 +510,37 @@ progressbar_new(Statusbar *statusbar, cfg_t *config)
|
||||||
d->data_title[i] = a_strdup(cfg_title(cfg));
|
d->data_title[i] = a_strdup(cfg_title(cfg));
|
||||||
|
|
||||||
if(!(d->reverse[i] = cfg_getbool(cfg, "reverse")))
|
if(!(d->reverse[i] = cfg_getbool(cfg, "reverse")))
|
||||||
d->reverse[i] = False;
|
d->reverse[i] = false;
|
||||||
|
|
||||||
if((color = cfg_getstr(cfg, "fg")))
|
if((color = cfg_getstr(cfg, "fg")))
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->fg[i]);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, &d->fg[i]);
|
||||||
else
|
else
|
||||||
d->fg[i] = globalconf.screens[statusbar->screen].styles.normal.fg;
|
d->fg[i] = globalconf.screens[statusbar->screen].styles.normal.fg;
|
||||||
|
|
||||||
if((color = cfg_getstr(cfg, "fg_center")))
|
if((color = cfg_getstr(cfg, "fg_center")))
|
||||||
{
|
{
|
||||||
d->pfg_center[i] = p_new(XColor, 1);
|
d->pfg_center[i] = p_new(xcolor_t, 1);
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, d->pfg_center[i]);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, d->pfg_center[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((color = cfg_getstr(cfg, "fg_end")))
|
if((color = cfg_getstr(cfg, "fg_end")))
|
||||||
{
|
{
|
||||||
d->pfg_end[i] = p_new(XColor, 1);
|
d->pfg_end[i] = p_new(xcolor_t, 1);
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, d->pfg_end[i]);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, d->pfg_end[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((color = cfg_getstr(cfg, "fg_off")))
|
if((color = cfg_getstr(cfg, "fg_off")))
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->fg_off[i]);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, &d->fg_off[i]);
|
||||||
else
|
else
|
||||||
d->fg_off[i] = globalconf.screens[statusbar->screen].styles.normal.bg;
|
d->fg_off[i] = globalconf.screens[statusbar->screen].styles.normal.bg;
|
||||||
|
|
||||||
if((color = cfg_getstr(cfg, "bg")))
|
if((color = cfg_getstr(cfg, "bg")))
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->bg[i]);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, &d->bg[i]);
|
||||||
else
|
else
|
||||||
d->bg[i] = globalconf.screens[statusbar->screen].styles.normal.bg;
|
d->bg[i] = globalconf.screens[statusbar->screen].styles.normal.bg;
|
||||||
|
|
||||||
if((color = cfg_getstr(cfg, "bordercolor")))
|
if((color = cfg_getstr(cfg, "bordercolor")))
|
||||||
draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->bordercolor[i]);
|
draw_color_new(globalconf.connection, statusbar->phys_screen, color, &d->bordercolor[i]);
|
||||||
else
|
else
|
||||||
d->bordercolor[i] = d->fg[i];
|
d->bordercolor[i] = d->fg[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,30 +33,30 @@ extern AwesomeConf globalconf;
|
||||||
* screen
|
* screen
|
||||||
* \param screen screen number
|
* \param screen screen number
|
||||||
* \param t tag
|
* \param t tag
|
||||||
* \return True or False
|
* \return true or false
|
||||||
*/
|
*/
|
||||||
static Bool
|
static bool
|
||||||
isoccupied(Tag *t)
|
isoccupied(Tag *t)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(is_client_tagged(c, t) && !c->skip && c != globalconf.scratch.client)
|
if(is_client_tagged(c, t) && !c->skip && c != globalconf.scratch.client)
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static bool
|
||||||
isurgent(Tag *t)
|
isurgent(Tag *t)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(is_client_tagged(c, t) && c->isurgent)
|
if(is_client_tagged(c, t) && c->isurgent)
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static style_t
|
static style_t
|
||||||
|
@ -90,7 +90,8 @@ taglist_draw(Widget *widget,
|
||||||
for(tag = vscreen.tags; tag; tag = tag->next)
|
for(tag = vscreen.tags; tag; tag = tag->next)
|
||||||
{
|
{
|
||||||
style = tag->selected ? vscreen.styles.focus : vscreen.styles.normal;
|
style = tag->selected ? vscreen.styles.focus : vscreen.styles.normal;
|
||||||
widget->area.width += draw_textwidth(ctx->display, style.font, tag->name)
|
widget->area.width += draw_textwidth(ctx->connection, ctx->default_screen,
|
||||||
|
style.font, tag->name)
|
||||||
+ style.font->height;
|
+ style.font->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +108,8 @@ taglist_draw(Widget *widget,
|
||||||
for(tag = vscreen.tags; tag; tag = tag->next)
|
for(tag = vscreen.tags; tag; tag = tag->next)
|
||||||
{
|
{
|
||||||
style = taglist_style_get(vscreen, tag);
|
style = taglist_style_get(vscreen, tag);
|
||||||
w = draw_textwidth(ctx->display, style.font, tag->name) + style.font->height;
|
w = draw_textwidth(ctx->connection, ctx->default_screen,
|
||||||
|
style.font, tag->name) + style.font->height;
|
||||||
area.x = widget->area.x + widget->area.width;
|
area.x = widget->area.x + widget->area.width;
|
||||||
area.y = widget->area.y;
|
area.y = widget->area.y;
|
||||||
area.width = w;
|
area.width = w;
|
||||||
|
@ -135,7 +137,7 @@ taglist_draw(Widget *widget,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
taglist_button_press(Widget *widget, xcb_button_press_event_t *ev)
|
||||||
{
|
{
|
||||||
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
|
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
|
||||||
Button *b;
|
Button *b;
|
||||||
|
@ -145,7 +147,7 @@ taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
style_t style;
|
style_t style;
|
||||||
|
|
||||||
for(b = widget->buttons; b; b = b->next)
|
for(b = widget->buttons; b; b = b->next)
|
||||||
if(ev->button == b->button && CLEANMASK(ev->state) == b->mod && b->func)
|
if(ev->detail == b->button && CLEANMASK(ev->state) == b->mod && b->func)
|
||||||
switch(widget->statusbar->position)
|
switch(widget->statusbar->position)
|
||||||
{
|
{
|
||||||
case Top:
|
case Top:
|
||||||
|
@ -153,10 +155,11 @@ taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
for(tag = vscreen.tags; tag; tag = tag->next, i++)
|
for(tag = vscreen.tags; tag; tag = tag->next, i++)
|
||||||
{
|
{
|
||||||
style = taglist_style_get(vscreen, tag);
|
style = taglist_style_get(vscreen, tag);
|
||||||
width = draw_textwidth(globalconf.display, style.font, tag->name)
|
width = draw_textwidth(globalconf.connection, globalconf.default_screen,
|
||||||
|
style.font, tag->name)
|
||||||
+ style.font->height;
|
+ style.font->height;
|
||||||
if(ev->x >= widget->area.x + prev_width
|
if(ev->event_x >= widget->area.x + prev_width
|
||||||
&& ev->x < widget->area.x + prev_width + width)
|
&& ev->event_x < widget->area.x + prev_width + width)
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "%d", i);
|
snprintf(buf, sizeof(buf), "%d", i);
|
||||||
b->func(widget->statusbar->screen, buf);
|
b->func(widget->statusbar->screen, buf);
|
||||||
|
@ -169,9 +172,10 @@ taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
for(tag = vscreen.tags; tag; tag = tag->next, i++)
|
for(tag = vscreen.tags; tag; tag = tag->next, i++)
|
||||||
{
|
{
|
||||||
style = taglist_style_get(vscreen, tag);
|
style = taglist_style_get(vscreen, tag);
|
||||||
width = draw_textwidth(globalconf.display, style.font, tag->name) + style.font->height;
|
width = draw_textwidth(globalconf.connection, globalconf.default_screen,
|
||||||
if(ev->y >= widget->area.x + prev_width
|
style.font, tag->name) + style.font->height;
|
||||||
&& ev->y < widget->area.x + prev_width + width)
|
if(ev->event_y >= widget->area.x + prev_width
|
||||||
|
&& ev->event_y < widget->area.x + prev_width + width)
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "%d", i);
|
snprintf(buf, sizeof(buf), "%d", i);
|
||||||
b->func(widget->statusbar->screen, buf);
|
b->func(widget->statusbar->screen, buf);
|
||||||
|
@ -184,9 +188,10 @@ taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
for(tag = vscreen.tags; tag; tag = tag->next, i++)
|
for(tag = vscreen.tags; tag; tag = tag->next, i++)
|
||||||
{
|
{
|
||||||
style = taglist_style_get(vscreen, tag);
|
style = taglist_style_get(vscreen, tag);
|
||||||
width = draw_textwidth(globalconf.display, style.font, tag->name) + style.font->height;
|
width = draw_textwidth(globalconf.connection, globalconf.default_screen,
|
||||||
if(widget->statusbar->width - ev->y >= widget->area.x + prev_width
|
style.font, tag->name) + style.font->height;
|
||||||
&& widget->statusbar->width - ev->y < widget->area.x + prev_width + width)
|
if(widget->statusbar->width - ev->event_y >= widget->area.x + prev_width
|
||||||
|
&& widget->statusbar->width - ev->event_y < widget->area.x + prev_width + width)
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "%d", i);
|
snprintf(buf, sizeof(buf), "%d", i);
|
||||||
b->func(widget->statusbar->screen, buf);
|
b->func(widget->statusbar->screen, buf);
|
||||||
|
|
|
@ -42,7 +42,7 @@ typedef enum
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
ShowClient show;
|
ShowClient show;
|
||||||
Bool show_icons;
|
bool show_icons;
|
||||||
Alignment align;
|
Alignment align;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -52,11 +52,11 @@ typedef struct
|
||||||
} styles;
|
} styles;
|
||||||
} Data;
|
} Data;
|
||||||
|
|
||||||
static inline Bool
|
static inline bool
|
||||||
tasklist_isvisible(Client *c, int screen, ShowClient show)
|
tasklist_isvisible(Client *c, int screen, ShowClient show)
|
||||||
{
|
{
|
||||||
if(c->skip || c->skiptb)
|
if(c->skip || c->skiptb)
|
||||||
return False;
|
return false;
|
||||||
|
|
||||||
switch(show)
|
switch(show)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ tasklist_isvisible(Client *c, int screen, ShowClient show)
|
||||||
case ShowFocus:
|
case ShowFocus:
|
||||||
return (c == focus_get_current_client(screen));
|
return (c == focus_get_current_client(screen));
|
||||||
}
|
}
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -124,7 +124,7 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
||||||
area.height = widget->statusbar->height;
|
area.height = widget->statusbar->height;
|
||||||
area.width = box_width;
|
area.width = box_width;
|
||||||
|
|
||||||
draw_rectangle(ctx, area, 1.0, True, style.bg);
|
draw_rectangle(ctx, area, 1.0, true, style.bg);
|
||||||
|
|
||||||
if((r = rule_matching_client(c)) && r->icon)
|
if((r = rule_matching_client(c)) && r->icon)
|
||||||
{
|
{
|
||||||
|
@ -190,7 +190,7 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
tasklist_button_press(Widget *widget, xcb_button_press_event_t *ev)
|
||||||
{
|
{
|
||||||
Button *b;
|
Button *b;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
@ -199,7 +199,7 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
int n = 0, box_width = 0, i, ci = 0;
|
int n = 0, box_width = 0, i, ci = 0;
|
||||||
|
|
||||||
/* button1 give focus */
|
/* button1 give focus */
|
||||||
if(ev->button == Button1 && CLEANMASK(ev->state) == NoSymbol)
|
if(ev->detail == XCB_BUTTON_INDEX_1 && CLEANMASK(ev->state) == XCB_NO_SYMBOL)
|
||||||
{
|
{
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(tasklist_isvisible(c, widget->statusbar->screen, d->show))
|
if(tasklist_isvisible(c, widget->statusbar->screen, d->show))
|
||||||
|
@ -210,19 +210,19 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
|
|
||||||
box_width = widget->area.width / n;
|
box_width = widget->area.width / n;
|
||||||
|
|
||||||
if(ev->button == Button1 && CLEANMASK(ev->state) == NoSymbol)
|
if(ev->detail == XCB_BUTTON_INDEX_1 && CLEANMASK(ev->state) == XCB_NO_SYMBOL)
|
||||||
{
|
{
|
||||||
switch(widget->statusbar->position)
|
switch(widget->statusbar->position)
|
||||||
{
|
{
|
||||||
case Top:
|
case Top:
|
||||||
case Bottom:
|
case Bottom:
|
||||||
ci = (ev->x - widget->area.x) / box_width;
|
ci = (ev->event_x - widget->area.x) / box_width;
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
ci = (ev->y - widget->area.x) / box_width;
|
ci = (ev->event_y - widget->area.x) / box_width;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ci = ((widget->statusbar->width - ev->y) - widget->area.x) / box_width;
|
ci = ((widget->statusbar->width - ev->event_y) - widget->area.x) / box_width;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* found first visible client */
|
/* found first visible client */
|
||||||
|
@ -242,7 +242,7 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
for(i = 0, tag = globalconf.screens[c->screen].tags; tag; tag = tag->next, i++)
|
for(i = 0, tag = globalconf.screens[c->screen].tags; tag; tag = tag->next, i++)
|
||||||
if(is_client_tagged(c, tag))
|
if(is_client_tagged(c, tag))
|
||||||
tag_view_only_byindex(c->screen, i);
|
tag_view_only_byindex(c->screen, i);
|
||||||
client_focus(c, widget->statusbar->screen, True);
|
client_focus(c, widget->statusbar->screen, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -250,7 +250,7 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
for(b = widget->buttons; b; b = b->next)
|
for(b = widget->buttons; b; b = b->next)
|
||||||
if(ev->button == b->button && CLEANMASK(ev->state) == b->mod && b->func)
|
if(ev->detail == b->button && CLEANMASK(ev->state) == b->mod && b->func)
|
||||||
{
|
{
|
||||||
b->func(widget->statusbar->screen, b->arg);
|
b->func(widget->statusbar->screen, b->arg);
|
||||||
return;
|
return;
|
||||||
|
@ -274,17 +274,17 @@ tasklist_new(Statusbar *statusbar, cfg_t *config)
|
||||||
|
|
||||||
cfg_styles = cfg_getsec(config, "styles");
|
cfg_styles = cfg_getsec(config, "styles");
|
||||||
|
|
||||||
draw_style_init(globalconf.display, statusbar->phys_screen,
|
draw_style_init(globalconf.connection, statusbar->phys_screen,
|
||||||
cfg_getsec(cfg_styles, "normal"),
|
cfg_getsec(cfg_styles, "normal"),
|
||||||
&d->styles.normal,
|
&d->styles.normal,
|
||||||
&globalconf.screens[statusbar->screen].styles.normal);
|
&globalconf.screens[statusbar->screen].styles.normal);
|
||||||
|
|
||||||
draw_style_init(globalconf.display, statusbar->phys_screen,
|
draw_style_init(globalconf.connection, statusbar->phys_screen,
|
||||||
cfg_getsec(cfg_styles, "focus"),
|
cfg_getsec(cfg_styles, "focus"),
|
||||||
&d->styles.focus,
|
&d->styles.focus,
|
||||||
&globalconf.screens[statusbar->screen].styles.focus);
|
&globalconf.screens[statusbar->screen].styles.focus);
|
||||||
|
|
||||||
draw_style_init(globalconf.display, statusbar->phys_screen,
|
draw_style_init(globalconf.connection, statusbar->phys_screen,
|
||||||
cfg_getsec(cfg_styles, "urgent"),
|
cfg_getsec(cfg_styles, "urgent"),
|
||||||
&d->styles.urgent,
|
&d->styles.urgent,
|
||||||
&globalconf.screens[statusbar->screen].styles.urgent);
|
&globalconf.screens[statusbar->screen].styles.urgent);
|
||||||
|
|
|
@ -44,7 +44,8 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
||||||
else if(widget->alignment == AlignFlex)
|
else if(widget->alignment == AlignFlex)
|
||||||
widget->area.width = widget->statusbar->width - used;
|
widget->area.width = widget->statusbar->width - used;
|
||||||
else
|
else
|
||||||
widget->area.width = MIN(draw_textwidth(ctx->display, d->style.font, d->text),
|
widget->area.width = MIN(draw_textwidth(ctx->connection, ctx->default_screen,
|
||||||
|
d->style.font, d->text),
|
||||||
widget->statusbar->width - used);
|
widget->statusbar->width - used);
|
||||||
|
|
||||||
widget->area.height = widget->statusbar->height;
|
widget->area.height = widget->statusbar->height;
|
||||||
|
@ -75,18 +76,18 @@ textbox_tell(Widget *widget, char *property, char *command)
|
||||||
d->text = a_strdup(command);
|
d->text = a_strdup(command);
|
||||||
}
|
}
|
||||||
else if(!a_strcmp(property, "fg"))
|
else if(!a_strcmp(property, "fg"))
|
||||||
if(draw_color_new(globalconf.display, widget->statusbar->screen, command, &d->style.fg))
|
if(draw_color_new(globalconf.connection, widget->statusbar->screen, command, &d->style.fg))
|
||||||
return WIDGET_NOERROR;
|
return WIDGET_NOERROR;
|
||||||
else
|
else
|
||||||
return WIDGET_ERROR_FORMAT_COLOR;
|
return WIDGET_ERROR_FORMAT_COLOR;
|
||||||
else if(!a_strcmp(property, "bg"))
|
else if(!a_strcmp(property, "bg"))
|
||||||
if(draw_color_new(globalconf.display, widget->statusbar->screen, command, &d->style.bg))
|
if(draw_color_new(globalconf.connection, widget->statusbar->screen, command, &d->style.bg))
|
||||||
return WIDGET_NOERROR;
|
return WIDGET_NOERROR;
|
||||||
else
|
else
|
||||||
return WIDGET_ERROR_FORMAT_COLOR;
|
return WIDGET_ERROR_FORMAT_COLOR;
|
||||||
else if(!a_strcmp(property, "font"))
|
else if(!a_strcmp(property, "font"))
|
||||||
{
|
{
|
||||||
if((newfont = draw_font_new(globalconf.display, command)))
|
if((newfont = draw_font_new(globalconf.connection, globalconf.default_screen, command)))
|
||||||
{
|
{
|
||||||
if(d->style.font != globalconf.screens[widget->statusbar->screen].styles.normal.font)
|
if(d->style.font != globalconf.screens[widget->statusbar->screen].styles.normal.font)
|
||||||
draw_font_delete(&d->style.font);
|
draw_font_delete(&d->style.font);
|
||||||
|
@ -119,7 +120,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
|
||||||
|
|
||||||
w->data = d = p_new(Data, 1);
|
w->data = d = p_new(Data, 1);
|
||||||
|
|
||||||
draw_style_init(globalconf.display, statusbar->phys_screen,
|
draw_style_init(globalconf.connection, statusbar->phys_screen,
|
||||||
cfg_getsec(config, "style"),
|
cfg_getsec(config, "style"),
|
||||||
&d->style,
|
&d->style,
|
||||||
&globalconf.screens[statusbar->screen].styles.normal);
|
&globalconf.screens[statusbar->screen].styles.normal);
|
||||||
|
|
201
window.c
201
window.c
|
@ -19,8 +19,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <X11/Xatom.h>
|
#include <xcb/xcb.h>
|
||||||
#include <X11/extensions/shape.h>
|
#include <xcb/xcb_atom.h>
|
||||||
|
#include <xcb/shape.h>
|
||||||
|
#include <xcb/xcb_keysyms.h>
|
||||||
|
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
@ -28,21 +30,22 @@
|
||||||
extern AwesomeConf globalconf;
|
extern AwesomeConf globalconf;
|
||||||
|
|
||||||
/** Mask shorthands */
|
/** Mask shorthands */
|
||||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
#define BUTTONMASK (XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE)
|
||||||
|
|
||||||
/** Set client WM_STATE property
|
/** Set client WM_STATE property
|
||||||
* \param win Window
|
* \param win Window
|
||||||
* \param state state
|
* \param state state
|
||||||
* \return XChangeProperty result
|
* \return XChangeProperty result
|
||||||
*/
|
*/
|
||||||
int
|
void
|
||||||
window_setstate(Window win, long state)
|
window_setstate(xcb_window_t win, long state)
|
||||||
{
|
{
|
||||||
long data[] = { state, None };
|
long data[] = { state, XCB_NONE };
|
||||||
|
|
||||||
return XChangeProperty(globalconf.display, win, XInternAtom(globalconf.display, "WM_STATE", False),
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, win,
|
||||||
XInternAtom(globalconf.display, "WM_STATE", False), 32,
|
x_intern_atom(globalconf.connection, "WM_STATE"),
|
||||||
PropModeReplace, (unsigned char *) data, 2);
|
x_intern_atom(globalconf.connection, "WM_STATE"), 32,
|
||||||
|
2, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a window state (WM_STATE)
|
/** Get a window state (WM_STATE)
|
||||||
|
@ -50,20 +53,27 @@ window_setstate(Window win, long state)
|
||||||
* \return state
|
* \return state
|
||||||
*/
|
*/
|
||||||
long
|
long
|
||||||
window_getstate(Window w)
|
window_getstate(xcb_window_t w)
|
||||||
{
|
{
|
||||||
int format;
|
|
||||||
long result = -1;
|
long result = -1;
|
||||||
unsigned char *p = NULL;
|
unsigned char *p = NULL;
|
||||||
unsigned long n, extra;
|
xcb_get_property_cookie_t prop_c;
|
||||||
Atom real;
|
xcb_atom_t wm_state_atom = x_intern_atom(globalconf.connection, "WM_STATE");
|
||||||
if(XGetWindowProperty(globalconf.display, w, XInternAtom(globalconf.display, "WM_STATE", False),
|
xcb_get_property_reply_t *prop_r;
|
||||||
0L, 2L, False, XInternAtom(globalconf.display, "WM_STATE", False),
|
|
||||||
&real, &format, &n, &extra, (unsigned char **) &p) != Success)
|
prop_c = xcb_get_property_unchecked(globalconf.connection, false, w,
|
||||||
|
wm_state_atom, wm_state_atom,
|
||||||
|
0L, 2L);
|
||||||
|
|
||||||
|
if((prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
if(n != 0)
|
|
||||||
|
p = xcb_get_property_value(prop_r);
|
||||||
|
if(xcb_get_property_value_length(prop_r) != 0)
|
||||||
result = *p;
|
result = *p;
|
||||||
p_delete(&p);
|
|
||||||
|
p_delete(&prop_r);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,13 +83,12 @@ window_getstate(Window w)
|
||||||
* \param border new border size
|
* \param border new border size
|
||||||
* \return the XSendEvent() status
|
* \return the XSendEvent() status
|
||||||
*/
|
*/
|
||||||
Status
|
void
|
||||||
window_configure(Window win, area_t geometry, int border)
|
window_configure(xcb_window_t win, area_t geometry, int border)
|
||||||
{
|
{
|
||||||
XConfigureEvent ce;
|
xcb_configure_notify_event_t ce;
|
||||||
|
|
||||||
ce.type = ConfigureNotify;
|
ce.response_type = XCB_CONFIGURE_NOTIFY;
|
||||||
ce.display = globalconf.display;
|
|
||||||
ce.event = win;
|
ce.event = win;
|
||||||
ce.window = win;
|
ce.window = win;
|
||||||
ce.x = geometry.x;
|
ce.x = geometry.x;
|
||||||
|
@ -87,9 +96,9 @@ window_configure(Window win, area_t geometry, int border)
|
||||||
ce.width = geometry.width;
|
ce.width = geometry.width;
|
||||||
ce.height = geometry.height;
|
ce.height = geometry.height;
|
||||||
ce.border_width = border;
|
ce.border_width = border;
|
||||||
ce.above = None;
|
ce.above_sibling = XCB_NONE;
|
||||||
ce.override_redirect = False;
|
ce.override_redirect = false;
|
||||||
return XSendEvent(globalconf.display, win, False, StructureNotifyMask, (XEvent *) & ce);
|
xcb_send_event(globalconf.connection, false, win, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (char *) &ce);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Grab or ungrab buttons on a window
|
/** Grab or ungrab buttons on a window
|
||||||
|
@ -97,32 +106,41 @@ window_configure(Window win, area_t geometry, int border)
|
||||||
* \param phys_screen Physical screen number
|
* \param phys_screen Physical screen number
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
window_grabbuttons(Window win, int phys_screen)
|
window_grabbuttons(xcb_window_t win, int phys_screen)
|
||||||
{
|
{
|
||||||
Button *b;
|
Button *b;
|
||||||
|
|
||||||
XGrabButton(globalconf.display, Button1, NoSymbol,
|
xcb_grab_button(globalconf.connection, false, win, BUTTONMASK,
|
||||||
win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None);
|
XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE,
|
||||||
XGrabButton(globalconf.display, Button1, NoSymbol | LockMask,
|
XCB_BUTTON_INDEX_1, XCB_NO_SYMBOL);
|
||||||
win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None);
|
xcb_grab_button(globalconf.connection, false, win, BUTTONMASK,
|
||||||
XGrabButton(globalconf.display, Button1, NoSymbol | globalconf.numlockmask,
|
XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE,
|
||||||
win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None);
|
XCB_BUTTON_INDEX_1, XCB_NO_SYMBOL | XCB_MOD_MASK_LOCK);
|
||||||
XGrabButton(globalconf.display, Button1, NoSymbol | globalconf.numlockmask | LockMask,
|
xcb_grab_button(globalconf.connection, false, win, BUTTONMASK,
|
||||||
win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None);
|
XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE,
|
||||||
|
XCB_BUTTON_INDEX_1, XCB_NO_SYMBOL | globalconf.numlockmask);
|
||||||
|
xcb_grab_button(globalconf.connection, false, win, BUTTONMASK,
|
||||||
|
XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE,
|
||||||
|
XCB_BUTTON_INDEX_1, XCB_NO_SYMBOL | globalconf.numlockmask | XCB_MOD_MASK_LOCK);
|
||||||
|
|
||||||
for(b = globalconf.buttons.client; b; b = b->next)
|
for(b = globalconf.buttons.client; b; b = b->next)
|
||||||
{
|
{
|
||||||
XGrabButton(globalconf.display, b->button, b->mod,
|
xcb_grab_button(globalconf.connection, false, win, BUTTONMASK,
|
||||||
win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
XGrabButton(globalconf.display, b->button, b->mod | LockMask,
|
b->button, b->mod);
|
||||||
win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
xcb_grab_button(globalconf.connection, false, win, BUTTONMASK,
|
||||||
XGrabButton(globalconf.display, b->button, b->mod | globalconf.numlockmask,
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
b->button, b->mod | XCB_MOD_MASK_LOCK);
|
||||||
XGrabButton(globalconf.display, b->button, b->mod | globalconf.numlockmask | LockMask,
|
xcb_grab_button(globalconf.connection, false, win, BUTTONMASK,
|
||||||
win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
|
b->button, b->mod | globalconf.numlockmask);
|
||||||
|
xcb_grab_button(globalconf.connection, false, win, BUTTONMASK,
|
||||||
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
|
b->button, b->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
XUngrabButton(globalconf.display, AnyButton, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
xcb_ungrab_button(globalconf.connection, XCB_BUTTON_INDEX_ANY,
|
||||||
|
root_window(globalconf.connection, phys_screen), ANY_MODIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Grab buttons on root window
|
/** Grab buttons on root window
|
||||||
|
@ -135,18 +153,22 @@ window_root_grabbuttons(int phys_screen)
|
||||||
|
|
||||||
for(b = globalconf.buttons.root; b; b = b->next)
|
for(b = globalconf.buttons.root; b; b = b->next)
|
||||||
{
|
{
|
||||||
XGrabButton(globalconf.display, b->button, b->mod,
|
xcb_grab_button(globalconf.connection, false,
|
||||||
RootWindow(globalconf.display, phys_screen), False, BUTTONMASK,
|
root_window(globalconf.connection, phys_screen), BUTTONMASK,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
XGrabButton(globalconf.display, b->button, b->mod | LockMask,
|
b->button, b->mod);
|
||||||
RootWindow(globalconf.display, phys_screen), False, BUTTONMASK,
|
xcb_grab_button(globalconf.connection, false,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
root_window(globalconf.connection, phys_screen), BUTTONMASK,
|
||||||
XGrabButton(globalconf.display, b->button, b->mod | globalconf.numlockmask,
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
RootWindow(globalconf.display, phys_screen), False, BUTTONMASK,
|
b->button, b->mod | XCB_MOD_MASK_LOCK);
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
xcb_grab_button(globalconf.connection, false,
|
||||||
XGrabButton(globalconf.display, b->button, b->mod | globalconf.numlockmask | LockMask,
|
root_window(globalconf.connection, phys_screen), BUTTONMASK,
|
||||||
RootWindow(globalconf.display, phys_screen), False, BUTTONMASK,
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
b->button, b->mod | globalconf.numlockmask);
|
||||||
|
xcb_grab_button(globalconf.connection, false,
|
||||||
|
root_window(globalconf.connection, phys_screen), BUTTONMASK,
|
||||||
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
|
b->button, b->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,56 +179,65 @@ void
|
||||||
window_root_grabkeys(int phys_screen)
|
window_root_grabkeys(int phys_screen)
|
||||||
{
|
{
|
||||||
Key *k;
|
Key *k;
|
||||||
KeyCode kc;
|
xcb_keycode_t kc;
|
||||||
|
xcb_key_symbols_t *keysyms;
|
||||||
|
|
||||||
XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
xcb_ungrab_key(globalconf.connection, ANY_KEY,
|
||||||
|
root_window(globalconf.connection, phys_screen), ANY_MODIFIER);
|
||||||
|
|
||||||
|
keysyms = xcb_key_symbols_alloc(globalconf.connection);
|
||||||
|
|
||||||
for(k = globalconf.keys; k; k = k->next)
|
for(k = globalconf.keys; k; k = k->next)
|
||||||
if((kc = k->keycode) || (k->keysym && (kc = XKeysymToKeycode(globalconf.display, k->keysym))))
|
if((kc = k->keycode) || (k->keysym && (kc = xcb_key_symbols_get_keycode(keysyms, k->keysym))))
|
||||||
{
|
{
|
||||||
XGrabKey(globalconf.display, kc, k->mod,
|
xcb_grab_key(globalconf.connection, true, root_window(globalconf.connection, phys_screen),
|
||||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
k->mod, kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
XGrabKey(globalconf.display, kc, k->mod | LockMask,
|
xcb_grab_key(globalconf.connection, true, root_window(globalconf.connection, phys_screen),
|
||||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
k->mod | XCB_MOD_MASK_LOCK, kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
XGrabKey(globalconf.display, kc, k->mod | globalconf.numlockmask,
|
xcb_grab_key(globalconf.connection, true, root_window(globalconf.connection, phys_screen),
|
||||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
k->mod | globalconf.numlockmask, kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
XGrabKey(globalconf.display, kc, k->mod | globalconf.numlockmask | LockMask,
|
xcb_grab_key(globalconf.connection, true, root_window(globalconf.connection, phys_screen),
|
||||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
k->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK, kc, XCB_GRAB_MODE_ASYNC,
|
||||||
|
XCB_GRAB_MODE_ASYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xcb_key_symbols_free(keysyms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_setshape(Window win, int phys_screen)
|
window_setshape(xcb_window_t win, int phys_screen)
|
||||||
{
|
{
|
||||||
int bounding_shaped, i, b;
|
xcb_shape_query_extents_reply_t *r;
|
||||||
unsigned int u; /* dummies */
|
|
||||||
|
|
||||||
/* Logic to decide if we have a shaped window cribbed from fvwm-2.5.10. */
|
/* Logic to decide if we have a shaped window cribbed from fvwm-2.5.10. */
|
||||||
if(XShapeQueryExtents(globalconf.display, win, &bounding_shaped, &i, &i,
|
if((r = xcb_shape_query_extents_reply(globalconf.connection,
|
||||||
&u, &u, &b, &i, &i, &u, &u) && bounding_shaped)
|
xcb_shape_query_extents_unchecked(globalconf.connection, win),
|
||||||
XShapeCombineShape(globalconf.display,
|
NULL)) && r->bounding_shaped)
|
||||||
RootWindow(globalconf.display, phys_screen),
|
{
|
||||||
ShapeBounding, 0, 0, win, ShapeBounding, ShapeSet);
|
xcb_shape_combine(globalconf.connection, XCB_SHAPE_SO_SET,
|
||||||
|
XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING,
|
||||||
|
root_window(globalconf.connection, phys_screen),
|
||||||
|
0, 0, win);
|
||||||
|
|
||||||
|
p_delete(&r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
window_settrans(Window win, double opacity)
|
window_settrans(xcb_window_t win, double opacity)
|
||||||
{
|
{
|
||||||
int status;
|
|
||||||
unsigned int real_opacity = 0xffffffff;
|
unsigned int real_opacity = 0xffffffff;
|
||||||
|
|
||||||
if(opacity >= 0 && opacity <= 1)
|
if(opacity >= 0 && opacity <= 1)
|
||||||
{
|
{
|
||||||
real_opacity = opacity * 0xffffffff;
|
real_opacity = opacity * 0xffffffff;
|
||||||
status = XChangeProperty(globalconf.display, win,
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, win,
|
||||||
XInternAtom(globalconf.display, "_NET_WM_WINDOW_OPACITY", False),
|
x_intern_atom(globalconf.connection, "_NET_WM_WINDOW_OPACITY"),
|
||||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &real_opacity, 1L);
|
CARDINAL, 32, 1L, &real_opacity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
status = XDeleteProperty(globalconf.display, win,
|
xcb_delete_property(globalconf.connection, win,
|
||||||
XInternAtom(globalconf.display, "_NET_WM_WINDOW_OPACITY", False));
|
x_intern_atom(globalconf.connection, "_NET_WM_WINDOW_OPACITY"));
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
12
window.h
12
window.h
|
@ -24,14 +24,14 @@
|
||||||
|
|
||||||
#include "common/draw.h"
|
#include "common/draw.h"
|
||||||
|
|
||||||
int window_setstate(Window, long);
|
void window_setstate(xcb_window_t, long);
|
||||||
long window_getstate(Window);
|
long window_getstate(xcb_window_t);
|
||||||
Status window_configure(Window, area_t, int);
|
void window_configure(xcb_window_t, area_t, int);
|
||||||
void window_grabbuttons(Window, int);
|
void window_grabbuttons(xcb_window_t, int);
|
||||||
void window_root_grabbuttons(int);
|
void window_root_grabbuttons(int);
|
||||||
void window_root_grabkeys(int);
|
void window_root_grabkeys(int);
|
||||||
void window_setshape(Window, int);
|
void window_setshape(xcb_window_t, int);
|
||||||
int window_settrans(Window, double);
|
void window_settrans(xcb_window_t, double);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// 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
|
||||||
|
|
|
@ -0,0 +1,192 @@
|
||||||
|
/*
|
||||||
|
* xcb_event_handler.c - xcb event handler
|
||||||
|
*
|
||||||
|
* Copyright © 2007-2008 Arnaud Fontaine <arnaud@andesi.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "xcb_event_handler.h"
|
||||||
|
#include "common/util.h"
|
||||||
|
|
||||||
|
const char *x_label_error[] =
|
||||||
|
{
|
||||||
|
"Success",
|
||||||
|
"BadRequest",
|
||||||
|
"BadValue",
|
||||||
|
"BadWindow",
|
||||||
|
"BadPixmap",
|
||||||
|
"BadAtom",
|
||||||
|
"BadCursor",
|
||||||
|
"BadFont",
|
||||||
|
"BadMatch",
|
||||||
|
"BadDrawable",
|
||||||
|
"BadAccess",
|
||||||
|
"BadAlloc",
|
||||||
|
"BadColor",
|
||||||
|
"BadGC",
|
||||||
|
"BadIDChoice",
|
||||||
|
"BadName",
|
||||||
|
"BadLength",
|
||||||
|
"BadImplementation",
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *x_label_request[] =
|
||||||
|
{
|
||||||
|
"XCB_NONE",
|
||||||
|
"CreateWindow",
|
||||||
|
"ChangeWindowAttributes",
|
||||||
|
"GetWindowAttributes",
|
||||||
|
"DestroyWindow",
|
||||||
|
"DestroySubwindows",
|
||||||
|
"ChangeSaveSet",
|
||||||
|
"ReparentWindow",
|
||||||
|
"MapWindow",
|
||||||
|
"MapSubwindows",
|
||||||
|
"UnmapWindow",
|
||||||
|
"UnmapSubwindows",
|
||||||
|
"ConfigureWindow",
|
||||||
|
"CirculateWindow",
|
||||||
|
"GetGeometry",
|
||||||
|
"QueryTree",
|
||||||
|
"InternAtom",
|
||||||
|
"GetAtomName",
|
||||||
|
"ChangeProperty",
|
||||||
|
"DeleteProperty",
|
||||||
|
"GetProperty",
|
||||||
|
"ListProperties",
|
||||||
|
"SetSelectionOwner",
|
||||||
|
"GetSelectionOwner",
|
||||||
|
"ConvertSelection",
|
||||||
|
"SendEvent",
|
||||||
|
"GrabPointer",
|
||||||
|
"UngrabPointer",
|
||||||
|
"GrabButton",
|
||||||
|
"UngrabButton",
|
||||||
|
"ChangeActivePointerGrab",
|
||||||
|
"GrabKeyboard",
|
||||||
|
"UngrabKeyboard",
|
||||||
|
"GrabKey",
|
||||||
|
"UngrabKey",
|
||||||
|
"AllowEvents",
|
||||||
|
"GrabServer",
|
||||||
|
"UngrabServer",
|
||||||
|
"QueryPointer",
|
||||||
|
"GetMotionEvents",
|
||||||
|
"TranslateCoords",
|
||||||
|
"WarpPointer",
|
||||||
|
"SetInputFocus",
|
||||||
|
"GetInputFocus",
|
||||||
|
"QueryKeymap",
|
||||||
|
"OpenFont",
|
||||||
|
"CloseFont",
|
||||||
|
"QueryFont",
|
||||||
|
"QueryTextExtents",
|
||||||
|
"ListFonts",
|
||||||
|
"ListFontsWithInfo",
|
||||||
|
"SetFontPath",
|
||||||
|
"GetFontPath",
|
||||||
|
"CreatePixmap",
|
||||||
|
"FreePixmap",
|
||||||
|
"CreateGC",
|
||||||
|
"ChangeGC",
|
||||||
|
"CopyGC",
|
||||||
|
"SetDashes",
|
||||||
|
"SetClipRectangles",
|
||||||
|
"FreeGC",
|
||||||
|
"ClearArea",
|
||||||
|
"CopyArea",
|
||||||
|
"CopyPlane",
|
||||||
|
"PolyPoint",
|
||||||
|
"PolyLine",
|
||||||
|
"PolySegment",
|
||||||
|
"PolyRectangle",
|
||||||
|
"PolyArc",
|
||||||
|
"FillPoly",
|
||||||
|
"PolyFillRectangle",
|
||||||
|
"PolyFillArc",
|
||||||
|
"PutImage",
|
||||||
|
"GetImage",
|
||||||
|
"PolyText",
|
||||||
|
"PolyText",
|
||||||
|
"ImageText",
|
||||||
|
"ImageText",
|
||||||
|
"CreateColormap",
|
||||||
|
"FreeColormap",
|
||||||
|
"CopyColormapAndFree",
|
||||||
|
"InstallColormap",
|
||||||
|
"UninstallColormap",
|
||||||
|
"ListInstalledColormaps",
|
||||||
|
"AllocColor",
|
||||||
|
"AllocNamedColor",
|
||||||
|
"AllocColorCells",
|
||||||
|
"AllocColorPlanes",
|
||||||
|
"FreeColors",
|
||||||
|
"StoreColors",
|
||||||
|
"StoreNamedColor",
|
||||||
|
"QueryColors",
|
||||||
|
"LookupColor",
|
||||||
|
"CreateCursor",
|
||||||
|
"CreateGlyphCursor",
|
||||||
|
"FreeCursor",
|
||||||
|
"RecolorCursor",
|
||||||
|
"QueryBestSize",
|
||||||
|
"QueryExtension",
|
||||||
|
"ListExtensions",
|
||||||
|
"ChangeKeyboardMapping",
|
||||||
|
"GetKeyboardMapping",
|
||||||
|
"ChangeKeyboardControl",
|
||||||
|
"GetKeyboardControl",
|
||||||
|
"Bell",
|
||||||
|
"ChangePointerControl",
|
||||||
|
"GetPointerControl",
|
||||||
|
"SetScreenSaver",
|
||||||
|
"GetScreenSaver",
|
||||||
|
"ChangeHosts",
|
||||||
|
"ListHosts",
|
||||||
|
"SetAccessControl",
|
||||||
|
"SetCloseDownMode",
|
||||||
|
"KillClient",
|
||||||
|
"RotateProperties",
|
||||||
|
"ForceScreenSaver",
|
||||||
|
"SetPointerMapping",
|
||||||
|
"GetPointerMapping",
|
||||||
|
"SetModifierMapping",
|
||||||
|
"GetModifierMapping",
|
||||||
|
"major 120",
|
||||||
|
"major 121",
|
||||||
|
"major 122",
|
||||||
|
"major 123",
|
||||||
|
"major 124",
|
||||||
|
"major 125",
|
||||||
|
"major 126",
|
||||||
|
"NoOperation",
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Set the same handler for all errors
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xcb_set_error_handler_catch_all(xcb_event_handlers_t *evenths,
|
||||||
|
xcb_generic_error_handler_t handler,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
int err_num;
|
||||||
|
for(err_num = 0; err_num < ERRORS_NBR; err_num++)
|
||||||
|
xcb_set_error_handler(evenths, err_num, handler, data);
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* xcb_event_handler.c - xcb event handler header
|
||||||
|
*
|
||||||
|
* Copyright © 2007-2008 Arnaud Fontaine <arnaud@andesi.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XCB_EVENT_HANDLER_H
|
||||||
|
#define XCB_EVENT_HANDLER_H
|
||||||
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_event.h>
|
||||||
|
|
||||||
|
/* Set the same handler for all errors */
|
||||||
|
void xcb_set_error_handler_catch_all(xcb_event_handlers_t *,
|
||||||
|
xcb_generic_error_handler_t,
|
||||||
|
void *);
|
||||||
|
|
||||||
|
/* Number of different errors */
|
||||||
|
#define ERRORS_NBR 256
|
||||||
|
|
||||||
|
/* Number of different events */
|
||||||
|
#define EVENTS_NBR 126
|
||||||
|
|
||||||
|
/* Get the error name from its code */
|
||||||
|
extern const char *x_label_error[];
|
||||||
|
|
||||||
|
/* Get a request name from its code */
|
||||||
|
extern const char *x_label_request[];
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue