-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from tiosgz/map-pointer-output
- Loading branch information
Showing
6 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Copyright (c), Niclas Meyer <[email protected]> | ||
* | ||
* 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_POINTER_H | ||
#define KIWMI_INPUT_POINTER_H | ||
|
||
#include <wayland-server.h> | ||
#include <wlr/types/wlr_input_device.h> | ||
|
||
#include "server.h" | ||
|
||
struct kiwmi_pointer { | ||
struct wlr_input_device *device; | ||
struct wl_list link; | ||
|
||
struct wl_listener device_destroy; | ||
}; | ||
|
||
struct kiwmi_pointer * | ||
pointer_create(struct kiwmi_server *server, struct wlr_input_device *device); | ||
void pointer_destroy(struct kiwmi_pointer *pointer); | ||
|
||
#endif /* KIWMI_INPUT_POINTER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* Copyright (c), Niclas Meyer <[email protected]> | ||
* | ||
* 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 "input/pointer.h" | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include <wayland-server.h> | ||
#include <wlr/types/wlr_cursor.h> | ||
#include <wlr/types/wlr_input_device.h> | ||
|
||
#include "desktop/output.h" | ||
#include "input/cursor.h" | ||
#include "input/input.h" | ||
#include "server.h" | ||
|
||
static void | ||
pointer_destroy_notify(struct wl_listener *listener, void *UNUSED(data)) | ||
{ | ||
struct kiwmi_pointer *pointer = | ||
wl_container_of(listener, pointer, device_destroy); | ||
|
||
pointer_destroy(pointer); | ||
} | ||
|
||
struct kiwmi_pointer * | ||
pointer_create(struct kiwmi_server *server, struct wlr_input_device *device) | ||
{ | ||
wlr_cursor_attach_input_device(server->input.cursor->cursor, device); | ||
|
||
struct kiwmi_pointer *pointer = malloc(sizeof(*pointer)); | ||
if (!pointer) { | ||
return NULL; | ||
} | ||
|
||
pointer->device = device; | ||
|
||
pointer->device_destroy.notify = pointer_destroy_notify; | ||
wl_signal_add(&device->events.destroy, &pointer->device_destroy); | ||
|
||
if (device->output_name) { | ||
struct kiwmi_output *output; | ||
wl_list_for_each (output, &server->desktop.outputs, link) { | ||
if (strcmp(device->output_name, output->wlr_output->name) == 0) { | ||
wlr_cursor_map_input_to_output( | ||
server->input.cursor->cursor, device, output->wlr_output); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return pointer; | ||
} | ||
|
||
void | ||
pointer_destroy(struct kiwmi_pointer *pointer) | ||
{ | ||
wl_list_remove(&pointer->device_destroy.link); | ||
wl_list_remove(&pointer->link); | ||
|
||
free(pointer); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters