Add kiwmi:unfocus(), clang-format
This commit is contained in:
parent
4322717ba7
commit
c45dd269e7
7 changed files with 61 additions and 36 deletions
|
@ -93,7 +93,6 @@ desktop_active_output(struct kiwmi_server *server)
|
|||
return output;
|
||||
}
|
||||
|
||||
|
||||
// 2. focused view center
|
||||
if (!wl_list_empty(&server->desktop.views)) {
|
||||
struct kiwmi_view *view;
|
||||
|
@ -104,7 +103,8 @@ desktop_active_output(struct kiwmi_server *server)
|
|||
double lx = view->geom.x + view->geom.width / 2;
|
||||
double ly = view->geom.y + view->geom.height / 2;
|
||||
|
||||
struct wlr_output *wlr_output = wlr_output_layout_output_at(server->desktop.output_layout, lx, ly);
|
||||
struct wlr_output *wlr_output =
|
||||
wlr_output_layout_output_at(server->desktop.output_layout, lx, ly);
|
||||
return wlr_output->data;
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,7 @@ desktop_active_output(struct kiwmi_server *server)
|
|||
double lx = server->input.cursor->cursor->x;
|
||||
double ly = server->input.cursor->cursor->y;
|
||||
|
||||
struct wlr_output *wlr_output = wlr_output_layout_output_at(server->desktop.output_layout, lx, ly);
|
||||
struct wlr_output *wlr_output =
|
||||
wlr_output_layout_output_at(server->desktop.output_layout, lx, ly);
|
||||
return wlr_output->data;
|
||||
}
|
||||
|
|
|
@ -351,9 +351,8 @@ layer_shell_new_surface_notify(struct wl_listener *listener, void *data)
|
|||
layer_surface->namespace);
|
||||
|
||||
if (!layer_surface->output) {
|
||||
struct kiwmi_server *server =
|
||||
wl_container_of(desktop, server, desktop);
|
||||
layer_surface->output = desktop_active_output(server)->wlr_output;
|
||||
struct kiwmi_server *server = wl_container_of(desktop, server, desktop);
|
||||
layer_surface->output = desktop_active_output(server)->wlr_output;
|
||||
}
|
||||
|
||||
struct kiwmi_layer *layer = malloc(sizeof(*layer));
|
||||
|
|
|
@ -41,28 +41,6 @@ seat_focus_surface(struct kiwmi_seat *seat, struct wlr_surface *wlr_surface)
|
|||
&keyboard->modifiers);
|
||||
}
|
||||
|
||||
void
|
||||
seat_focus_view(struct kiwmi_seat *seat, struct kiwmi_view *view)
|
||||
{
|
||||
if (!view) {
|
||||
seat_focus_surface(seat, NULL);
|
||||
}
|
||||
|
||||
struct kiwmi_desktop *desktop = view->desktop;
|
||||
|
||||
if (seat->focused_view) {
|
||||
view_set_activated(seat->focused_view, false);
|
||||
}
|
||||
|
||||
// move view to front
|
||||
wl_list_remove(&view->link);
|
||||
wl_list_insert(&desktop->views, &view->link);
|
||||
|
||||
seat->focused_view = view;
|
||||
view_set_activated(view, true);
|
||||
seat_focus_surface(seat, view->wlr_surface);
|
||||
}
|
||||
|
||||
void
|
||||
seat_focus_layer(struct kiwmi_seat *seat, struct kiwmi_layer *layer)
|
||||
{
|
||||
|
@ -87,6 +65,29 @@ seat_focus_layer(struct kiwmi_seat *seat, struct kiwmi_layer *layer)
|
|||
seat->focused_layer = layer;
|
||||
}
|
||||
|
||||
void
|
||||
seat_focus_view(struct kiwmi_seat *seat, struct kiwmi_view *view)
|
||||
{
|
||||
if (!view) {
|
||||
seat_focus_surface(seat, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
struct kiwmi_desktop *desktop = view->desktop;
|
||||
|
||||
if (seat->focused_view) {
|
||||
view_set_activated(seat->focused_view, false);
|
||||
}
|
||||
|
||||
// move view to front
|
||||
wl_list_remove(&view->link);
|
||||
wl_list_insert(&desktop->views, &view->link);
|
||||
|
||||
seat->focused_view = view;
|
||||
view_set_activated(view, true);
|
||||
seat_focus_surface(seat, view->wlr_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
request_set_cursor_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ l_kiwmi_cursor_output_at_pos(lua_State *L)
|
|||
struct kiwmi_server *server = cursor->server;
|
||||
|
||||
struct wlr_output *wlr_output = wlr_output_layout_output_at(
|
||||
server->desktop.output_layout,cursor->cursor->x, cursor->cursor->y);
|
||||
server->desktop.output_layout, cursor->cursor->x, cursor->cursor->y);
|
||||
|
||||
if (wlr_output) {
|
||||
lua_pushcfunction(L, luaK_kiwmi_output_new);
|
||||
|
|
|
@ -228,6 +228,19 @@ l_kiwmi_server_stop_interactive(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
l_kiwmi_server_unfocus(lua_State *L)
|
||||
{
|
||||
struct kiwmi_object *obj =
|
||||
*(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_server");
|
||||
|
||||
struct kiwmi_server *server = obj->object;
|
||||
|
||||
seat_focus_view(server->input.seat, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
l_kiwmi_server_view_at(lua_State *L)
|
||||
{
|
||||
|
@ -273,6 +286,7 @@ static const luaL_Reg kiwmi_server_methods[] = {
|
|||
{"schedule", l_kiwmi_server_schedule},
|
||||
{"spawn", l_kiwmi_server_spawn},
|
||||
{"stop_interactive", l_kiwmi_server_stop_interactive},
|
||||
{"unfocus", l_kiwmi_server_unfocus},
|
||||
{"view_at", l_kiwmi_server_view_at},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
@ -328,7 +342,9 @@ kiwmi_server_on_output_notify(struct wl_listener *listener, void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
kiwmi_server_on_request_active_output_notify(struct wl_listener *listener, void *data)
|
||||
kiwmi_server_on_request_active_output_notify(
|
||||
struct wl_listener *listener,
|
||||
void *data)
|
||||
{
|
||||
struct kiwmi_lua_callback *lc = wl_container_of(listener, lc, listener);
|
||||
struct kiwmi_server *server = lc->server;
|
||||
|
@ -345,7 +361,10 @@ kiwmi_server_on_request_active_output_notify(struct wl_listener *listener, void
|
|||
struct kiwmi_object *obj;
|
||||
struct kiwmi_object **objp;
|
||||
if (!(objp = luaK_toudata(L, -1, "kiwmi_output"))) {
|
||||
wlr_log(WLR_ERROR, "kiwmi_output expected, got %s", luaL_typename(L, -1));
|
||||
wlr_log(
|
||||
WLR_ERROR,
|
||||
"kiwmi_output expected, got %s",
|
||||
luaL_typename(L, -1));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,12 @@ void *
|
|||
luaK_toudata(lua_State *L, int ud, const char *tname)
|
||||
{
|
||||
void *p = lua_touserdata(L, ud);
|
||||
if (p != NULL) { /* value is a userdata? */
|
||||
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
|
||||
if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
|
||||
lua_pop(L, 2); /* remove both metatables */
|
||||
if (p != NULL) { /* value is a userdata? */
|
||||
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
|
||||
lua_getfield(
|
||||
L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
|
||||
if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
|
||||
lua_pop(L, 2); /* remove both metatables */
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@ Spawn a new process.
|
|||
|
||||
Stops an interactive move or resize.
|
||||
|
||||
#### kiwmi:unfocus()
|
||||
|
||||
Unfocus the currently focused view.
|
||||
|
||||
#### kiwmi:view_at(lx, ly)
|
||||
|
||||
Get the view at a specified position.
|
||||
|
|
Loading…
Reference in a new issue