Merged output.cs and input.cs
This commit is contained in:
parent
83c38f6e5c
commit
1ba4b518fa
9 changed files with 117 additions and 181 deletions
|
@ -9,6 +9,17 @@
|
|||
#define KIWMI_DESKTOP_OUTPUT_H
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
|
||||
#include "kiwmi/desktop/desktop.h"
|
||||
|
||||
struct kiwmi_output {
|
||||
struct wl_list link;
|
||||
struct kiwmi_desktop *desktop;
|
||||
struct wlr_output *wlr_output;
|
||||
struct wl_listener frame;
|
||||
struct wl_listener destroy;
|
||||
};
|
||||
|
||||
void new_output_notify(struct wl_listener *listener, void *data);
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
/* 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 */
|
|
@ -1,27 +0,0 @@
|
|||
/* 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_OUTPUT_H
|
||||
#define KIWMI_OUTPUT_H
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
|
||||
#include "kiwmi/desktop/desktop.h"
|
||||
|
||||
struct kiwmi_output {
|
||||
struct wl_list link;
|
||||
struct kiwmi_desktop *desktop;
|
||||
struct wlr_output *wlr_output;
|
||||
struct wl_listener frame;
|
||||
struct wl_listener destroy;
|
||||
};
|
||||
|
||||
struct kiwmi_output *
|
||||
output_create(struct wlr_output *wlr_output, struct kiwmi_desktop *desktop);
|
||||
|
||||
#endif /* KIWMI_OUTPUT_H */
|
|
@ -7,15 +7,78 @@
|
|||
|
||||
#include "kiwmi/desktop/output.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "kiwmi/output.h"
|
||||
#include "kiwmi/server.h"
|
||||
#include "kiwmi/desktop/desktop.h"
|
||||
|
||||
static void
|
||||
output_frame_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct kiwmi_output *output = wl_container_of(listener, output, frame);
|
||||
struct wlr_output *wlr_output = data;
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(wlr_output->backend);
|
||||
|
||||
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);
|
||||
wlr_renderer_clear(renderer, (float[]){0.18f, 0.20f, 0.25f, 1.0f});
|
||||
wlr_output_render_software_cursors(wlr_output, 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))
|
||||
{
|
||||
struct kiwmi_output *output = wl_container_of(listener, output, destroy);
|
||||
|
||||
wlr_output_layout_remove(output->desktop->output_layout, output->wlr_output);
|
||||
|
||||
wl_list_remove(&output->link);
|
||||
wl_list_remove(&output->frame.link);
|
||||
wl_list_remove(&output->destroy.link);
|
||||
|
||||
free(output);
|
||||
}
|
||||
|
||||
static struct kiwmi_output *
|
||||
output_create(struct wlr_output *wlr_output, struct kiwmi_desktop *desktop)
|
||||
{
|
||||
struct kiwmi_output *output = calloc(1, sizeof(*output));
|
||||
if (!output) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
output->wlr_output = wlr_output;
|
||||
output->desktop = desktop;
|
||||
|
||||
output->frame.notify = output_frame_notify;
|
||||
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
||||
|
||||
output->destroy.notify = output_destroy_notify;
|
||||
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void
|
||||
new_output_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/* 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"
|
||||
#include "kiwmi/input/input.h"
|
||||
#include "kiwmi/input/keyboard.h"
|
||||
|
||||
static void
|
||||
new_pointer(struct kiwmi_input *input, struct wlr_input_device *device)
|
||||
{
|
||||
wlr_cursor_attach_input_device(input->cursor->cursor, device);
|
||||
}
|
||||
|
||||
static void
|
||||
new_keyboard(struct kiwmi_input *input, struct wlr_input_device *device)
|
||||
{
|
||||
struct kiwmi_server *server = wl_container_of(input, server, input);
|
||||
|
||||
struct kiwmi_keyboard *keyboard = keyboard_create(server, device);
|
||||
if (!keyboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
wl_list_insert(&input->keyboards, &keyboard->link);
|
||||
}
|
||||
|
||||
void
|
||||
new_input_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct kiwmi_input *input = wl_container_of(listener, input, new_input);
|
||||
struct wlr_input_device *device = data;
|
||||
|
||||
wlr_log(WLR_DEBUG, "New input %p: %s", device, device->name);
|
||||
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
new_pointer(input, device);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
new_keyboard(input, device);
|
||||
break;
|
||||
default:
|
||||
// NOT HANDLED
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -8,10 +8,51 @@
|
|||
#include "kiwmi/input/input.h"
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "kiwmi/input.h"
|
||||
#include "kiwmi/server.h"
|
||||
#include "kiwmi/input/keyboard.h"
|
||||
|
||||
static void
|
||||
new_pointer(struct kiwmi_input *input, struct wlr_input_device *device)
|
||||
{
|
||||
wlr_cursor_attach_input_device(input->cursor->cursor, device);
|
||||
}
|
||||
|
||||
static void
|
||||
new_keyboard(struct kiwmi_input *input, struct wlr_input_device *device)
|
||||
{
|
||||
struct kiwmi_server *server = wl_container_of(input, server, input);
|
||||
|
||||
struct kiwmi_keyboard *keyboard = keyboard_create(server, device);
|
||||
if (!keyboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
wl_list_insert(&input->keyboards, &keyboard->link);
|
||||
}
|
||||
|
||||
static void
|
||||
new_input_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct kiwmi_input *input = wl_container_of(listener, input, new_input);
|
||||
struct wlr_input_device *device = data;
|
||||
|
||||
wlr_log(WLR_DEBUG, "New input %p: %s", device, device->name);
|
||||
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
new_pointer(input, device);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
new_keyboard(input, device);
|
||||
break;
|
||||
default:
|
||||
// NOT HANDLED
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
input_init(struct kiwmi_input *input)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
kiwmi_sources = files(
|
||||
'main.c',
|
||||
'input.c',
|
||||
'output.c',
|
||||
'server.c',
|
||||
'desktop/desktop.c',
|
||||
'desktop/output.c',
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
/* 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/output.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
|
||||
#include "kiwmi/desktop/desktop.h"
|
||||
|
||||
static void
|
||||
output_frame_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct kiwmi_output *output = wl_container_of(listener, output, frame);
|
||||
struct wlr_output *wlr_output = data;
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(wlr_output->backend);
|
||||
|
||||
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);
|
||||
wlr_renderer_clear(renderer, (float[]){0.18f, 0.20f, 0.25f, 1.0f});
|
||||
wlr_output_render_software_cursors(wlr_output, 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))
|
||||
{
|
||||
struct kiwmi_output *output = wl_container_of(listener, output, destroy);
|
||||
|
||||
wlr_output_layout_remove(output->desktop->output_layout, output->wlr_output);
|
||||
|
||||
wl_list_remove(&output->link);
|
||||
wl_list_remove(&output->frame.link);
|
||||
wl_list_remove(&output->destroy.link);
|
||||
|
||||
free(output);
|
||||
}
|
||||
|
||||
struct kiwmi_output *
|
||||
output_create(struct wlr_output *wlr_output, struct kiwmi_desktop *desktop)
|
||||
{
|
||||
struct kiwmi_output *output = calloc(1, sizeof(*output));
|
||||
if (!output) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
output->wlr_output = wlr_output;
|
||||
output->desktop = desktop;
|
||||
|
||||
output->frame.notify = output_frame_notify;
|
||||
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
||||
|
||||
output->destroy.notify = output_destroy_notify;
|
||||
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
|
||||
|
||||
return output;
|
||||
}
|
|
@ -15,7 +15,6 @@
|
|||
#include <wlr/util/log.h>
|
||||
|
||||
#include "kiwmi/desktop/desktop.h"
|
||||
#include "kiwmi/input.h"
|
||||
#include "kiwmi/input/cursor.h"
|
||||
#include "kiwmi/input/input.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue