aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-08-09 11:09:36 -0400
committerGitHub <noreply@github.com>2017-08-09 11:09:36 -0400
commit6345d6deeda014b8a95ef4a40eef938b552ff153 (patch)
tree75af61ae2c792c648b5f13e830ff1272574c3c00
parenta77fac07603028c869e7d3d1dee58d6972d29498 (diff)
parent60ecbe42468e74dad6535903cac571757f8052cc (diff)
Merge pull request #51 from nyorain/region
Implement wlr_region using pixman
-rw-r--r--.build.yml1
-rw-r--r--.travis.yml1
-rw-r--r--README.md2
-rw-r--r--include/wlr/types/wlr_region.h10
-rw-r--r--meson.build2
-rw-r--r--types/meson.build1
-rw-r--r--types/wlr_region.c44
7 files changed, 60 insertions, 1 deletions
diff --git a/.build.yml b/.build.yml
index a9c11445..98ff7f89 100644
--- a/.build.yml
+++ b/.build.yml
@@ -7,6 +7,7 @@ packages:
- libinput
- libxkbcommon
- libcap
+ - pixman
- clang
sources:
- https://git.sr.ht/~sircmpwn/wlroots
diff --git a/.travis.yml b/.travis.yml
index 5684de93..52d6eae4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,6 +14,7 @@ arch:
- wayland-protocols
- mesa
- libinput
+ - pixman
- libxkbcommon
- libcap
script:
diff --git a/README.md b/README.md
index 98c359fc..831b900f 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,6 @@ WIP - [Status](https://github.com/SirCmpwn/wlroots/issues/9)
Install dependencies:
-* cmake
* wayland
* wayland-protocols
* EGL
@@ -17,6 +16,7 @@ Install dependencies:
* GBM
* libinput
* udev
+* pixman
* systemd (optional, for logind support)
* libcap (optional, for capability support)
* asciidoc (optional, for man pages)
diff --git a/include/wlr/types/wlr_region.h b/include/wlr/types/wlr_region.h
new file mode 100644
index 00000000..9fff0150
--- /dev/null
+++ b/include/wlr/types/wlr_region.h
@@ -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
diff --git a/meson.build b/meson.build
index a6c8dd6c..b4a7fdc4 100644
--- a/meson.build
+++ b/meson.build
@@ -30,6 +30,7 @@ dep_gbm = dependency('gbm')
dep_libinput = dependency('libinput')
dep_xkbcommon = dependency('xkbcommon')
dep_udev = dependency('libudev')
+dep_pixman = dependency('pixman-1')
dep_libcap = dependency('libcap', required: false)
dep_systemd = dependency('libsystemd', required: false)
dep_math = cc.find_library('m', required: false)
@@ -46,6 +47,7 @@ all_deps = [
dep_libinput,
dep_xkbcommon,
dep_udev,
+ dep_pixman,
dep_libcap,
dep_systemd,
dep_math,
diff --git a/types/meson.build b/types/meson.build
index 323806c6..89e36ac0 100644
--- a/types/meson.build
+++ b/types/meson.build
@@ -3,6 +3,7 @@ wlr_files += files(
'wlr_keyboard.c',
'wlr_output.c',
'wlr_pointer.c',
+ 'wlr_region.c',
'wlr_tablet_pad.c',
'wlr_tablet_tool.c',
'wlr_touch.c',
diff --git a/types/wlr_region.c b/types/wlr_region.c
new file mode 100644
index 00000000..a1c45542
--- /dev/null
+++ b/types/wlr_region.c
@@ -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, &region_interface, region, destroy_region);
+}