Render cursors
This commit is contained in:
parent
1e01e3f74e
commit
45e5f6235e
6 changed files with 74 additions and 6 deletions
15
include/kiwmi/input.h
Normal file
15
include/kiwmi/input.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* Copyright (c), Charlotte Meyer <dev@buffet.sh>
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#ifndef KIWMI_INPUT_H
|
||||
#define KIWMI_INPUT_H
|
||||
|
||||
#include <wayland-server.h>
|
||||
|
||||
void new_input_notify(struct wl_listener *listener, void *data);
|
||||
|
||||
#endif /* KIWMI_INPUT_H */
|
|
@ -26,6 +26,7 @@ struct kiwmi_server {
|
|||
struct wl_list outputs; // struct kiwmi_output::link
|
||||
struct wl_listener new_output;
|
||||
struct kiwmi_cursor *cursor;
|
||||
struct wl_listener new_input;
|
||||
};
|
||||
|
||||
bool server_init(struct kiwmi_server *server);
|
||||
|
|
38
kiwmi/input.c
Normal file
38
kiwmi/input.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* Copyright (c), Charlotte Meyer <dev@buffet.sh>
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "kiwmi/input.h"
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "kiwmi/server.h"
|
||||
|
||||
static void
|
||||
new_pointer(struct kiwmi_server *server, struct wlr_input_device *device)
|
||||
{
|
||||
wlr_cursor_attach_input_device(server->cursor->cursor, device);
|
||||
}
|
||||
|
||||
void
|
||||
new_input_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct kiwmi_server *server = wl_container_of(listener, server, new_input);
|
||||
struct wlr_input_device *device = data;
|
||||
|
||||
wlr_log(WLR_DEBUG, "Adding input device: '%s'", device->name);
|
||||
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
new_pointer(server, device);
|
||||
break;
|
||||
default:
|
||||
// NOT HANDLED
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
kiwmi_sources = files(
|
||||
'main.c',
|
||||
'server.c',
|
||||
'input.c',
|
||||
'output.c',
|
||||
'desktop/output.c',
|
||||
'input/cursor.c',
|
||||
|
|
|
@ -23,17 +23,26 @@ output_frame_notify(struct wl_listener *listener, void *data)
|
|||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(wlr_output->backend);
|
||||
|
||||
wlr_output_make_current(wlr_output, NULL);
|
||||
wlr_renderer_begin(renderer, wlr_output->width, wlr_output->height);
|
||||
if (!wlr_output_make_current(wlr_output, NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
wlr_output_effective_resolution(wlr_output, &width, &height);
|
||||
|
||||
{
|
||||
wlr_renderer_begin(renderer, width, height);
|
||||
float color[] = {0.18f, 0.20f, 0.25f, 1.0f};
|
||||
wlr_renderer_clear(renderer, color);
|
||||
wlr_output_render_software_cursors(wlr_output, NULL);
|
||||
wlr_output_swap_buffers(wlr_output, NULL, NULL);
|
||||
}
|
||||
wlr_renderer_end(renderer);
|
||||
}
|
||||
|
||||
wlr_output_swap_buffers(wlr_output, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
output_destroy_notify(struct wl_listener *listener, void *UNUSED(data))
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <wlr/util/log.h>
|
||||
|
||||
#include "kiwmi/desktop/output.h"
|
||||
#include "kiwmi/input.h"
|
||||
#include "kiwmi/input/cursor.h"
|
||||
|
||||
bool
|
||||
|
@ -42,6 +43,8 @@ server_init(struct kiwmi_server *server)
|
|||
server->data_device_manager =
|
||||
wlr_data_device_manager_create(server->wl_display);
|
||||
|
||||
server->output_layout = wlr_output_layout_create();
|
||||
|
||||
server->cursor = cursor_create(server->output_layout);
|
||||
if (!server->cursor) {
|
||||
wlr_log(WLR_ERROR, "Failed to create cursor");
|
||||
|
@ -50,13 +53,14 @@ server_init(struct kiwmi_server *server)
|
|||
return false;
|
||||
}
|
||||
|
||||
server->output_layout = wlr_output_layout_create();
|
||||
|
||||
wl_list_init(&server->outputs);
|
||||
|
||||
server->new_output.notify = new_output_notify;
|
||||
wl_signal_add(&server->backend->events.new_output, &server->new_output);
|
||||
|
||||
server->new_input.notify = new_input_notify;
|
||||
wl_signal_add(&server->backend->events.new_input, &server->new_input);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue