Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make display info **log as** info #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/desktop/desktop_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct kiwmi_desktop_surface {
// The tree is where the config is supposed to put custom decorations (it
// also contains the surface_node)
struct wlr_scene_tree *tree;
struct wlr_scene_node *surface_node;
struct wlr_scene_tree *surface_tree;

struct wlr_scene_tree *popups_tree;

Expand Down
2 changes: 1 addition & 1 deletion include/desktop/layer_shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <stdbool.h>

#include <wayland-server.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/util/box.h>

#include "desktop/desktop_surface.h"
Expand Down
2 changes: 1 addition & 1 deletion include/input/cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct kiwmi_cursor {
};

struct kiwmi_cursor_button_event {
struct wlr_event_pointer_button *wlr_event;
struct wlr_pointer_button_event *wlr_event;
bool handled;
};

Expand Down
4 changes: 2 additions & 2 deletions include/input/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
struct kiwmi_keyboard {
struct wl_list link;
struct kiwmi_server *server;
struct wlr_input_device *device;
struct wlr_keyboard *wlr_keyboard;
struct wl_listener modifiers;
struct wl_listener key;
struct wl_listener device_destroy;
Expand All @@ -39,7 +39,7 @@ struct kiwmi_keyboard_key_event {
};

struct kiwmi_keyboard *
keyboard_create(struct kiwmi_server *server, struct wlr_input_device *device);
keyboard_create(struct kiwmi_server *server, struct wlr_keyboard *device);
void keyboard_destroy(struct kiwmi_keyboard *keyboard);

#endif /* KIWMI_INPUT_KEYBOARD_H */
6 changes: 3 additions & 3 deletions include/input/pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
#define KIWMI_INPUT_POINTER_H

#include <wayland-server.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_pointer.h>

#include "server.h"

struct kiwmi_pointer {
struct wlr_input_device *device;
struct wlr_pointer *pointer;
struct wl_list link;

struct wl_listener device_destroy;
};

struct kiwmi_pointer *
pointer_create(struct kiwmi_server *server, struct wlr_input_device *device);
pointer_create(struct kiwmi_server *server, struct wlr_pointer *pointer);
void pointer_destroy(struct kiwmi_pointer *pointer);

#endif /* KIWMI_INPUT_POINTER_H */
2 changes: 1 addition & 1 deletion include/input/seat.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define KIWMI_INPUT_SEAT_H

#include <wayland-server.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>

#include "desktop/layer_shell.h"
#include "desktop/view.h"
Expand Down
8 changes: 4 additions & 4 deletions kiwmi/desktop/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ desktop_init(struct kiwmi_desktop *desktop)

const float bg_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
desktop->background_rect =
wlr_scene_rect_create(&desktop->scene->node, 0, 0, bg_color);
wlr_scene_rect_create(&desktop->scene->tree, 0, 0, bg_color);
// No point in showing black
wlr_scene_node_set_enabled(&desktop->background_rect->node, false);

// Create a scene-graph tree for each stratum
for (size_t i = 0; i < KIWMI_STRATA_COUNT; ++i) {
desktop->strata[i] = wlr_scene_tree_create(&desktop->scene->node);
desktop->strata[i] = wlr_scene_tree_create(&desktop->scene->tree);
}

wlr_scene_attach_output_layout(desktop->scene, desktop->output_layout);
Expand All @@ -72,7 +72,7 @@ desktop_init(struct kiwmi_desktop *desktop)
wlr_presentation_create(server->wl_display, server->backend);
wlr_scene_set_presentation(desktop->scene, presentation);

desktop->xdg_shell = wlr_xdg_shell_create(server->wl_display);
desktop->xdg_shell = wlr_xdg_shell_create(server->wl_display, 5);
desktop->xdg_shell_new_surface.notify = xdg_shell_new_surface_notify;
wl_signal_add(
&desktop->xdg_shell->events.new_surface,
Expand Down Expand Up @@ -114,7 +114,7 @@ desktop_fini(struct kiwmi_desktop *desktop)
{
wlr_output_layout_destroy(desktop->output_layout);
desktop->output_layout = NULL;
wlr_scene_node_destroy(&desktop->scene->node);
wlr_scene_node_destroy(&desktop->scene->tree.node);
desktop->scene = NULL;
}

Expand Down
19 changes: 13 additions & 6 deletions kiwmi/desktop/desktop_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_xdg_shell.h>

#include "desktop/desktop.h"
Expand Down Expand Up @@ -55,16 +55,23 @@ desktop_surface_from_wlr_surface(struct wlr_surface *surface)
struct kiwmi_desktop_surface *
desktop_surface_at(struct kiwmi_desktop *desktop, double lx, double ly)
{
double sx, sy; // unused
double sx, sy;
struct wlr_scene_node *node_at =
wlr_scene_node_at(&desktop->scene->node, lx, ly, &sx, &sy);
wlr_scene_node_at(&desktop->scene->tree.node, lx, ly, &sx, &sy);

if (!node_at || node_at->type != WLR_SCENE_NODE_SURFACE) {
if (!node_at || node_at->type != WLR_SCENE_NODE_BUFFER) {
return NULL;
}

struct wlr_surface *surface = wlr_scene_surface_from_node(node_at)->surface;
return desktop_surface_from_wlr_surface(surface);
struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node_at);
struct wlr_scene_surface *scene_surface =
wlr_scene_surface_from_buffer(scene_buffer);

if (!scene_surface) {
return NULL;
}

return desktop_surface_from_wlr_surface(scene_surface->surface);
}

struct kiwmi_output *
Expand Down
11 changes: 5 additions & 6 deletions kiwmi/desktop/layer_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ kiwmi_layer_commit_notify(struct wl_listener *listener, void *UNUSED(data))
stratum_from_layer_shell_layer(layer->layer);

wlr_scene_node_reparent(
&layer->desktop_surface.tree->node,
&output->strata[new_stratum]->node);
&layer->desktop_surface.tree->node, output->strata[new_stratum]);
}

if (layer->layer_surface->current.committed != 0) {
Expand Down Expand Up @@ -432,11 +431,11 @@ layer_shell_new_surface_notify(struct wl_listener *listener, void *data)
enum kiwmi_stratum stratum = stratum_from_layer_shell_layer(layer->layer);

layer->desktop_surface.tree =
wlr_scene_tree_create(&output->strata[stratum]->node);
wlr_scene_tree_create(output->strata[stratum]);
layer->desktop_surface.popups_tree =
wlr_scene_tree_create(&output->strata[KIWMI_STRATUM_POPUPS]->node);
layer->desktop_surface.surface_node = wlr_scene_subsurface_tree_create(
&layer->desktop_surface.tree->node, layer->layer_surface->surface);
wlr_scene_tree_create(output->strata[KIWMI_STRATUM_POPUPS]);
layer->desktop_surface.surface_tree = wlr_scene_subsurface_tree_create(
layer->desktop_surface.tree, layer->layer_surface->surface);

wlr_scene_node_set_enabled(&layer->desktop_surface.tree->node, false);
wlr_scene_node_set_enabled(
Expand Down
25 changes: 13 additions & 12 deletions kiwmi/desktop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
#include <wlr/backend.h>
#include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/util/log.h>

Expand Down Expand Up @@ -180,10 +180,10 @@ new_output_notify(struct wl_listener *listener, void *data)

struct kiwmi_pointer *pointer;
wl_list_for_each (pointer, &server->input.pointers, link) {
if (pointer->device->output_name
&& strcmp(pointer->device->output_name, wlr_output->name) == 0) {
if (pointer->pointer->base.name
&& strcmp(pointer->pointer->base.name, wlr_output->name) == 0) {
wlr_cursor_map_input_to_output(
cursor->cursor, pointer->device, wlr_output);
cursor->cursor, &pointer->pointer->base, wlr_output);
}
}

Expand All @@ -199,7 +199,7 @@ new_output_notify(struct wl_listener *listener, void *data)
}

for (size_t i = 0; i < KIWMI_STRATA_COUNT; ++i) {
output->strata[i] = wlr_scene_tree_create(&desktop->strata[i]->node);
output->strata[i] = wlr_scene_tree_create(desktop->strata[i]);
}

wl_signal_init(&output->events.destroy);
Expand All @@ -219,24 +219,25 @@ output_layout_change_notify(struct wl_listener *listener, void *UNUSED(data))
struct kiwmi_desktop *desktop =
wl_container_of(listener, desktop, output_layout_change);

struct wlr_box *ol_box =
wlr_output_layout_get_box(desktop->output_layout, NULL);
struct wlr_box ol_box;
wlr_output_layout_get_box(desktop->output_layout, NULL, &ol_box);
wlr_scene_node_set_position(
&desktop->background_rect->node, ol_box->x, ol_box->y);
&desktop->background_rect->node, ol_box.x, ol_box.y);
wlr_scene_rect_set_size(
desktop->background_rect, ol_box->width, ol_box->height);
desktop->background_rect, ol_box.width, ol_box.height);

