mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-23 05:15:58 +01:00
Merge pull request #51 from nyorain/region
Implement wlr_region using pixman
This commit is contained in:
commit
6345d6deed
7 changed files with 60 additions and 1 deletions
|
@ -7,6 +7,7 @@ packages:
|
||||||
- libinput
|
- libinput
|
||||||
- libxkbcommon
|
- libxkbcommon
|
||||||
- libcap
|
- libcap
|
||||||
|
- pixman
|
||||||
- clang
|
- clang
|
||||||
sources:
|
sources:
|
||||||
- https://git.sr.ht/~sircmpwn/wlroots
|
- https://git.sr.ht/~sircmpwn/wlroots
|
||||||
|
|
|
@ -14,6 +14,7 @@ arch:
|
||||||
- wayland-protocols
|
- wayland-protocols
|
||||||
- mesa
|
- mesa
|
||||||
- libinput
|
- libinput
|
||||||
|
- pixman
|
||||||
- libxkbcommon
|
- libxkbcommon
|
||||||
- libcap
|
- libcap
|
||||||
script:
|
script:
|
||||||
|
|
|
@ -8,7 +8,6 @@ WIP - [Status](https://github.com/SirCmpwn/wlroots/issues/9)
|
||||||
|
|
||||||
Install dependencies:
|
Install dependencies:
|
||||||
|
|
||||||
* cmake
|
|
||||||
* wayland
|
* wayland
|
||||||
* wayland-protocols
|
* wayland-protocols
|
||||||
* EGL
|
* EGL
|
||||||
|
@ -17,6 +16,7 @@ Install dependencies:
|
||||||
* GBM
|
* GBM
|
||||||
* libinput
|
* libinput
|
||||||
* udev
|
* udev
|
||||||
|
* pixman
|
||||||
* systemd (optional, for logind support)
|
* systemd (optional, for logind support)
|
||||||
* libcap (optional, for capability support)
|
* libcap (optional, for capability support)
|
||||||
* asciidoc (optional, for man pages)
|
* asciidoc (optional, for man pages)
|
||||||
|
|
10
include/wlr/types/wlr_region.h
Normal file
10
include/wlr/types/wlr_region.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef _WLR_TYPES_REGION_H
|
||||||
|
#define _WLR_TYPES_REGION_H
|
||||||
|
|
||||||
|
struct wl_resource;
|
||||||
|
|
||||||
|
// Implements the given resource as region.
|
||||||
|
// Sets the associated pixman_region32_t as userdata.
|
||||||
|
void wlr_region_create(struct wl_resource *res);
|
||||||
|
|
||||||
|
#endif
|
|
@ -30,6 +30,7 @@ dep_gbm = dependency('gbm')
|
||||||
dep_libinput = dependency('libinput')
|
dep_libinput = dependency('libinput')
|
||||||
dep_xkbcommon = dependency('xkbcommon')
|
dep_xkbcommon = dependency('xkbcommon')
|
||||||
dep_udev = dependency('libudev')
|
dep_udev = dependency('libudev')
|
||||||
|
dep_pixman = dependency('pixman-1')
|
||||||
dep_libcap = dependency('libcap', required: false)
|
dep_libcap = dependency('libcap', required: false)
|
||||||
dep_systemd = dependency('libsystemd', required: false)
|
dep_systemd = dependency('libsystemd', required: false)
|
||||||
dep_math = cc.find_library('m', required: false)
|
dep_math = cc.find_library('m', required: false)
|
||||||
|
@ -46,6 +47,7 @@ all_deps = [
|
||||||
dep_libinput,
|
dep_libinput,
|
||||||
dep_xkbcommon,
|
dep_xkbcommon,
|
||||||
dep_udev,
|
dep_udev,
|
||||||
|
dep_pixman,
|
||||||
dep_libcap,
|
dep_libcap,
|
||||||
dep_systemd,
|
dep_systemd,
|
||||||
dep_math,
|
dep_math,
|
||||||
|
|
|
@ -3,6 +3,7 @@ wlr_files += files(
|
||||||
'wlr_keyboard.c',
|
'wlr_keyboard.c',
|
||||||
'wlr_output.c',
|
'wlr_output.c',
|
||||||
'wlr_pointer.c',
|
'wlr_pointer.c',
|
||||||
|
'wlr_region.c',
|
||||||
'wlr_tablet_pad.c',
|
'wlr_tablet_pad.c',
|
||||||
'wlr_tablet_tool.c',
|
'wlr_tablet_tool.c',
|
||||||
'wlr_touch.c',
|
'wlr_touch.c',
|
||||||
|
|
44
types/wlr_region.c
Normal file
44
types/wlr_region.c
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <wayland-server.h>
|
||||||
|
#include <pixman.h>
|
||||||
|
|
||||||
|
static void region_add(struct wl_client *client, struct wl_resource *resource,
|
||||||
|
int32_t x, int32_t y, int32_t width, int32_t height) {
|
||||||
|
pixman_region32_t *region = wl_resource_get_user_data(resource);
|
||||||
|
pixman_region32_union_rect(region, region, x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void region_subtract(struct wl_client *client, struct wl_resource *resource,
|
||||||
|
int32_t x, int32_t y, int32_t width, int32_t height) {
|
||||||
|
pixman_region32_t *region = wl_resource_get_user_data(resource);
|
||||||
|
pixman_region32_union_rect(region, region, x, y, width, height);
|
||||||
|
|
||||||
|
pixman_region32_t rect;
|
||||||
|
pixman_region32_init_rect(&rect, x, y, width, height);
|
||||||
|
pixman_region32_subtract(region, region, &rect);
|
||||||
|
pixman_region32_fini(&rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void region_destroy(struct wl_client *client, struct wl_resource *resource) {
|
||||||
|
wl_resource_destroy(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct wl_region_interface region_interface = {
|
||||||
|
region_destroy,
|
||||||
|
region_add,
|
||||||
|
region_subtract,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void destroy_region(struct wl_resource *resource) {
|
||||||
|
pixman_region32_t *reg = wl_resource_get_user_data(resource);
|
||||||
|
pixman_region32_fini(reg);
|
||||||
|
free(reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_region_create(struct wl_resource *res) {
|
||||||
|
pixman_region32_t *region = calloc(1, sizeof(pixman_region32_t));
|
||||||
|
pixman_region32_init(region);
|
||||||
|
wl_resource_set_implementation(res, ®ion_interface, region, destroy_region);
|
||||||
|
}
|
Loading…
Reference in a new issue