window: import class
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
fccc451f89
commit
220d072164
|
@ -65,6 +65,7 @@ set(AWE_SRCS
|
|||
${SOURCE_DIR}/font.c
|
||||
${SOURCE_DIR}/color.c
|
||||
${SOURCE_DIR}/objects/timer.c
|
||||
${SOURCE_DIR}/objects/window.c
|
||||
${SOURCE_DIR}/common/buffer.c
|
||||
${SOURCE_DIR}/common/atoms.c
|
||||
${SOURCE_DIR}/common/util.c
|
||||
|
|
3
luaa.c
3
luaa.c
|
@ -759,6 +759,9 @@ luaA_init(xdgHandle* xdg)
|
|||
/* Export tag */
|
||||
tag_class_setup(L);
|
||||
|
||||
/* Export window */
|
||||
window_class_setup(L);
|
||||
|
||||
/* Export wibox */
|
||||
wibox_class_setup(L);
|
||||
|
||||
|
|
|
@ -55,24 +55,6 @@ luaA_client_gc(lua_State *L)
|
|||
return luaA_object_gc(L);
|
||||
}
|
||||
|
||||
/** Change the client opacity.
|
||||
* \param L The Lua VM state.
|
||||
* \param cidx The client index.
|
||||
* \param opacity The opacity.
|
||||
*/
|
||||
void
|
||||
client_set_opacity(lua_State *L, int cidx, double opacity)
|
||||
{
|
||||
client_t *c = luaA_checkudata(L, cidx, &client_class);
|
||||
|
||||
if(c->opacity != opacity)
|
||||
{
|
||||
c->opacity = opacity;
|
||||
xwindow_set_opacity(c->window, opacity);
|
||||
luaA_object_emit_signal(L, cidx, "property::opacity", 0);
|
||||
}
|
||||
}
|
||||
|
||||
/** Change the clients urgency flag.
|
||||
* \param L The Lua VM state.
|
||||
* \param cidx The client index on the stack.
|
||||
|
@ -636,7 +618,7 @@ HANDLE_GEOM(height)
|
|||
property_update_net_wm_pid(c, NULL);
|
||||
property_update_net_wm_icon(c, NULL);
|
||||
|
||||
client_set_opacity(globalconf.L, -1, xwindow_get_opacity(c->window));
|
||||
window_set_opacity(globalconf.L, -1, xwindow_get_opacity(c->window));
|
||||
|
||||
/* Then check clients hints */
|
||||
ewmh_client_check_hints(c);
|
||||
|
@ -1616,16 +1598,6 @@ luaA_client_set_icon(lua_State *L, client_t *c)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_client_set_opacity(lua_State *L, client_t *c)
|
||||
{
|
||||
if(lua_isnil(L, -1))
|
||||
client_set_opacity(L, -3, -1);
|
||||
else
|
||||
client_set_opacity(L, -3, luaL_checknumber(L, -1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_client_set_sticky(lua_State *L, client_t *c)
|
||||
{
|
||||
|
@ -1718,7 +1690,6 @@ LUA_OBJECT_EXPORT_PROPERTY(client, client_t, machine, lua_pushstring)
|
|||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, role, lua_pushstring)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, transient_for, luaA_object_push)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, skip_taskbar, lua_pushboolean)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, window, lua_pushnumber)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, leader_window, lua_pushnumber)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, group_window, lua_pushnumber)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, pid, lua_pushnumber)
|
||||
|
@ -1734,7 +1705,6 @@ LUA_OBJECT_EXPORT_PROPERTY(client, client_t, sticky, lua_pushboolean)
|
|||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, size_hints_honor, lua_pushboolean)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_horizontal, lua_pushboolean)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, opacity, lua_pushnumber)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_width, lua_pushnumber)
|
||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_color, luaA_pushxcolor)
|
||||
|
||||
|
@ -2089,7 +2059,7 @@ client_class_setup(lua_State *L)
|
|||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
luaA_class_setup(L, &client_class, "client", NULL,
|
||||
luaA_class_setup(L, &client_class, "client", &window_class,
|
||||
(lua_class_allocator_t) client_new,
|
||||
(lua_class_checker_t) client_checker,
|
||||
luaA_class_index_miss_property, luaA_class_newindex_miss_property,
|
||||
|
@ -2130,10 +2100,6 @@ client_class_setup(lua_State *L)
|
|||
NULL,
|
||||
(lua_class_propfunc_t) luaA_client_get_pid,
|
||||
NULL);
|
||||
luaA_class_add_property(&client_class, A_TK_WINDOW,
|
||||
NULL,
|
||||
(lua_class_propfunc_t) luaA_client_get_window,
|
||||
NULL);
|
||||
luaA_class_add_property(&client_class, A_TK_LEADER_WINDOW,
|
||||
NULL,
|
||||
(lua_class_propfunc_t) luaA_client_get_leader_window,
|
||||
|
@ -2182,10 +2148,6 @@ client_class_setup(lua_State *L)
|
|||
(lua_class_propfunc_t) luaA_client_set_icon,
|
||||
(lua_class_propfunc_t) luaA_client_get_icon,
|
||||
(lua_class_propfunc_t) luaA_client_set_icon);
|
||||
luaA_class_add_property(&client_class, A_TK_OPACITY,
|
||||
(lua_class_propfunc_t) luaA_client_set_opacity,
|
||||
(lua_class_propfunc_t) luaA_client_get_opacity,
|
||||
(lua_class_propfunc_t) luaA_client_set_opacity);
|
||||
luaA_class_add_property(&client_class, A_TK_ONTOP,
|
||||
(lua_class_propfunc_t) luaA_client_set_ontop,
|
||||
(lua_class_propfunc_t) luaA_client_get_ontop,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "strut.h"
|
||||
#include "draw.h"
|
||||
#include "banning.h"
|
||||
#include "objects/window.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
#define CLIENT_SELECT_INPUT_EVENT_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY \
|
||||
|
@ -61,7 +62,7 @@ typedef enum
|
|||
/** client_t type */
|
||||
struct client_t
|
||||
{
|
||||
LUA_OBJECT_HEADER
|
||||
WINDOW_OBJECT_HEADER
|
||||
/** Valid, or not ? */
|
||||
bool invalid;
|
||||
/** Client name */
|
||||
|
@ -116,8 +117,6 @@ struct client_t
|
|||
bool nofocus;
|
||||
/** The window type */
|
||||
window_type_t type;
|
||||
/** Window of the client */
|
||||
xcb_window_t window;
|
||||
/** Window of the group leader */
|
||||
xcb_window_t group_window;
|
||||
/** Window holding command needed to start it (session management related) */
|
||||
|
@ -145,8 +144,6 @@ struct client_t
|
|||
uint32_t pid;
|
||||
/** Window it is transient for */
|
||||
client_t *transient_for;
|
||||
/** Window opacity */
|
||||
double opacity;
|
||||
};
|
||||
|
||||
ARRAY_FUNCS(client_t *, client, DO_NOTHING)
|
||||
|
@ -190,7 +187,6 @@ void client_set_alt_name(lua_State *L, int, char *);
|
|||
void client_set_group_window(lua_State *, int, xcb_window_t);
|
||||
void client_set_icon(lua_State *, int, int);
|
||||
void client_set_skip_taskbar(lua_State *, int, bool);
|
||||
void client_set_opacity(lua_State *, int, double);
|
||||
void client_focus(client_t *);
|
||||
void client_focus_update(client_t *);
|
||||
void client_unfocus(client_t *);
|
||||
|
|
|
@ -355,19 +355,6 @@ wibox_refresh_pixmap_partial(wibox_t *wibox,
|
|||
w, h);
|
||||
}
|
||||
|
||||
void
|
||||
wibox_set_opacity(lua_State *L, int udx, double opacity)
|
||||
{
|
||||
wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
|
||||
if(w->opacity != opacity)
|
||||
{
|
||||
w->opacity = opacity;
|
||||
if(w->window)
|
||||
xwindow_set_opacity(w->window, opacity);
|
||||
luaA_object_emit_signal(L, udx, "property::opacity", 0);
|
||||
}
|
||||
}
|
||||
|
||||
/** Set a wibox border color.
|
||||
* \param L The Lua VM state.
|
||||
* \param udx The wibox to change border width.
|
||||
|
@ -1105,41 +1092,6 @@ luaA_wibox_set_ontop(lua_State *L, wibox_t *wibox)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** Set the wibox opacity.
|
||||
* \param L The Lua VM state.
|
||||
* \param wibox The wibox object.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_wibox_set_opacity(lua_State *L, wibox_t *wibox)
|
||||
{
|
||||
if(lua_isnil(L, -1))
|
||||
wibox_set_opacity(L, -3, -1);
|
||||
else
|
||||
{
|
||||
double d = luaL_checknumber(L, -1);
|
||||
if(d >= 0 && d <= 1)
|
||||
wibox_set_opacity(L, -3, d);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Get the wibox opacity.
|
||||
* \param L The Lua VM state.
|
||||
* \param wibox The wibox object.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_wibox_get_opacity(lua_State *L, wibox_t *wibox)
|
||||
{
|
||||
if (wibox->opacity >= 0)
|
||||
{
|
||||
lua_pushnumber(L, wibox->opacity);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Set the wibox cursor.
|
||||
* \param L The Lua VM state.
|
||||
* \param wibox The wibox object.
|
||||
|
@ -1389,7 +1341,7 @@ wibox_class_setup(lua_State *L)
|
|||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
luaA_class_setup(L, &wibox_class, "wibox", NULL,
|
||||
luaA_class_setup(L, &wibox_class, "wibox", &window_class,
|
||||
(lua_class_allocator_t) wibox_new, NULL,
|
||||
luaA_class_index_miss_property, luaA_class_newindex_miss_property,
|
||||
wibox_methods, wibox_meta);
|
||||
|
@ -1397,10 +1349,6 @@ wibox_class_setup(lua_State *L)
|
|||
(lua_class_propfunc_t) luaA_wibox_set_widgets,
|
||||
(lua_class_propfunc_t) luaA_wibox_get_widgets,
|
||||
(lua_class_propfunc_t) luaA_wibox_set_widgets);
|
||||
luaA_class_add_property(&wibox_class, A_TK_OPACITY,
|
||||
(lua_class_propfunc_t) luaA_wibox_set_opacity,
|
||||
(lua_class_propfunc_t) luaA_wibox_get_opacity,
|
||||
(lua_class_propfunc_t) luaA_wibox_set_opacity);
|
||||
luaA_class_add_property(&wibox_class, A_TK_VISIBLE,
|
||||
(lua_class_propfunc_t) luaA_wibox_set_visible,
|
||||
(lua_class_propfunc_t) luaA_wibox_get_visible,
|
||||
|
|
|
@ -24,12 +24,13 @@
|
|||
|
||||
#include "objects/widget.h"
|
||||
#include "strut.h"
|
||||
#include "objects/window.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
/** Wibox type */
|
||||
struct wibox_t
|
||||
{
|
||||
LUA_OBJECT_HEADER
|
||||
WINDOW_OBJECT_HEADER
|
||||
/** Ontop */
|
||||
bool ontop;
|
||||
/** Visible */
|
||||
|
@ -51,8 +52,6 @@ struct wibox_t
|
|||
image_t *bg_image;
|
||||
/** Button bindings */
|
||||
button_array_t buttons;
|
||||
/** The window object. */
|
||||
xcb_window_t window;
|
||||
/** The pixmap copied to the window object. */
|
||||
xcb_pixmap_t pixmap;
|
||||
/** The graphic context. */
|
||||
|
@ -67,8 +66,6 @@ struct wibox_t
|
|||
draw_context_t ctx;
|
||||
/** Orientation */
|
||||
orientation_t orientation;
|
||||
/** Opacity */
|
||||
double opacity;
|
||||
/** Strut */
|
||||
strut_t strut;
|
||||
/** The window's shape */
|
||||
|
@ -92,8 +89,6 @@ void luaA_wibox_invalidate_byitem(lua_State *, const void *);
|
|||
|
||||
wibox_t * wibox_getbywin(xcb_window_t);
|
||||
|
||||
void wibox_set_opacity(lua_State *, int, double);
|
||||
|
||||
void wibox_refresh_pixmap_partial(wibox_t *, int16_t, int16_t, uint16_t, uint16_t);
|
||||
|
||||
void wibox_class_setup(lua_State *);
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* window.c - window object
|
||||
*
|
||||
* Copyright © 2009 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "luaa.h"
|
||||
#include "xwindow.h"
|
||||
#include "objects/window.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
LUA_CLASS_FUNCS(window, window_class)
|
||||
|
||||
/** Set a window opacity.
|
||||
* \param L The Lua VM state.
|
||||
* \param idx The index of the window on the stack.
|
||||
* \param opacity The opacity value.
|
||||
*/
|
||||
void
|
||||
window_set_opacity(lua_State *L, int idx, double opacity)
|
||||
{
|
||||
window_t *window = luaA_checkudata(L, idx, &window_class);
|
||||
|
||||
if(window->opacity != opacity)
|
||||
{
|
||||
window->opacity = opacity;
|
||||
xwindow_set_opacity(window->window, opacity);
|
||||
luaA_object_emit_signal(L, idx, "property::opacity", 0);
|
||||
}
|
||||
}
|
||||
|
||||
/** Set a window opacity.
|
||||
* \param L The Lua VM state.
|
||||
* \param window The window object.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_window_set_opacity(lua_State *L, window_t *window)
|
||||
{
|
||||
if(lua_isnil(L, -1))
|
||||
window_set_opacity(L, -3, -1);
|
||||
else
|
||||
{
|
||||
double d = luaL_checknumber(L, -1);
|
||||
if(d >= 0 && d <= 1)
|
||||
window_set_opacity(L, -3, d);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Get the window opacity.
|
||||
* \param L The Lua VM state.
|
||||
* \param window The window object.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_window_get_opacity(lua_State *L, window_t *window)
|
||||
{
|
||||
if(window->opacity >= 0)
|
||||
{
|
||||
lua_pushnumber(L, window->opacity);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LUA_OBJECT_EXPORT_PROPERTY(window, window_t, window, lua_pushnumber)
|
||||
|
||||
void
|
||||
window_class_setup(lua_State *L)
|
||||
{
|
||||
static const struct luaL_reg window_methods[] =
|
||||
{
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const struct luaL_reg window_meta[] =
|
||||
{
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
luaA_class_setup(L, &window_class, "window", NULL,
|
||||
NULL, NULL,
|
||||
luaA_class_index_miss_property, luaA_class_newindex_miss_property,
|
||||
window_methods, window_meta);
|
||||
|
||||
luaA_class_add_property(&window_class, A_TK_WINDOW,
|
||||
NULL,
|
||||
(lua_class_propfunc_t) luaA_window_get_window,
|
||||
NULL);
|
||||
luaA_class_add_property(&window_class, A_TK_OPACITY,
|
||||
(lua_class_propfunc_t) luaA_window_set_opacity,
|
||||
(lua_class_propfunc_t) luaA_window_get_opacity,
|
||||
(lua_class_propfunc_t) luaA_window_set_opacity);
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* window.h - window object header
|
||||
*
|
||||
* Copyright © 2009 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_OBJECTS_WINDOW_H
|
||||
#define AWESOME_OBJECTS_WINDOW_H
|
||||
|
||||
#include "common/luaclass.h"
|
||||
|
||||
#define WINDOW_OBJECT_HEADER \
|
||||
LUA_OBJECT_HEADER \
|
||||
/** The X window number */ \
|
||||
xcb_window_t window; \
|
||||
/** Opacity */ \
|
||||
double opacity;
|
||||
|
||||
/** Window structure */
|
||||
typedef struct
|
||||
{
|
||||
WINDOW_OBJECT_HEADER
|
||||
} window_t;
|
||||
|
||||
lua_class_t window_class;
|
||||
|
||||
void window_class_setup(lua_State *);
|
||||
|
||||
void window_set_opacity(lua_State *, int, double);
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -398,7 +398,7 @@ property_handle_net_wm_opacity(void *data __attribute__ ((unused)),
|
|||
if(wibox)
|
||||
{
|
||||
luaA_object_push(globalconf.L, wibox);
|
||||
wibox_set_opacity(globalconf.L, -1, xwindow_get_opacity_from_reply(reply));
|
||||
window_set_opacity(globalconf.L, -1, xwindow_get_opacity_from_reply(reply));
|
||||
lua_pop(globalconf.L, -1);
|
||||
}
|
||||
else
|
||||
|
@ -407,7 +407,7 @@ property_handle_net_wm_opacity(void *data __attribute__ ((unused)),
|
|||
if(c)
|
||||
{
|
||||
luaA_object_push(globalconf.L, c);
|
||||
client_set_opacity(globalconf.L, -1, xwindow_get_opacity_from_reply(reply));
|
||||
window_set_opacity(globalconf.L, -1, xwindow_get_opacity_from_reply(reply));
|
||||
lua_pop(globalconf.L, 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue