aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/dmabuf-capture.c1
-rw-r--r--examples/idle.c4
-rw-r--r--examples/input-method.c2
-rw-r--r--examples/meson.build21
-rw-r--r--examples/output-layout.c1
-rw-r--r--examples/screencopy.c31
-rw-r--r--examples/screenshot.c36
7 files changed, 35 insertions, 61 deletions
diff --git a/examples/dmabuf-capture.c b/examples/dmabuf-capture.c
index abdb146a..ebbe0a70 100644
--- a/examples/dmabuf-capture.c
+++ b/examples/dmabuf-capture.c
@@ -1,4 +1,3 @@
-#define _XOPEN_SOURCE 700
#define _POSIX_C_SOURCE 199309L
#include <libavformat/avformat.h>
#include <libavutil/display.h>
diff --git a/examples/idle.c b/examples/idle.c
index 3e1565ca..a6a4f5c0 100644
--- a/examples/idle.c
+++ b/examples/idle.c
@@ -1,12 +1,12 @@
#include <getopt.h>
#include <pthread.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wayland-client-protocol.h>
#include <wayland-client.h>
-#include <wlr/util/log.h>
#include "idle-client-protocol.h"
static struct org_kde_kwin_idle *idle_manager = NULL;
@@ -109,8 +109,6 @@ void *main_loop(void *data) {
}
int main(int argc, char *argv[]) {
- wlr_log_init(WLR_DEBUG, NULL);
-
if (parse_args(argc, argv) != 0) {
return -1;
}
diff --git a/examples/input-method.c b/examples/input-method.c
index 3e485d1c..4e375306 100644
--- a/examples/input-method.c
+++ b/examples/input-method.c
@@ -1,6 +1,7 @@
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -9,7 +10,6 @@
#include <unistd.h>
#include <wayland-client.h>
#include <wayland-egl.h>
-#include <wlr/render/egl.h>
#include "input-method-unstable-v2-client-protocol.h"
#include "text-input-unstable-v3-client-protocol.h"
#include "xdg-shell-client-protocol.h"
diff --git a/examples/meson.build b/examples/meson.build
index 369c7049..cbf39347 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -55,11 +55,11 @@ examples = {
},
'screenshot': {
'src': 'screenshot.c',
- 'dep': [wayland_client, wlr_protos, wlroots],
+ 'dep': [wayland_client, wlr_protos, rt],
},
'idle': {
'src': 'idle.c',
- 'dep': [wayland_client, wlr_protos, wlroots, threads],
+ 'dep': [wayland_client, wlr_protos, threads],
},
'idle-inhibit': {
'src': 'idle-inhibit.c',
@@ -75,7 +75,7 @@ examples = {
},
'gamma-control': {
'src': 'gamma-control.c',
- 'dep': [wayland_client, wayland_cursor, wlr_protos, wlroots],
+ 'dep': [wayland_client, wayland_cursor, wlr_protos, math],
},
'pointer-constraints': {
'src': 'pointer-constraints.c',
@@ -91,25 +91,24 @@ examples = {
threads,
wayland_client,
wlr_protos,
- wlroots,
],
},
'screencopy': {
'src': 'screencopy.c',
- 'dep': [libpng, wayland_client, wlr_protos, wlroots],
+ 'dep': [libpng, wayland_client, wlr_protos, rt],
},
'toplevel-decoration': {
'src': 'toplevel-decoration.c',
'dep': [wayland_client, wlr_protos, wlroots],
},
'input-method': {
- 'src': 'input-method.c',
- 'dep': [wayland_client, wlr_protos, wlroots] + libepoll,
- },
+ 'src': 'input-method.c',
+ 'dep': [wayland_client, wlr_protos] + libepoll,
+ },
'text-input': {
- 'src': 'text-input.c',
- 'dep': [wayland_cursor, wayland_client, wlr_protos, wlroots],
- },
+ 'src': 'text-input.c',
+ 'dep': [wayland_cursor, wayland_client, wlr_protos, wlroots],
+ },
}
foreach name, info : examples
diff --git a/examples/output-layout.c b/examples/output-layout.c
index 2d1bc58b..440b3188 100644
--- a/examples/output-layout.c
+++ b/examples/output-layout.c
@@ -1,5 +1,4 @@
#define _POSIX_C_SOURCE 200112L
-#define _XOPEN_SOURCE 700
#include <GLES2/gl2.h>
#include <limits.h>
#include <math.h>
diff --git a/examples/screencopy.c b/examples/screencopy.c
index 4e58cd3b..82edcb9c 100644
--- a/examples/screencopy.c
+++ b/examples/screencopy.c
@@ -21,8 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-#define _XOPEN_SOURCE 700
-#define _POSIX_C_SOURCE 199309L
+#define _POSIX_C_SOURCE 200112L
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -65,12 +64,17 @@ static const struct format formats[] = {
{WL_SHM_FORMAT_ABGR8888, false},
};
-static int backingfile(off_t size) {
- char template[] = "/tmp/wlroots-shared-XXXXXX";
- int fd = mkstemp(template);
+static struct wl_buffer *create_shm_buffer(enum wl_shm_format fmt,
+ int width, int height, int stride, void **data_out) {
+ int size = stride * height;
+
+ const char shm_name[] = "/wlroots-screencopy";
+ int fd = shm_open(shm_name, O_RDWR | O_CREAT | O_EXCL, 0);
if (fd < 0) {
- return -1;
+ fprintf(stderr, "shm_open failed\n");
+ return NULL;
}
+ shm_unlink(shm_name);
int ret;
while ((ret = ftruncate(fd, size)) == EINTR) {
@@ -78,20 +82,7 @@ static int backingfile(off_t size) {
}
if (ret < 0) {
close(fd);
- return -1;
- }
-
- unlink(template);
- return fd;
-}
-
-static struct wl_buffer *create_shm_buffer(enum wl_shm_format fmt,
- int width, int height, int stride, void **data_out) {
- int size = stride * height;
-
- int fd = backingfile(size);
- if (fd < 0) {
- fprintf(stderr, "creating a buffer file for %d B failed: %m\n", size);
+ fprintf(stderr, "ftruncate failed\n");
return NULL;
}
diff --git a/examples/screenshot.c b/examples/screenshot.c
index aa4dcaa0..914f3994 100644
--- a/examples/screenshot.c
+++ b/examples/screenshot.c
@@ -21,8 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-#define _XOPEN_SOURCE 700
-#define _POSIX_C_SOURCE 199309L
+#define _POSIX_C_SOURCE 200112L
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -35,7 +34,6 @@
#include <sys/wait.h>
#include <unistd.h>
#include <wayland-client.h>
-#include <wlr/util/log.h>
#include "screenshooter-client-protocol.h"
static struct wl_shm *shm = NULL;
@@ -111,12 +109,18 @@ static const struct wl_registry_listener registry_listener = {
.global_remove = handle_global_remove,
};
-static int backingfile(off_t size) {
- char template[] = "/tmp/wlroots-shared-XXXXXX";
- int fd = mkstemp(template);
+static struct wl_buffer *create_shm_buffer(int width, int height,
+ void **data_out) {
+ int stride = width * 4;
+ int size = stride * height;
+
+ const char shm_name[] = "/wlroots-screenshot";
+ int fd = shm_open(shm_name, O_RDWR | O_CREAT | O_EXCL, 0);
if (fd < 0) {
- return -1;
+ fprintf(stderr, "shm_open failed\n");
+ return NULL;
}
+ shm_unlink(shm_name);
int ret;
while ((ret = ftruncate(fd, size)) == EINTR) {
@@ -124,21 +128,7 @@ static int backingfile(off_t size) {
}
if (ret < 0) {
close(fd);
- return -1;
- }
-
- unlink(template);
- return fd;
-}
-
-static struct wl_buffer *create_shm_buffer(int width, int height,
- void **data_out) {
- int stride = width * 4;
- int size = stride * height;
-
- int fd = backingfile(size);
- if (fd < 0) {
- fprintf(stderr, "creating a buffer file for %d B failed: %m\n", size);
+ fprintf(stderr, "ftruncate failed\n");
return NULL;
}
@@ -200,8 +190,6 @@ static void write_image(const char *filename, int width, int height,
}
int main(int argc, char *argv[]) {
- wlr_log_init(WLR_DEBUG, NULL);
-
struct wl_display * display = wl_display_connect(NULL);
if (display == NULL) {
fprintf(stderr, "failed to create display: %m\n");