struct wlr_output_layout_output *ol_output;
wl_list_for_each (ol_output, &desktop->output_layout->outputs, link) {
struct kiwmi_output *output = ol_output->output->data;

struct wlr_box *box = wlr_output_layout_get_box(
desktop->output_layout, output->wlr_output);
struct wlr_box box;
wlr_output_layout_get_box(
desktop->output_layout, output->wlr_output, &box);

for (size_t i = 0; i < KIWMI_STRATA_COUNT; ++i) {
if (output->strata[i]) {
wlr_scene_node_set_position(
&output->strata[i]->node, box->x, box->y);
&output->strata[i]->node, box.x, box.y);
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions kiwmi/desktop/popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ popup_get_desktop_surface(struct wlr_xdg_popup *popup)
case WLR_XDG_SURFACE_ROLE_POPUP:
parent = xdg_surface->popup->parent;
break;
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
case WLR_XDG_SURFACE_ROLE_TOPLEVEL: {
struct kiwmi_view *view = xdg_surface->data;
return &view->desktop_surface;
}
default:
return NULL;
}
Expand Down Expand Up @@ -109,11 +110,11 @@ popup_attach(

popup_unconstrain(popup, desktop_surface);

struct wlr_scene_node *node =
wlr_scene_xdg_surface_create(&parent_tree->node, popup->base);
if (!node) {
struct wlr_scene_tree *tree =
wlr_scene_xdg_surface_create(parent_tree, popup->base);
if (!tree) {
wlr_log(WLR_ERROR, "failed to attach popup to scene");
return;
}
popup->base->data = node;
popup->base->data = tree;
}
12 changes: 6 additions & 6 deletions kiwmi/desktop/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ view_desktop_surface_get_output(struct kiwmi_desktop_surface *desktop_surface)
// Prefer view center
struct wlr_output *output = wlr_output_layout_output_at(
view->desktop->output_layout,
lx + view->geom.width / 2,
ly + view->geom.height / 2);
lx + (float)view->geom.width / 2,
ly + (float)view->geom.height / 2);
if (output) {
return (struct kiwmi_output *)output->data;
}
Expand Down Expand Up @@ -248,10 +248,10 @@ view_create(
wl_signal_init(&view->events.post_render);
wl_signal_init(&view->events.pre_render);

view->desktop_surface.tree = wlr_scene_tree_create(
&view->desktop->strata[KIWMI_STRATUM_NORMAL]->node);
view->desktop_surface.popups_tree = wlr_scene_tree_create(
&view->desktop->strata[KIWMI_STRATUM_POPUPS]->node);
view->desktop_surface.tree =
wlr_scene_tree_create(view->desktop->strata[KIWMI_STRATUM_NORMAL]);
view->desktop_surface.popups_tree =
wlr_scene_tree_create(view->desktop->strata[KIWMI_STRATUM_POPUPS]);

view_set_hidden(view, true);
wlr_scene_node_lower_to_bottom(&view->desktop_surface.tree->node);
Expand Down
12 changes: 6 additions & 6 deletions kiwmi/desktop/xdg_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ xdg_shell_view_close(struct kiwmi_view *view)
struct wlr_xdg_surface *surface = view->xdg_surface;

if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL && surface->toplevel) {
wlr_xdg_toplevel_send_close(surface);
wlr_xdg_toplevel_send_close(surface->toplevel);
}
}

Expand Down Expand Up @@ -166,7 +166,7 @@ xdg_shell_view_get_string_prop(
static void
xdg_shell_view_set_activated(struct kiwmi_view *view, bool activated)
{
wlr_xdg_toplevel_set_activated(view->xdg_surface, activated);
wlr_xdg_toplevel_set_activated(view->xdg_surface->toplevel, activated);
}

static void
Expand All @@ -175,13 +175,13 @@ xdg_shell_view_set_size(
uint32_t width,
uint32_t height)
{
wlr_xdg_toplevel_set_size(view->xdg_surface, width, height);
wlr_xdg_toplevel_set_size(view->xdg_surface->toplevel, width, height);
}

static void
xdg_shell_view_set_tiled(struct kiwmi_view *view, enum wlr_edges edges)
{
wlr_xdg_toplevel_set_tiled(view->xdg_surface, edges);
wlr_xdg_toplevel_set_tiled(view->xdg_surface->toplevel, edges);
}

static const struct kiwmi_view_impl xdg_shell_view_impl = {
Expand Down Expand Up @@ -233,8 +233,8 @@ xdg_shell_new_surface_notify(struct wl_listener *listener, void *data)
view->xdg_surface = xdg_surface;
view->wlr_surface = xdg_surface->surface;

view->desktop_surface.surface_node = wlr_scene_xdg_surface_create(
&view->desktop_surface.tree->node, xdg_surface);
view->desktop_surface.surface_tree =
wlr_scene_xdg_surface_create(view->desktop_surface.tree, xdg_surface);

view->map.notify = xdg_surface_map_notify;
wl_signal_add(&xdg_surface->events.map, &view->map);
Expand Down
Loading