Compare commits

...

4 Commits

Author SHA1 Message Date
Casey 5c7cd39166
Debug prints 2024-04-10 15:39:44 +03:00
Casey 6a81121674
Silly 2024-04-10 15:30:48 +03:00
Casey 890c0dd514
luaL_newlib is the way 2024-04-10 15:21:34 +03:00
Casey e4bf16bd57
Lua 5.4 tests 2024-04-10 15:09:57 +03:00
6 changed files with 22 additions and 12 deletions

View File

@ -1,5 +1,5 @@
CFLAGS += `pkg-config --cflags cairo xcb lua53`
LDFLAGS := `pkg-config --libs cairo xcb lua53`
CFLAGS += `pkg-config --cflags cairo xcb lua54`
LDFLAGS := `pkg-config --libs cairo xcb lua54`
OBJECTS := obj/common.o obj/rootwindow.o obj/cairo_context.o obj/api_draw.o
livewp: lib

View File

@ -1,8 +1,8 @@
#include "common.h"
#include "api_draw.h"
#include <cairo/cairo.h>
#include <lua5.3/lua.h>
#include <lua5.3/lauxlib.h>
#include <lua.h>
#include <lauxlib.h>
#include <math.h>
int api_draw_clear(lua_State *L);
@ -24,9 +24,9 @@ bool loadapi_draw(lua_State *lua) {
{ "rect_fill", api_draw_rect_fill },
{ "circle", api_draw_circle },
{ "ring", api_draw_ring },
{ NULL, NULL }
};
lua_newtable(lua);
luaL_setfuncs(lua, api_draw, 0);
luaL_newlib(lua, api_draw);
lua_setglobal(lua, "Draw");
return true;
}

View File

@ -1,7 +1,7 @@
#ifndef _API_DRAW_H_
#define _API_DRAW_H_
#include <lua5.3/lua.h>
#include <lua.h>
#include <stdbool.h>
bool loadapi_draw(lua_State *lua);

View File

@ -1,7 +1,7 @@
#ifndef _COMMON_H_
#define _COMMON_H_
#include <lua5.3/lua.h>
#include <lua.h>
#include "cairo_context.h"
extern struct global_context {

View File

@ -1,7 +1,7 @@
#include <lua5.3/lua.h>
#include <lua5.3/luaconf.h>
#include <lua5.3/lualib.h>
#include <lua5.3/lauxlib.h>
#include <lua.h>
#include <luaconf.h>
#include <lualib.h>
#include <lauxlib.h>
#include <signal.h>
#include <stdio.h>
#include <math.h>

View File

@ -10,12 +10,18 @@
xcb_window_t find_subwindow(xcb_connection_t *connection, xcb_window_t win, int w, int h);
xcb_window_t create_root_window(xcb_connection_t *connection, xcb_screen_t *screen) {
fprintf(stderr, "DBG: screen root WID=0x%08x\n", screen->root);
xcb_window_t root = find_subwindow(connection, screen->root, -1, -1);
if (!root) return 0;
fprintf(stderr, "DBG: root WID=0x%08x\n", root);
xcb_window_t parent = find_subwindow(connection, root, screen->width_in_pixels, screen->height_in_pixels);
if (!parent) return 0;
fprintf(stderr, "DBG: parent WID=0x%08x\n", parent);
xcb_window_t wid = xcb_generate_id(connection);
{
@ -87,11 +93,15 @@ xcb_window_t find_subwindow(xcb_connection_t *connection, xcb_window_t win, int
if (!get_window_attributes(connection, children[i], &attrs)) continue;
if (attrs.map_state != 0 && rect.width == w && rect.height == h) {
fprintf(stderr, "DBG: matching window WID=0x%08x x=%d y=%d w=%d h=%d\n", children[i], rect.x, rect.y, rect.width, rect.height);
free(qt_reply);
return children[i];
}
}
free(qt_reply);
}
fprintf(stderr, "ERR: didn't find matching subwindow, returning WID=0x%08x\n", win);
return win;
}