image: port to new class system
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
0eb0c49592
commit
a916f2cd55
|
@ -26,8 +26,6 @@
|
|||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <ev.h>
|
||||
|
||||
#include <xcb/xtest.h>
|
||||
#include <xcb/xcb_event.h>
|
||||
|
||||
|
@ -42,6 +40,7 @@
|
|||
#include "property.h"
|
||||
#include "screen.h"
|
||||
#include "titlebar.h"
|
||||
#include "luaa.h"
|
||||
#include "common/version.h"
|
||||
#include "common/atoms.h"
|
||||
#include "common/xcursor.h"
|
||||
|
|
1
button.c
1
button.c
|
@ -22,6 +22,7 @@
|
|||
#include "button.h"
|
||||
#include "luaa.h"
|
||||
#include "key.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
/** Create a new mouse button bindings.
|
||||
* \param L The Lua VM state.
|
||||
|
|
1
client.c
1
client.c
|
@ -29,6 +29,7 @@
|
|||
#include "systray.h"
|
||||
#include "property.h"
|
||||
#include "spawn.h"
|
||||
#include "luaa.h"
|
||||
#include "common/atoms.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
|
|
2
client.h
2
client.h
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "mouse.h"
|
||||
#include "stack.h"
|
||||
#include "common/luaclass.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
#define CLIENT_SELECT_INPUT_EVENT_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY \
|
||||
| XCB_EVENT_MASK_PROPERTY_CHANGE \
|
||||
|
|
1
ewmh.c
1
ewmh.c
|
@ -31,6 +31,7 @@
|
|||
#include "client.h"
|
||||
#include "widget.h"
|
||||
#include "wibox.h"
|
||||
#include "luaa.h"
|
||||
#include "common/atoms.h"
|
||||
#include "common/buffer.h"
|
||||
#include "common/xutil.h"
|
||||
|
|
1
hooks.c
1
hooks.c
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "structs.h"
|
||||
#include "luaa.h"
|
||||
|
||||
#define HANDLE_HOOK(L, h) \
|
||||
do { \
|
||||
|
|
140
image.c
140
image.c
|
@ -19,11 +19,28 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "structs.h"
|
||||
#include "common/tokenize.h"
|
||||
#include "common/xutil.h"
|
||||
#include <xcb/xcb_image.h>
|
||||
|
||||
#include <Imlib2.h>
|
||||
|
||||
#include "structs.h"
|
||||
#include "luaa.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
struct image
|
||||
{
|
||||
LUA_OBJECT_HEADER
|
||||
/** Imlib2 image */
|
||||
Imlib_Image image;
|
||||
/** Image data */
|
||||
uint8_t *data;
|
||||
/** Flag telling if the image is up to date or needs computing before
|
||||
* drawing */
|
||||
bool isupdated;
|
||||
};
|
||||
|
||||
LUA_OBJECT_FUNCS(image_class, image_t, image)
|
||||
|
||||
static int
|
||||
luaA_image_gc(lua_State *L)
|
||||
{
|
||||
|
@ -729,68 +746,73 @@ luaA_image_insert(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** Image object.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
* \luastack
|
||||
* \lvalue An image
|
||||
* \lfield width The image width.
|
||||
* \lfield height The image height.
|
||||
*/
|
||||
static int
|
||||
luaA_image_index(lua_State *L)
|
||||
luaA_image_get_width(lua_State *L, image_t *image)
|
||||
{
|
||||
if(luaA_usemetatable(L, 1, 2))
|
||||
return 1;
|
||||
|
||||
image_t *image = luaA_checkudata(L, 1, &image_class);
|
||||
size_t len;
|
||||
const char *attr = luaL_checklstring(L, 2, &len);
|
||||
|
||||
switch(a_tokenize(attr, len))
|
||||
{
|
||||
case A_TK_WIDTH:
|
||||
lua_pushnumber(L, image_getwidth(image));
|
||||
break;
|
||||
case A_TK_HEIGHT:
|
||||
lua_pushnumber(L, image_getheight(image));
|
||||
break;
|
||||
case A_TK_ALPHA:
|
||||
imlib_context_set_image(image->image);
|
||||
lua_pushboolean(L, imlib_image_has_alpha());
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
lua_pushnumber(L, image_getwidth(image));
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct luaL_reg awesome_image_methods[] =
|
||||
static int
|
||||
luaA_image_get_height(lua_State *L, image_t *image)
|
||||
{
|
||||
LUA_CLASS_METHODS(image)
|
||||
{ "__call", luaA_image_new },
|
||||
{ "argb32", luaA_image_argb32_new },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
const struct luaL_reg awesome_image_meta[] =
|
||||
lua_pushnumber(L, image_getheight(image));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_image_get_alpha(lua_State *L, image_t *image)
|
||||
{
|
||||
LUA_OBJECT_META(image)
|
||||
{ "__index", luaA_image_index },
|
||||
{ "rotate", luaA_image_rotate },
|
||||
{ "orientate", luaA_image_orientate },
|
||||
{ "crop", luaA_image_crop },
|
||||
{ "crop_and_scale", luaA_image_crop_and_scale },
|
||||
{ "save", luaA_image_save },
|
||||
{ "insert", luaA_image_insert },
|
||||
/* draw on images, whee! */
|
||||
{ "draw_pixel", luaA_image_draw_pixel },
|
||||
{ "draw_line", luaA_image_draw_line },
|
||||
{ "draw_rectangle", luaA_image_draw_rectangle },
|
||||
{ "draw_rectangle_gradient", luaA_image_draw_rectangle_gradient },
|
||||
{ "draw_circle", luaA_image_draw_circle },
|
||||
{ "__gc", luaA_image_gc },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
imlib_context_set_image(image->image);
|
||||
lua_pushboolean(L, imlib_image_has_alpha());
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
image_class_setup(lua_State *L)
|
||||
{
|
||||
static const struct luaL_reg image_methods[] =
|
||||
{
|
||||
LUA_CLASS_METHODS(image)
|
||||
{ "__call", luaA_image_new },
|
||||
{ "argb32", luaA_image_argb32_new },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const struct luaL_reg image_meta[] =
|
||||
{
|
||||
LUA_OBJECT_META(image)
|
||||
LUA_CLASS_META
|
||||
{ "rotate", luaA_image_rotate },
|
||||
{ "orientate", luaA_image_orientate },
|
||||
{ "crop", luaA_image_crop },
|
||||
{ "crop_and_scale", luaA_image_crop_and_scale },
|
||||
{ "save", luaA_image_save },
|
||||
{ "insert", luaA_image_insert },
|
||||
/* draw on images, whee! */
|
||||
{ "draw_pixel", luaA_image_draw_pixel },
|
||||
{ "draw_line", luaA_image_draw_line },
|
||||
{ "draw_rectangle", luaA_image_draw_rectangle },
|
||||
{ "draw_rectangle_gradient", luaA_image_draw_rectangle_gradient },
|
||||
{ "draw_circle", luaA_image_draw_circle },
|
||||
{ "__gc", luaA_image_gc },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
luaA_class_setup(L, &image_class, "image", (lua_class_allocator_t) image_new,
|
||||
image_methods, image_meta);
|
||||
luaA_class_add_property(&image_class, A_TK_WIDTH,
|
||||
NULL,
|
||||
(lua_class_propfunc_t) luaA_image_get_width,
|
||||
NULL);
|
||||
luaA_class_add_property(&image_class, A_TK_HEIGHT,
|
||||
NULL,
|
||||
(lua_class_propfunc_t) luaA_image_get_height,
|
||||
NULL);
|
||||
luaA_class_add_property(&image_class, A_TK_ALPHA,
|
||||
NULL,
|
||||
(lua_class_propfunc_t) luaA_image_get_alpha,
|
||||
NULL);
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
25
image.h
25
image.h
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* image.h - image object header
|
||||
*
|
||||
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
||||
* Copyright © 2008-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
|
||||
|
@ -22,27 +22,12 @@
|
|||
#ifndef AWESOME_IMAGE_H
|
||||
#define AWESOME_IMAGE_H
|
||||
|
||||
#include <Imlib2.h>
|
||||
|
||||
#include "common/util.h"
|
||||
#include "common/luaobject.h"
|
||||
#include <xcb/xcb.h>
|
||||
#include "common/luaclass.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LUA_OBJECT_HEADER
|
||||
/** Imlib2 image */
|
||||
Imlib_Image image;
|
||||
/** Image data */
|
||||
uint8_t *data;
|
||||
/** Flag telling if the image is up to date or needs computing before
|
||||
* drawing */
|
||||
bool isupdated;
|
||||
} image_t;
|
||||
|
||||
lua_class_t image_class;
|
||||
LUA_OBJECT_FUNCS(image_class, image_t, image)
|
||||
typedef struct image image_t;
|
||||
|
||||
void image_class_setup(lua_State *);
|
||||
int image_new_from_argb32(int, int, uint32_t *);
|
||||
uint8_t * image_getdata(image_t *);
|
||||
int image_getwidth(image_t *);
|
||||
|
@ -50,5 +35,7 @@ int image_getheight(image_t *);
|
|||
|
||||
xcb_pixmap_t image_to_1bit_pixmap(image_t *, xcb_drawable_t);
|
||||
|
||||
lua_class_t image_class;
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
3
key.c
3
key.c
|
@ -28,8 +28,9 @@
|
|||
#include <X11/XF86keysym.h>
|
||||
|
||||
#include "structs.h"
|
||||
#include "luaa.h"
|
||||
#include "common/xutil.h"
|
||||
#include "common/tokenize.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
/** Grab key on a window.
|
||||
* \param win The window.
|
||||
|
|
2
key.h
2
key.h
|
@ -22,7 +22,7 @@
|
|||
#ifndef AWESOME_KEY_H
|
||||
#define AWESOME_KEY_H
|
||||
|
||||
#include "luaa.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
typedef struct keyb_t
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "structs.h"
|
||||
#include "keygrabber.h"
|
||||
#include "key.h"
|
||||
#include "luaa.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
/** Grab the keyboard.
|
||||
|
|
5
luaa.c
5
luaa.c
|
@ -51,8 +51,6 @@ extern const struct luaL_reg awesome_hooks_lib[];
|
|||
extern const struct luaL_reg awesome_keygrabber_lib[];
|
||||
extern const struct luaL_reg awesome_mousegrabber_lib[];
|
||||
extern const struct luaL_reg awesome_root_lib[];
|
||||
extern const struct luaL_reg awesome_image_methods[];
|
||||
extern const struct luaL_reg awesome_image_meta[];
|
||||
extern const struct luaL_reg awesome_mouse_methods[];
|
||||
extern const struct luaL_reg awesome_mouse_meta[];
|
||||
extern const struct luaL_reg awesome_screen_methods[];
|
||||
|
@ -737,8 +735,7 @@ luaA_init(xdgHandle* xdg)
|
|||
button_class_setup(L);
|
||||
|
||||
/* Export image */
|
||||
luaA_class_setup(L, &image_class, "image", (lua_class_allocator_t) image_new,
|
||||
awesome_image_methods, awesome_image_meta);
|
||||
image_class_setup(L);
|
||||
|
||||
/* Export tag */
|
||||
tag_class_setup(L);
|
||||
|
|
1
luaa.h
1
luaa.h
|
@ -30,6 +30,7 @@
|
|||
#include <basedir.h>
|
||||
|
||||
#include "draw.h"
|
||||
#include "common/lualib.h"
|
||||
|
||||
#define luaA_deprecate(L, repl) \
|
||||
luaA_warn(L, "%s: This function is deprecated and will be removed, see %s", \
|
||||
|
|
1
mouse.c
1
mouse.c
|
@ -24,6 +24,7 @@
|
|||
#include "client.h"
|
||||
#include "structs.h"
|
||||
#include "wibox.h"
|
||||
#include "luaa.h"
|
||||
#include "common/tokenize.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* mousegrabber.c - mouse pointer grabbing
|
||||
*
|
||||
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
||||
* Copyright © 2008-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
|
||||
|
@ -24,6 +24,7 @@
|
|||
#include "structs.h"
|
||||
#include "mouse.h"
|
||||
#include "mousegrabber.h"
|
||||
#include "luaa.h"
|
||||
#include "common/xcursor.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
|
|
|
@ -26,9 +26,10 @@
|
|||
#include "client.h"
|
||||
#include "ewmh.h"
|
||||
#include "wibox.h"
|
||||
#include "window.h"
|
||||
#include "luaa.h"
|
||||
#include "common/atoms.h"
|
||||
#include "common/xutil.h"
|
||||
#include "window.h"
|
||||
|
||||
void
|
||||
property_update_wm_transient_for(client_t *c, xcb_get_property_reply_t *reply)
|
||||
|
|
1
root.c
1
root.c
|
@ -24,6 +24,7 @@
|
|||
#include "structs.h"
|
||||
#include "button.h"
|
||||
#include "wibox.h"
|
||||
#include "luaa.h"
|
||||
#include "common/xcursor.h"
|
||||
#include "common/tokenize.h"
|
||||
#include "common/xutil.h"
|
||||
|
|
1
screen.c
1
screen.c
|
@ -30,6 +30,7 @@
|
|||
#include "client.h"
|
||||
#include "widget.h"
|
||||
#include "wibox.h"
|
||||
#include "luaa.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
static inline area_t
|
||||
|
|
|
@ -25,11 +25,14 @@
|
|||
#define SN_API_NOT_YET_FROZEN
|
||||
#include <libsn/sn.h>
|
||||
|
||||
#include <ev.h>
|
||||
|
||||
#include <xcb/xcb_icccm.h>
|
||||
#include <xcb/xcb_keysyms.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "key.h"
|
||||
#include "draw.h"
|
||||
#include "common/xembed.h"
|
||||
|
||||
typedef struct wibox_t wibox_t;
|
||||
|
|
1
tag.c
1
tag.c
|
@ -24,6 +24,7 @@
|
|||
#include "client.h"
|
||||
#include "ewmh.h"
|
||||
#include "widget.h"
|
||||
#include "luaa.h"
|
||||
|
||||
/** Tag type */
|
||||
struct tag
|
||||
|
|
1
timer.c
1
timer.c
|
@ -24,6 +24,7 @@
|
|||
#include "structs.h"
|
||||
#include "luaa.h"
|
||||
#include "timer.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* titlebar.c - titlebar management
|
||||
*
|
||||
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
||||
* Copyright © 2008-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
|
||||
|
@ -26,6 +26,7 @@
|
|||
#include "widget.h"
|
||||
#include "wibox.h"
|
||||
#include "screen.h"
|
||||
#include "luaa.h"
|
||||
|
||||
/** Get a client by its titlebar.
|
||||
* \param titlebar The titlebar.
|
||||
|
|
1
wibox.c
1
wibox.c
|
@ -27,6 +27,7 @@
|
|||
#include "client.h"
|
||||
#include "screen.h"
|
||||
#include "window.h"
|
||||
#include "luaa.h"
|
||||
#include "common/xcursor.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
|
|
1
wibox.h
1
wibox.h
|
@ -23,6 +23,7 @@
|
|||
#define AWESOME_WIBOX_H
|
||||
|
||||
#include "widget.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
/** Wibox types */
|
||||
typedef enum
|
||||
|
|
1
widget.c
1
widget.c
|
@ -29,6 +29,7 @@
|
|||
#include "widget.h"
|
||||
#include "wibox.h"
|
||||
#include "client.h"
|
||||
#include "luaa.h"
|
||||
#include "common/atoms.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "widget.h"
|
||||
#include "luaa.h"
|
||||
#include "common/tokenize.h"
|
||||
|
||||
typedef enum
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* imagebox.c - imagebox widget
|
||||
*
|
||||
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
||||
* Copyright © 2008-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
|
||||
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "widget.h"
|
||||
#include "luaa.h"
|
||||
#include "titlebar.h"
|
||||
|
||||
/** The imagebox private data structure */
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "common/tokenize.h"
|
||||
#include "widget.h"
|
||||
#include "luaa.h"
|
||||
#include "common/tokenize.h"
|
||||
|
||||
/** Progressbar bar data structure */
|
||||
typedef struct
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "widget.h"
|
||||
#include "wibox.h"
|
||||
#include "luaa.h"
|
||||
#include "common/tokenize.h"
|
||||
|
||||
/** The textbox private data structure */
|
||||
|
|
Loading…
Reference in New Issue