wibox: merge statusbar and titlebar types
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
24d6341c39
commit
34fe130307
|
@ -55,6 +55,7 @@ set(AWE_SRCS
|
|||
${SOURCE_DIR}/screen.c
|
||||
${SOURCE_DIR}/stack.c
|
||||
${SOURCE_DIR}/statusbar.c
|
||||
${SOURCE_DIR}/wibox.c
|
||||
${SOURCE_DIR}/systray.c
|
||||
${SOURCE_DIR}/tag.c
|
||||
${SOURCE_DIR}/titlebar.c
|
||||
|
|
13
client.c
13
client.c
|
@ -36,6 +36,7 @@
|
|||
#include "mouse.h"
|
||||
#include "systray.h"
|
||||
#include "statusbar.h"
|
||||
#include "wibox.h"
|
||||
#include "property.h"
|
||||
#include "layouts/floating.h"
|
||||
#include "common/markup.h"
|
||||
|
@ -333,7 +334,7 @@ client_stack(void)
|
|||
for(screen = 0; screen < globalconf.nscreen; screen++)
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *sb = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *sb = globalconf.screens[screen].statusbars.tab[i];
|
||||
xcb_configure_window(globalconf.connection,
|
||||
sb->sw.window,
|
||||
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
||||
|
@ -818,7 +819,7 @@ client_unmanage(client_t *c)
|
|||
if(c->titlebar)
|
||||
{
|
||||
xcb_unmap_window(globalconf.connection, c->titlebar->sw.window);
|
||||
titlebar_unref(&c->titlebar);
|
||||
wibox_unref(&c->titlebar);
|
||||
c->titlebar = NULL;
|
||||
}
|
||||
|
||||
|
@ -833,7 +834,7 @@ client_unmanage(client_t *c)
|
|||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
statusbar_position_update(s);
|
||||
}
|
||||
|
||||
|
@ -1202,7 +1203,7 @@ luaA_client_newindex(lua_State *L)
|
|||
bool b;
|
||||
double d;
|
||||
int i;
|
||||
titlebar_t **t = NULL;
|
||||
wibox_t **t = NULL;
|
||||
image_t **image;
|
||||
|
||||
if((*c)->invalid)
|
||||
|
@ -1291,7 +1292,7 @@ luaA_client_newindex(lua_State *L)
|
|||
if((*c)->titlebar)
|
||||
{
|
||||
xcb_unmap_window(globalconf.connection, (*c)->titlebar->sw.window);
|
||||
titlebar_unref(&(*c)->titlebar);
|
||||
wibox_unref(&(*c)->titlebar);
|
||||
(*c)->titlebar = NULL;
|
||||
client_need_arrange(*c);
|
||||
}
|
||||
|
@ -1299,7 +1300,7 @@ luaA_client_newindex(lua_State *L)
|
|||
if(t)
|
||||
{
|
||||
/* Attach titlebar to client */
|
||||
(*c)->titlebar = titlebar_ref(t);
|
||||
(*c)->titlebar = wibox_ref(t);
|
||||
titlebar_init(*c);
|
||||
}
|
||||
client_stack();
|
||||
|
|
10
event.c
10
event.c
|
@ -140,7 +140,7 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e
|
|||
for(screen = 0; screen < globalconf.nscreen; screen++)
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *statusbar = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *statusbar = globalconf.screens[screen].statusbars.tab[i];
|
||||
if(statusbar->sw.window == ev->event || statusbar->sw.window == ev->child)
|
||||
{
|
||||
/* If the statusbar is child, then x,y are
|
||||
|
@ -225,7 +225,7 @@ event_handle_configurerequest(void *data __attribute__ ((unused)),
|
|||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
statusbar_position_update(s);
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ event_handle_motionnotify(void *data __attribute__ ((unused)),
|
|||
xcb_connection_t *connection,
|
||||
xcb_motion_notify_event_t *ev)
|
||||
{
|
||||
statusbar_t *statusbar = statusbar_getbywin(ev->event);
|
||||
wibox_t *statusbar = statusbar_getbywin(ev->event);
|
||||
client_t *c;
|
||||
widget_node_t *w;
|
||||
|
||||
|
@ -419,7 +419,7 @@ event_handle_leavenotify(void *data __attribute__ ((unused)),
|
|||
xcb_connection_t *connection,
|
||||
xcb_leave_notify_event_t *ev)
|
||||
{
|
||||
statusbar_t *statusbar = statusbar_getbywin(ev->event);
|
||||
wibox_t *statusbar = statusbar_getbywin(ev->event);
|
||||
client_t *c;
|
||||
|
||||
if(statusbar)
|
||||
|
@ -500,7 +500,7 @@ event_handle_expose(void *data __attribute__ ((unused)),
|
|||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *statusbar = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *statusbar = globalconf.screens[screen].statusbars.tab[i];
|
||||
if(statusbar->sw.window == ev->window)
|
||||
{
|
||||
simplewindow_refresh_pixmap_partial(&statusbar->sw,
|
||||
|
|
2
ewmh.c
2
ewmh.c
|
@ -536,7 +536,7 @@ ewmh_client_strut_update(client_t *c, xcb_get_property_reply_t *strut_r)
|
|||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
statusbar_position_update(s);
|
||||
}
|
||||
}
|
||||
|
|
8
screen.c
8
screen.c
|
@ -162,7 +162,7 @@ screen_getbycoord(int screen, int x, int y)
|
|||
* \return The screen area.
|
||||
*/
|
||||
area_t
|
||||
screen_area_get(int screen, statusbar_array_t *statusbars,
|
||||
screen_area_get(int screen, wibox_array_t *statusbars,
|
||||
padding_t *padding, bool strut)
|
||||
{
|
||||
area_t area = globalconf.screens[screen].geometry;
|
||||
|
@ -218,7 +218,7 @@ screen_area_get(int screen, statusbar_array_t *statusbars,
|
|||
if(statusbars)
|
||||
for(int i = 0; i < statusbars->len; i++)
|
||||
{
|
||||
statusbar_t *sb = statusbars->tab[i];
|
||||
wibox_t *sb = statusbars->tab[i];
|
||||
switch(sb->position)
|
||||
{
|
||||
case Top:
|
||||
|
@ -253,7 +253,7 @@ screen_area_get(int screen, statusbar_array_t *statusbars,
|
|||
* \return The display area.
|
||||
*/
|
||||
area_t
|
||||
display_area_get(int phys_screen, statusbar_array_t *statusbars, padding_t *padding)
|
||||
display_area_get(int phys_screen, wibox_array_t *statusbars, padding_t *padding)
|
||||
{
|
||||
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
|
||||
area_t area = { .x = 0,
|
||||
|
@ -264,7 +264,7 @@ display_area_get(int phys_screen, statusbar_array_t *statusbars, padding_t *padd
|
|||
if(statusbars)
|
||||
for(int i = 0; i < statusbars->len; i++)
|
||||
{
|
||||
statusbar_t *sb = statusbars->tab[i];
|
||||
wibox_t *sb = statusbars->tab[i];
|
||||
area.y += sb->position == Top ? sb->height : 0;
|
||||
area.height -= (sb->position == Top || sb->position == Bottom) ? sb->height : 0;
|
||||
}
|
||||
|
|
4
screen.h
4
screen.h
|
@ -28,8 +28,8 @@
|
|||
|
||||
void screen_scan(void);
|
||||
int screen_getbycoord(int, int, int);
|
||||
area_t screen_area_get(int, statusbar_array_t *, padding_t *, bool);
|
||||
area_t display_area_get(int, statusbar_array_t *, padding_t *);
|
||||
area_t screen_area_get(int, wibox_array_t *, padding_t *, bool);
|
||||
area_t display_area_get(int, wibox_array_t *, padding_t *);
|
||||
int screen_virttophys(int);
|
||||
void screen_client_moveto(client_t *, int, bool, bool);
|
||||
|
||||
|
|
50
statusbar.c
50
statusbar.c
|
@ -25,13 +25,14 @@
|
|||
#include "statusbar.h"
|
||||
#include "screen.h"
|
||||
#include "widget.h"
|
||||
#include "wibox.h"
|
||||
#include "ewmh.h"
|
||||
|
||||
extern awesome_t globalconf;
|
||||
|
||||
DO_LUA_NEW(extern, statusbar_t, statusbar, "statusbar", statusbar_ref)
|
||||
DO_LUA_GC(statusbar_t, statusbar, "statusbar", statusbar_unref)
|
||||
DO_LUA_EQ(statusbar_t, statusbar, "statusbar")
|
||||
DO_LUA_NEW(extern, wibox_t, statusbar, "statusbar", wibox_ref)
|
||||
DO_LUA_GC(wibox_t, statusbar, "statusbar", wibox_unref)
|
||||
DO_LUA_EQ(wibox_t, statusbar, "statusbar")
|
||||
|
||||
/** Kick out systray windows.
|
||||
* \param phys_screen Physical screen number.
|
||||
|
@ -52,7 +53,7 @@ statusbar_systray_kickout(int phys_screen)
|
|||
}
|
||||
|
||||
static void
|
||||
statusbar_systray_refresh(statusbar_t *statusbar)
|
||||
statusbar_systray_refresh(wibox_t *statusbar)
|
||||
{
|
||||
widget_node_t *systray;
|
||||
|
||||
|
@ -215,7 +216,7 @@ statusbar_systray_refresh(statusbar_t *statusbar)
|
|||
* \param statusbar The statusbar to draw.
|
||||
*/
|
||||
static void
|
||||
statusbar_draw(statusbar_t *statusbar)
|
||||
statusbar_draw(wibox_t *statusbar)
|
||||
{
|
||||
statusbar->need_update = false;
|
||||
|
||||
|
@ -236,13 +237,13 @@ statusbar_draw(statusbar_t *statusbar)
|
|||
* \param w The window id.
|
||||
* \return A statusbar if found, NULL otherwise.
|
||||
*/
|
||||
statusbar_t *
|
||||
wibox_t *
|
||||
statusbar_getbywin(xcb_window_t w)
|
||||
{
|
||||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
if(s->sw.window == w)
|
||||
return s;
|
||||
}
|
||||
|
@ -257,7 +258,7 @@ statusbar_refresh(void)
|
|||
for(int screen = 0; screen < globalconf.nscreen; screen++)
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
if(s->need_update)
|
||||
statusbar_draw(s);
|
||||
}
|
||||
|
@ -268,7 +269,7 @@ statusbar_refresh(void)
|
|||
* \param statusbar The statusbar.
|
||||
*/
|
||||
void
|
||||
statusbar_position_update(statusbar_t *statusbar)
|
||||
statusbar_position_update(wibox_t *statusbar)
|
||||
{
|
||||
area_t area, wingeometry;
|
||||
bool ignore = false;
|
||||
|
@ -284,10 +285,10 @@ statusbar_position_update(statusbar_t *statusbar)
|
|||
area = screen_area_get(statusbar->screen, NULL,
|
||||
&globalconf.screens[statusbar->screen].padding, true);
|
||||
|
||||
/* Top and Bottom statusbar_t have prio */
|
||||
/* Top and Bottom wibox_t have prio */
|
||||
for(int i = 0; i < globalconf.screens[statusbar->screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *sb = globalconf.screens[statusbar->screen].statusbars.tab[i];
|
||||
wibox_t *sb = globalconf.screens[statusbar->screen].statusbars.tab[i];
|
||||
/* Ignore every statusbar after me that is in the same position */
|
||||
if(statusbar == sb)
|
||||
{
|
||||
|
@ -482,7 +483,7 @@ statusbar_position_update(statusbar_t *statusbar)
|
|||
static int
|
||||
luaA_statusbar_tostring(lua_State *L)
|
||||
{
|
||||
statusbar_t **p = luaA_checkudata(L, 1, "statusbar");
|
||||
wibox_t **p = luaA_checkudata(L, 1, "statusbar");
|
||||
lua_pushfstring(L, "[statusbar udata(%p) name(%s)]", *p, (*p)->name);
|
||||
return 1;
|
||||
}
|
||||
|
@ -498,7 +499,7 @@ luaA_statusbar_tostring(lua_State *L)
|
|||
static int
|
||||
luaA_statusbar_new(lua_State *L)
|
||||
{
|
||||
statusbar_t *sb;
|
||||
wibox_t *sb;
|
||||
const char *buf;
|
||||
size_t len;
|
||||
xcolor_init_request_t reqs[2];
|
||||
|
@ -509,7 +510,7 @@ luaA_statusbar_new(lua_State *L)
|
|||
if(!(buf = luaA_getopt_string(L, 2, "name", NULL)))
|
||||
luaL_error(L, "object statusbar must have a name");
|
||||
|
||||
sb = p_new(statusbar_t, 1);
|
||||
sb = p_new(wibox_t, 1);
|
||||
|
||||
sb->name = a_strdup(buf);
|
||||
|
||||
|
@ -555,7 +556,7 @@ static int
|
|||
luaA_statusbar_index(lua_State *L)
|
||||
{
|
||||
size_t len;
|
||||
statusbar_t **statusbar = luaA_checkudata(L, 1, "statusbar");
|
||||
wibox_t **statusbar = luaA_checkudata(L, 1, "statusbar");
|
||||
const char *attr = luaL_checklstring(L, 2, &len);
|
||||
|
||||
if(luaA_usemetatable(L, 1, 2))
|
||||
|
@ -597,7 +598,7 @@ luaA_statusbar_index(lua_State *L)
|
|||
static int
|
||||
luaA_statusbar_widgets(lua_State *L)
|
||||
{
|
||||
statusbar_t **statusbar = luaA_checkudata(L, 1, "statusbar");
|
||||
wibox_t **statusbar = luaA_checkudata(L, 1, "statusbar");
|
||||
|
||||
if(lua_gettop(L) == 2)
|
||||
{
|
||||
|
@ -613,7 +614,7 @@ luaA_statusbar_widgets(lua_State *L)
|
|||
* \param statusbar Statusbar to detach from screen.
|
||||
*/
|
||||
static void
|
||||
statusbar_remove(statusbar_t *statusbar)
|
||||
statusbar_remove(wibox_t *statusbar)
|
||||
{
|
||||
if(statusbar->screen != SCREEN_UNDEF)
|
||||
{
|
||||
|
@ -633,12 +634,12 @@ statusbar_remove(statusbar_t *statusbar)
|
|||
for(int i = 0; i < globalconf.screens[statusbar->screen].statusbars.len; i++)
|
||||
if(globalconf.screens[statusbar->screen].statusbars.tab[i] == statusbar)
|
||||
{
|
||||
statusbar_array_take(&globalconf.screens[statusbar->screen].statusbars, i);
|
||||
wibox_array_take(&globalconf.screens[statusbar->screen].statusbars, i);
|
||||
break;
|
||||
}
|
||||
globalconf.screens[statusbar->screen].need_arrange = true;
|
||||
statusbar->screen = SCREEN_UNDEF;
|
||||
statusbar_unref(&statusbar);
|
||||
wibox_unref(&statusbar);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -650,7 +651,7 @@ static int
|
|||
luaA_statusbar_newindex(lua_State *L)
|
||||
{
|
||||
size_t len;
|
||||
statusbar_t **statusbar = luaA_checkudata(L, 1, "statusbar");
|
||||
wibox_t **statusbar = luaA_checkudata(L, 1, "statusbar");
|
||||
const char *buf, *attr = luaL_checklstring(L, 2, &len);
|
||||
position_t p;
|
||||
int screen;
|
||||
|
@ -673,7 +674,7 @@ luaA_statusbar_newindex(lua_State *L)
|
|||
/* Check for uniq name and id. */
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
if(!a_strcmp(s->name, (*statusbar)->name))
|
||||
luaL_error(L, "a statusbar with that name is already on screen %d\n",
|
||||
screen + 1);
|
||||
|
@ -683,13 +684,12 @@ luaA_statusbar_newindex(lua_State *L)
|
|||
|
||||
(*statusbar)->screen = screen;
|
||||
|
||||
statusbar_array_append(&globalconf.screens[screen].statusbars, *statusbar);
|
||||
statusbar_ref(statusbar);
|
||||
wibox_array_append(&globalconf.screens[screen].statusbars, wibox_ref(statusbar));
|
||||
|
||||
/* All the other statusbar and ourselves need to be repositioned */
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *s = globalconf.screens[screen].statusbars.tab[i];
|
||||
statusbar_position_update(s);
|
||||
}
|
||||
|
||||
|
@ -729,7 +729,7 @@ luaA_statusbar_newindex(lua_State *L)
|
|||
{
|
||||
for(int i = 0; i < globalconf.screens[(*statusbar)->screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *s = globalconf.screens[(*statusbar)->screen].statusbars.tab[i];
|
||||
wibox_t *s = globalconf.screens[(*statusbar)->screen].statusbars.tab[i];
|
||||
statusbar_position_update(s);
|
||||
}
|
||||
ewmh_update_workarea(screen_virttophys((*statusbar)->screen));
|
||||
|
|
24
statusbar.h
24
statusbar.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* statusbar.h - statusbar functions header
|
||||
* wibox.h - wibox functions header
|
||||
*
|
||||
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
||||
*
|
||||
|
@ -19,30 +19,18 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef AWESOME_STATUSBAR_H
|
||||
#define AWESOME_STATUSBAR_H
|
||||
#ifndef AWESOME_WIBOX_H
|
||||
#define AWESOME_WIBOX_H
|
||||
|
||||
#include "structs.h"
|
||||
#include "swindow.h"
|
||||
#include "common/refcount.h"
|
||||
|
||||
static inline void
|
||||
statusbar_delete(statusbar_t **statusbar)
|
||||
{
|
||||
simplewindow_wipe(&(*statusbar)->sw);
|
||||
widget_node_list_wipe(&(*statusbar)->widgets);
|
||||
p_delete(&(*statusbar)->name);
|
||||
p_delete(statusbar);
|
||||
}
|
||||
|
||||
statusbar_t * statusbar_getbywin(xcb_window_t);
|
||||
wibox_t * statusbar_getbywin(xcb_window_t);
|
||||
void statusbar_refresh(void);
|
||||
void statusbar_position_update(statusbar_t *);
|
||||
void statusbar_position_update(wibox_t *);
|
||||
|
||||
int luaA_statusbar_userdata_new(lua_State *, statusbar_t *);
|
||||
|
||||
DO_RCNT(statusbar_t, statusbar, statusbar_delete)
|
||||
ARRAY_FUNCS(statusbar_t *, statusbar, statusbar_unref)
|
||||
int luaA_statusbar_userdata_new(lua_State *, wibox_t *);
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
125
structs.h
125
structs.h
|
@ -69,9 +69,7 @@ enum
|
|||
typedef struct button_t button_t;
|
||||
typedef struct widget_t widget_t;
|
||||
typedef struct widget_node_t widget_node_t;
|
||||
typedef struct statusbar_t statusbar_t;
|
||||
typedef struct client_t client_t;
|
||||
typedef struct titlebar_t titlebar_t;
|
||||
typedef struct client_node_t client_node_t;
|
||||
typedef struct _tag_t tag_t;
|
||||
typedef struct tag_client_node_t tag_client_node_t;
|
||||
|
@ -79,6 +77,42 @@ typedef widget_t *(widget_constructor_t)(alignment_t);
|
|||
typedef void (widget_destructor_t)(widget_t *);
|
||||
typedef struct awesome_t awesome_t;
|
||||
|
||||
/** Wibox type */
|
||||
typedef struct
|
||||
{
|
||||
/** Ref count */
|
||||
int refcount;
|
||||
/** Window */
|
||||
simple_window_t sw;
|
||||
/** Wibox name */
|
||||
char *name;
|
||||
/** Box width and height */
|
||||
int width, height;
|
||||
/** Box position */
|
||||
position_t position;
|
||||
/** Alignment */
|
||||
alignment_t align;
|
||||
/** Screen */
|
||||
int screen;
|
||||
/** Widget list */
|
||||
widget_node_t *widgets;
|
||||
/** Widget the mouse is over */
|
||||
widget_node_t *mouse_over;
|
||||
/** Need update */
|
||||
bool need_update;
|
||||
/** Default colors */
|
||||
struct
|
||||
{
|
||||
xcolor_t fg, bg;
|
||||
} colors;
|
||||
struct
|
||||
{
|
||||
xcolor_t color;
|
||||
uint16_t width;
|
||||
} border;
|
||||
} wibox_t;
|
||||
ARRAY_TYPE(wibox_t *, wibox)
|
||||
|
||||
/** Mouse buttons bindings */
|
||||
struct button_t
|
||||
{
|
||||
|
@ -109,15 +143,15 @@ struct widget_t
|
|||
/** Widget destructor */
|
||||
widget_destructor_t *destructor;
|
||||
/** Widget detach function */
|
||||
void (*detach)(widget_t *, void *);
|
||||
void (*detach)(widget_t *, wibox_t *);
|
||||
/** Draw function */
|
||||
int (*draw)(draw_context_t *, int, widget_node_t *, int, int, void *, awesome_type_t);
|
||||
int (*draw)(draw_context_t *, int, widget_node_t *, int, int, wibox_t *, awesome_type_t);
|
||||
/** Index function */
|
||||
int (*index)(lua_State *, awesome_token_t);
|
||||
/** Newindex function */
|
||||
int (*newindex)(lua_State *, awesome_token_t);
|
||||
/** Button event handler */
|
||||
void (*button)(widget_node_t *, xcb_button_press_event_t *, int, void *, awesome_type_t);
|
||||
void (*button)(widget_node_t *, xcb_button_press_event_t *, int, wibox_t *, awesome_type_t);
|
||||
/** Mouse over event handler */
|
||||
luaA_ref mouse_enter, mouse_leave;
|
||||
/** Alignement */
|
||||
|
@ -169,83 +203,6 @@ widget_node_delete(widget_node_t **node)
|
|||
|
||||
DO_SLIST(widget_node_t, widget_node, widget_node_delete)
|
||||
|
||||
/** Titlebar template structure */
|
||||
struct titlebar_t
|
||||
{
|
||||
/** Ref count */
|
||||
int refcount;
|
||||
/** Position */
|
||||
position_t position;
|
||||
/** Alignment on window */
|
||||
alignment_t align;
|
||||
/** Widgets */
|
||||
widget_node_t *widgets;
|
||||
/** Widget the mouse is over */
|
||||
widget_node_t *mouse_over;
|
||||
/** Width and height */
|
||||
int width, height;
|
||||
/** Titlebar window */
|
||||
simple_window_t sw;
|
||||
/** Default colors */
|
||||
struct
|
||||
{
|
||||
xcolor_t fg, bg;
|
||||
} colors;
|
||||
/** Border */
|
||||
struct
|
||||
{
|
||||
xcolor_t color;
|
||||
int width;
|
||||
} border;
|
||||
/** Need update */
|
||||
bool need_update;
|
||||
};
|
||||
|
||||
/** Delete a titlebar structure.
|
||||
* \param t The titlebar to destroy.
|
||||
*/
|
||||
static inline void
|
||||
titlebar_delete(titlebar_t **t)
|
||||
{
|
||||
widget_node_list_wipe(&(*t)->widgets);
|
||||
p_delete(t);
|
||||
}
|
||||
|
||||
DO_RCNT(titlebar_t, titlebar, titlebar_delete)
|
||||
|
||||
/** Status bar */
|
||||
struct statusbar_t
|
||||
{
|
||||
/** Ref count */
|
||||
int refcount;
|
||||
/** Window */
|
||||
simple_window_t sw;
|
||||
/** statusbar_t name */
|
||||
char *name;
|
||||
/** Bar width */
|
||||
int width;
|
||||
/** Bar height */
|
||||
int height;
|
||||
/** Bar position */
|
||||
position_t position;
|
||||
/** Alignment */
|
||||
alignment_t align;
|
||||
/** Screen */
|
||||
int screen;
|
||||
/** Widget list */
|
||||
widget_node_t *widgets;
|
||||
/** Need update */
|
||||
bool need_update;
|
||||
/** Default colors */
|
||||
struct
|
||||
{
|
||||
xcolor_t fg, bg;
|
||||
} colors;
|
||||
/** Widget the mouse is over */
|
||||
widget_node_t *mouse_over;
|
||||
};
|
||||
ARRAY_TYPE(statusbar_t *, statusbar)
|
||||
|
||||
/* Strut */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -318,7 +275,7 @@ struct client_t
|
|||
/** Path to an icon */
|
||||
char *icon_path;
|
||||
/** Titlebar */
|
||||
titlebar_t *titlebar;
|
||||
wibox_t *titlebar;
|
||||
/** Button bindings */
|
||||
button_array_t buttons;
|
||||
/** Icon */
|
||||
|
@ -399,7 +356,7 @@ typedef struct
|
|||
/** Tag list */
|
||||
tag_array_t tags;
|
||||
/** Statusbars */
|
||||
statusbar_array_t statusbars;
|
||||
wibox_array_t statusbars;
|
||||
/** Padding */
|
||||
padding_t padding;
|
||||
/** Window that contains the systray */
|
||||
|
|
28
titlebar.c
28
titlebar.c
|
@ -24,19 +24,20 @@
|
|||
#include "titlebar.h"
|
||||
#include "client.h"
|
||||
#include "widget.h"
|
||||
#include "wibox.h"
|
||||
|
||||
extern awesome_t globalconf;
|
||||
|
||||
DO_LUA_NEW(extern, titlebar_t, titlebar, "titlebar", titlebar_ref)
|
||||
DO_LUA_GC(titlebar_t, titlebar, "titlebar", titlebar_unref)
|
||||
DO_LUA_EQ(titlebar_t, titlebar, "titlebar")
|
||||
DO_LUA_NEW(extern, wibox_t, titlebar, "titlebar", wibox_ref)
|
||||
DO_LUA_GC(wibox_t, titlebar, "titlebar", wibox_unref)
|
||||
DO_LUA_EQ(wibox_t, titlebar, "titlebar")
|
||||
|
||||
/** Get a client by its titlebar.
|
||||
* \param titlebar The titlebar.
|
||||
* \return A client.
|
||||
*/
|
||||
client_t *
|
||||
client_getbytitlebar(titlebar_t *titlebar)
|
||||
client_getbytitlebar(wibox_t *titlebar)
|
||||
{
|
||||
client_t *c;
|
||||
|
||||
|
@ -253,7 +254,7 @@ titlebar_init(client_t *c)
|
|||
static int
|
||||
luaA_titlebar_new(lua_State *L)
|
||||
{
|
||||
titlebar_t *tb;
|
||||
wibox_t *tb;
|
||||
const char *buf;
|
||||
size_t len;
|
||||
xcolor_init_request_t reqs[3];
|
||||
|
@ -261,7 +262,7 @@ luaA_titlebar_new(lua_State *L)
|
|||
|
||||
luaA_checktable(L, 2);
|
||||
|
||||
tb = p_new(titlebar_t, 1);
|
||||
tb = p_new(wibox_t, 1);
|
||||
|
||||
buf = luaA_getopt_lstring(L, 2, "align", "left", &len);
|
||||
tb->align = draw_align_fromstr(buf, len);
|
||||
|
@ -303,7 +304,7 @@ static int
|
|||
luaA_titlebar_newindex(lua_State *L)
|
||||
{
|
||||
size_t len;
|
||||
titlebar_t **titlebar = luaA_checkudata(L, 1, "titlebar");
|
||||
wibox_t **titlebar = luaA_checkudata(L, 1, "titlebar");
|
||||
const char *buf, *attr = luaL_checklstring(L, 2, &len);
|
||||
client_t *c = NULL;
|
||||
int i;
|
||||
|
@ -318,11 +319,10 @@ luaA_titlebar_newindex(lua_State *L)
|
|||
if((*newc)->titlebar)
|
||||
{
|
||||
xcb_unmap_window(globalconf.connection, (*newc)->titlebar->sw.window);
|
||||
titlebar_unref(&(*newc)->titlebar);
|
||||
wibox_unref(&(*newc)->titlebar);
|
||||
}
|
||||
/* Attach titlebar to client */
|
||||
(*newc)->titlebar = *titlebar;
|
||||
titlebar_ref(titlebar);
|
||||
(*newc)->titlebar = wibox_ref(titlebar);
|
||||
titlebar_init(*newc);
|
||||
c = *newc;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ luaA_titlebar_newindex(lua_State *L)
|
|||
{
|
||||
xcb_unmap_window(globalconf.connection, (*titlebar)->sw.window);
|
||||
/* unref and NULL the ref */
|
||||
titlebar_unref(&c->titlebar);
|
||||
wibox_unref(&c->titlebar);
|
||||
c->titlebar = NULL;
|
||||
client_need_arrange(c);
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ static int
|
|||
luaA_titlebar_index(lua_State *L)
|
||||
{
|
||||
size_t len;
|
||||
titlebar_t **titlebar = luaA_checkudata(L, 1, "titlebar");
|
||||
wibox_t **titlebar = luaA_checkudata(L, 1, "titlebar");
|
||||
const char *attr = luaL_checklstring(L, 2, &len);
|
||||
client_t *c;
|
||||
|
||||
|
@ -447,7 +447,7 @@ luaA_titlebar_index(lua_State *L)
|
|||
static int
|
||||
luaA_titlebar_widgets(lua_State *L)
|
||||
{
|
||||
titlebar_t **titlebar = luaA_checkudata(L, 1, "titlebar");
|
||||
wibox_t **titlebar = luaA_checkudata(L, 1, "titlebar");
|
||||
|
||||
if(lua_gettop(L) == 2)
|
||||
{
|
||||
|
@ -469,7 +469,7 @@ luaA_titlebar_widgets(lua_State *L)
|
|||
static int
|
||||
luaA_titlebar_tostring(lua_State *L)
|
||||
{
|
||||
titlebar_t **p = luaA_checkudata(L, 1, "titlebar");
|
||||
wibox_t **p = luaA_checkudata(L, 1, "titlebar");
|
||||
lua_pushfstring(L, "[titlebar udata(%p)]", *p);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -24,14 +24,14 @@
|
|||
|
||||
#include "structs.h"
|
||||
|
||||
client_t * client_getbytitlebar(titlebar_t *);
|
||||
client_t * client_getbytitlebar(wibox_t *);
|
||||
client_t * client_getbytitlebarwin(xcb_window_t);
|
||||
void titlebar_geometry_compute(client_t *, area_t, area_t *);
|
||||
void titlebar_draw(client_t *);
|
||||
void titlebar_init(client_t *);
|
||||
void titlebar_refresh(void);
|
||||
|
||||
int luaA_titlebar_userdata_new(lua_State *, titlebar_t *);
|
||||
int luaA_titlebar_userdata_new(lua_State *, wibox_t *);
|
||||
|
||||
/** Add the titlebar geometry and border to a geometry.
|
||||
* \param t The titlebar
|
||||
|
@ -40,7 +40,7 @@ int luaA_titlebar_userdata_new(lua_State *, titlebar_t *);
|
|||
* \return A new geometry bigger if the titlebar is visible.
|
||||
*/
|
||||
static inline area_t
|
||||
titlebar_geometry_add(titlebar_t *t, int border, area_t geometry)
|
||||
titlebar_geometry_add(wibox_t *t, int border, area_t geometry)
|
||||
{
|
||||
if(t)
|
||||
switch(t->position)
|
||||
|
@ -82,7 +82,7 @@ titlebar_geometry_add(titlebar_t *t, int border, area_t geometry)
|
|||
* \return A new geometry smaller if the titlebar is visible.
|
||||
*/
|
||||
static inline area_t
|
||||
titlebar_geometry_remove(titlebar_t *t, int border, area_t geometry)
|
||||
titlebar_geometry_remove(wibox_t *t, int border, area_t geometry)
|
||||
{
|
||||
if(t)
|
||||
switch(t->position)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* wibox.c - statusbar functions
|
||||
*
|
||||
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* statusbar.h - statusbar functions header
|
||||
*
|
||||
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
||||
*
|
||||
* 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 AWESOME_STATUSBAR_H
|
||||
#define AWESOME_STATUSBAR_H
|
||||
|
||||
#include "widget.h"
|
||||
#include "swindow.h"
|
||||
#include "common/util.h"
|
||||
#include "common/refcount.h"
|
||||
#include "common/array.h"
|
||||
|
||||
static inline void
|
||||
wibox_delete(wibox_t **wibox)
|
||||
{
|
||||
simplewindow_wipe(&(*wibox)->sw);
|
||||
widget_node_list_wipe(&(*wibox)->widgets);
|
||||
p_delete(&(*wibox)->name);
|
||||
p_delete(wibox);
|
||||
}
|
||||
|
||||
DO_RCNT(wibox_t, wibox, wibox_delete)
|
||||
ARRAY_FUNCS(wibox_t *, wibox, wibox_unref)
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
6
widget.c
6
widget.c
|
@ -67,7 +67,7 @@ static void
|
|||
widget_common_button(widget_node_t *w,
|
||||
xcb_button_press_event_t *ev,
|
||||
int screen __attribute__ ((unused)),
|
||||
void *p,
|
||||
wibox_t *p,
|
||||
awesome_type_t type)
|
||||
{
|
||||
button_array_t *b = &w->widget->buttons;
|
||||
|
@ -212,7 +212,7 @@ widget_invalidate_cache(int screen, int flags)
|
|||
{
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *statusbar = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *statusbar = globalconf.screens[screen].statusbars.tab[i];
|
||||
widget_node_t *widget;
|
||||
|
||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||
|
@ -238,7 +238,7 @@ widget_invalidate_bywidget(widget_t *widget)
|
|||
for(screen = 0; screen < globalconf.nscreen; screen++)
|
||||
for(int i = 0; i < globalconf.screens[screen].statusbars.len; i++)
|
||||
{
|
||||
statusbar_t *statusbar = globalconf.screens[screen].statusbars.tab[i];
|
||||
wibox_t *statusbar = globalconf.screens[screen].statusbars.tab[i];
|
||||
|
||||
if(!statusbar->need_update)
|
||||
for(witer = statusbar->widgets; witer; witer = witer->next)
|
||||
|
|
|
@ -145,7 +145,7 @@ graph_draw(draw_context_t *ctx,
|
|||
widget_node_t *w,
|
||||
int offset,
|
||||
int used __attribute__ ((unused)),
|
||||
void *p __attribute__ ((unused)),
|
||||
wibox_t *p __attribute__ ((unused)),
|
||||
awesome_type_t type)
|
||||
{
|
||||
int margin_top, y;
|
||||
|
|
|
@ -45,7 +45,7 @@ static int
|
|||
imagebox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
|
||||
widget_node_t *w,
|
||||
int offset, int used,
|
||||
void *p, awesome_type_t type)
|
||||
wibox_t *p, awesome_type_t type)
|
||||
{
|
||||
imagebox_data_t *d = w->widget->data;
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ progressbar_draw(draw_context_t *ctx,
|
|||
widget_node_t *w,
|
||||
int offset,
|
||||
int used __attribute__ ((unused)),
|
||||
void *p __attribute__ ((unused)),
|
||||
wibox_t *p __attribute__ ((unused)),
|
||||
awesome_type_t type)
|
||||
{
|
||||
/* pb_.. values points to the widget inside a potential border */
|
||||
|
|
|
@ -37,12 +37,10 @@ systray_draw(draw_context_t *ctx,
|
|||
int screen __attribute__ ((unused)),
|
||||
widget_node_t *w,
|
||||
int offset, int used __attribute__ ((unused)),
|
||||
void *p,
|
||||
wibox_t *p,
|
||||
awesome_type_t type)
|
||||
{
|
||||
uint32_t orient;
|
||||
/* p is always a statusbar, titlebars are forbidden */
|
||||
statusbar_t *sb = (statusbar_t *) p;
|
||||
|
||||
/* we are on a statusbar */
|
||||
assert(type == AWESOME_TYPE_STATUSBAR);
|
||||
|
@ -54,7 +52,7 @@ systray_draw(draw_context_t *ctx,
|
|||
int i = 0;
|
||||
xembed_window_t *em;
|
||||
for(em = globalconf.embedded; em; em = em->next)
|
||||
if(em->phys_screen == sb->sw.ctx.phys_screen)
|
||||
if(em->phys_screen == p->sw.ctx.phys_screen)
|
||||
i++;
|
||||
/** \todo use clas hints */
|
||||
w->area.width = MIN(i * ctx->height, ctx->width - used);
|
||||
|
@ -68,7 +66,7 @@ systray_draw(draw_context_t *ctx,
|
|||
w->widget->align);
|
||||
w->area.y = 0;
|
||||
|
||||
switch(sb->position)
|
||||
switch(p->position)
|
||||
{
|
||||
case Right:
|
||||
case Left:
|
||||
|
@ -82,7 +80,7 @@ systray_draw(draw_context_t *ctx,
|
|||
/* set statusbar orientation */
|
||||
/** \todo stop setting that property on each redraw */
|
||||
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||
globalconf.screens[sb->sw.ctx.phys_screen].systray.window,
|
||||
globalconf.screens[p->sw.ctx.phys_screen].systray.window,
|
||||
_NET_SYSTEM_TRAY_ORIENTATION, CARDINAL, 32, 1, &orient);
|
||||
|
||||
return w->area.width;
|
||||
|
|
|
@ -33,7 +33,7 @@ extern awesome_t globalconf;
|
|||
typedef struct taglist_drawn_area_t taglist_drawn_area_t;
|
||||
struct taglist_drawn_area_t
|
||||
{
|
||||
void *object;
|
||||
wibox_t *object;
|
||||
area_array_t areas;
|
||||
taglist_drawn_area_t *next, *prev;
|
||||
};
|
||||
|
@ -58,7 +58,7 @@ typedef struct
|
|||
} taglist_data_t;
|
||||
|
||||
static taglist_drawn_area_t *
|
||||
taglist_drawn_area_getbyobj(taglist_drawn_area_t *list, void *p)
|
||||
taglist_drawn_area_getbyobj(taglist_drawn_area_t *list, wibox_t *p)
|
||||
{
|
||||
taglist_drawn_area_t *t;
|
||||
|
||||
|
@ -83,7 +83,7 @@ static int
|
|||
taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w,
|
||||
int offset,
|
||||
int used __attribute__ ((unused)),
|
||||
void *object,
|
||||
wibox_t *object,
|
||||
awesome_type_t type)
|
||||
{
|
||||
taglist_data_t *data = w->widget->data;
|
||||
|
@ -168,7 +168,7 @@ static void
|
|||
taglist_button(widget_node_t *w,
|
||||
xcb_button_press_event_t *ev,
|
||||
int screen,
|
||||
void *object,
|
||||
wibox_t *object,
|
||||
awesome_type_t type)
|
||||
{
|
||||
tag_array_t *tags = &globalconf.screens[screen].tags;
|
||||
|
@ -265,7 +265,7 @@ taglist_destructor(widget_t *widget)
|
|||
* \param object The object we are leaving.
|
||||
*/
|
||||
static void
|
||||
taglist_detach(widget_t *widget, void *object)
|
||||
taglist_detach(widget_t *widget, wibox_t *object)
|
||||
{
|
||||
taglist_data_t *d = widget->data;
|
||||
taglist_drawn_area_t *tda;
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef struct tasklist_object_data_t tasklist_object_data_t;
|
|||
struct tasklist_object_data_t
|
||||
{
|
||||
/** The object */
|
||||
void *object;
|
||||
wibox_t *object;
|
||||
/** The box width for each client */
|
||||
int box_width;
|
||||
/** The client label array for the object */
|
||||
|
@ -88,7 +88,7 @@ typedef struct
|
|||
* \return A object data or NULL if not found.
|
||||
*/
|
||||
static tasklist_object_data_t *
|
||||
tasklist_object_data_getbyobj(tasklist_object_data_t *od, void *p)
|
||||
tasklist_object_data_getbyobj(tasklist_object_data_t *od, wibox_t *p)
|
||||
{
|
||||
tasklist_object_data_t *o;
|
||||
|
||||
|
@ -178,7 +178,7 @@ tasklist_draw_item(draw_context_t *ctx,
|
|||
static int
|
||||
tasklist_draw(draw_context_t *ctx, int screen,
|
||||
widget_node_t *w,
|
||||
int offset, int used, void *p,
|
||||
int offset, int used, wibox_t *p,
|
||||
awesome_type_t type)
|
||||
{
|
||||
client_t *c;
|
||||
|
@ -279,7 +279,7 @@ static void
|
|||
tasklist_button(widget_node_t *w,
|
||||
xcb_button_press_event_t *ev,
|
||||
int screen,
|
||||
void *object,
|
||||
wibox_t *object,
|
||||
awesome_type_t type)
|
||||
{
|
||||
tasklist_data_t *d = w->widget->data;
|
||||
|
@ -388,7 +388,7 @@ tasklist_destructor(widget_t *widget)
|
|||
* \param object The object we are leaving.
|
||||
*/
|
||||
static void
|
||||
tasklist_detach(widget_t *widget, void *object)
|
||||
tasklist_detach(widget_t *widget, wibox_t *object)
|
||||
{
|
||||
tasklist_data_t *d = widget->data;
|
||||
tasklist_object_data_t *od;
|
||||
|
|
|
@ -53,7 +53,7 @@ static int
|
|||
textbox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
|
||||
widget_node_t *w,
|
||||
int offset, int used,
|
||||
void *p __attribute__ ((unused)),
|
||||
wibox_t *p __attribute__ ((unused)),
|
||||
awesome_type_t type)
|
||||
{
|
||||
textbox_data_t *d = w->widget->data;
|
||||
|
|
Loading…
Reference in New Issue