aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/support/config.c5
-rw-r--r--examples/support/ini.c2
-rw-r--r--include/wlr/types/wlr_output.h2
-rw-r--r--include/wlr/types/wlr_xdg_shell.h10
-rw-r--r--include/wlr/types/wlr_xdg_shell_v6.h10
-rw-r--r--include/wlr/xwayland.h12
-rw-r--r--rootston/config.c5
-rw-r--r--rootston/ini.c2
-rw-r--r--xwayland/xwm.c52
9 files changed, 70 insertions, 30 deletions
diff --git a/examples/support/config.c b/examples/support/config.c
index f0efa594..319be31a 100644
--- a/examples/support/config.c
+++ b/examples/support/config.c
@@ -202,7 +202,10 @@ struct example_config *parse_args(int argc, char *argv[]) {
char cwd[MAXPATHLEN];
if (getcwd(cwd, sizeof(cwd)) != NULL) {
char buf[MAXPATHLEN];
- snprintf(buf, MAXPATHLEN, "%s/%s", cwd, "wlr-example.ini");
+ if (snprintf(buf, MAXPATHLEN, "%s/%s", cwd, "wlr-example.ini") >= MAXPATHLEN) {
+ wlr_log(L_ERROR, "config path too long");
+ exit(1);
+ }
config->config_path = strdup(buf);
} else {
wlr_log(L_ERROR, "could not get cwd");
diff --git a/examples/support/ini.c b/examples/support/ini.c
index 6be9c44a..6bc1eae6 100644
--- a/examples/support/ini.c
+++ b/examples/support/ini.c
@@ -64,7 +64,7 @@ static char* find_chars_or_comment(const char* s, const char* chars)
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
static char* strncpy0(char* dest, const char* src, size_t size)
{
- strncpy(dest, src, size);
+ strncpy(dest, src, size-1);
dest[size - 1] = '\0';
return dest;
}
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index cc03452d..cef3fc5d 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -55,7 +55,7 @@ struct wlr_output {
struct wl_global *wl_global;
struct wl_list wl_resources;
- char name[16];
+ char name[24];
char make[48];
char model[16];
char serial[16];
diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h
index faf398a7..5046339a 100644
--- a/include/wlr/types/wlr_xdg_shell.h
+++ b/include/wlr/types/wlr_xdg_shell.h
@@ -102,6 +102,16 @@ struct wlr_xdg_surface_configure {
struct wlr_xdg_toplevel_state *toplevel_state;
};
+/**
+ * An xdg-surface is a user interface element requiring management by the
+ * compositor. An xdg-surface alone isn't useful, a role should be assigned to
+ * it in order to map it.
+ *
+ * When a surface has a role and is ready to be displayed, the `map` event is
+ * emitted. When a surface should no longer be displayed, the `unmap` event is
+ * emitted. The `unmap` event is guaranted to be emitted before the `destroy`
+ * event if the view is destroyed when mapped.
+ */
struct wlr_xdg_surface {
struct wlr_xdg_client *client;
struct wl_resource *resource;
diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h
index 337d96ab..a315c4d9 100644
--- a/include/wlr/types/wlr_xdg_shell_v6.h
+++ b/include/wlr/types/wlr_xdg_shell_v6.h
@@ -90,6 +90,16 @@ struct wlr_xdg_toplevel_v6_state {
uint32_t min_width, min_height;
};
+/**
+ * An xdg-surface is a user interface element requiring management by the
+ * compositor. An xdg-surface alone isn't useful, a role should be assigned to
+ * it in order to map it.
+ *
+ * When a surface has a role and is ready to be displayed, the `map` event is
+ * emitted. When a surface should no longer be displayed, the `unmap` event is
+ * emitted. The `unmap` event is guaranted to be emitted before the `destroy`
+ * event if the view is destroyed when mapped.
+ */
struct wlr_xdg_toplevel_v6 {
struct wl_resource *resource;
struct wlr_xdg_surface_v6 *base;
diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h
index 1fad54d1..477dddc4 100644
--- a/include/wlr/xwayland.h
+++ b/include/wlr/xwayland.h
@@ -75,6 +75,15 @@ struct wlr_xwayland_surface_size_hints {
uint32_t win_gravity;
};
+/**
+ * An Xwayland user interface component. It has an absolute position in
+ * layout-local coordinates.
+ *
+ * When a surface is ready to be displayed, the `map` event is emitted. When a
+ * surface should no longer be displayed, the `unmap` event is emitted. The
+ * `unmap` event is guaranted to be emitted before the `destroy` event if the
+ * view is destroyed when mapped.
+ */
struct wlr_xwayland_surface {
xcb_window_t window_id;
struct wlr_xwm *xwm;
@@ -116,8 +125,7 @@ struct wlr_xwayland_surface {
// _NET_WM_STATE
bool fullscreen;
- bool maximized_vert;
- bool maximized_horz;
+ bool maximized_vert, maximized_horz;
bool has_alpha;
diff --git a/rootston/config.c b/rootston/config.c
index 0883f6d4..67bf83e9 100644
--- a/rootston/config.c
+++ b/rootston/config.c
@@ -418,7 +418,10 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) {
char cwd[MAXPATHLEN];
if (getcwd(cwd, sizeof(cwd)) != NULL) {
char buf[MAXPATHLEN];
- snprintf(buf, MAXPATHLEN, "%s/%s", cwd, "rootston.ini");
+ if (snprintf(buf, MAXPATHLEN, "%s/%s", cwd, "rootston.ini") >= MAXPATHLEN) {
+ wlr_log(L_ERROR, "config path too long");
+ exit(1);
+ }
config->config_path = strdup(buf);
} else {
wlr_log(L_ERROR, "could not get cwd");
diff --git a/rootston/ini.c b/rootston/ini.c
index 56cc9ea6..f515dd38 100644
--- a/rootston/ini.c
+++ b/rootston/ini.c
@@ -64,7 +64,7 @@ static char* find_chars_or_comment(const char* s, const char* chars)
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
static char* strncpy0(char* dest, const char* src, size_t size)
{
- strncpy(dest, src, size);
+ strncpy(dest, src, size-1);
dest[size - 1] = '\0';
return dest;
}
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index bad40117..e755c9d4 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -273,8 +273,12 @@ static void xsurface_set_net_wm_state(struct wlr_xwayland_surface *xsurface) {
i, property);
}
+static void xsurface_unmap(struct wlr_xwayland_surface *surface);
+
static void wlr_xwayland_surface_destroy(
struct wlr_xwayland_surface *xsurface) {
+ xsurface_unmap(xsurface);
+
wlr_signal_emit_safe(&xsurface->events.destroy, xsurface);
if (xsurface == xsurface->xwm->focus_surface) {
@@ -618,7 +622,8 @@ static void handle_surface_commit(struct wlr_surface *wlr_surface,
if (!xsurface->added &&
wlr_surface_has_buffer(xsurface->surface) &&
xsurface->mapped) {
- wlr_signal_emit_safe(&xsurface->xwm->xwayland->events.new_surface, xsurface);
+ wlr_signal_emit_safe(&xsurface->xwm->xwayland->events.new_surface,
+ xsurface);
xsurface->added = true;
}
}
@@ -626,9 +631,7 @@ static void handle_surface_commit(struct wlr_surface *wlr_surface,
static void handle_surface_destroy(struct wl_listener *listener, void *data) {
struct wlr_xwayland_surface *xsurface =
wl_container_of(listener, xsurface, surface_destroy);
-
- xsurface->surface = NULL;
- // TODO destroy xwayland surface?
+ xsurface_unmap(xsurface);
}
static void xwm_map_shell_surface(struct wlr_xwm *xwm,
@@ -665,6 +668,27 @@ static void xwm_map_shell_surface(struct wlr_xwm *xwm,
wlr_signal_emit_safe(&xsurface->events.map, xsurface);
}
+static void xsurface_unmap(struct wlr_xwayland_surface *surface) {
+ if (surface->mapped) {
+ surface->mapped = false;
+ wlr_signal_emit_safe(&surface->events.unmap, surface);
+ }
+
+ if (surface->surface_id) {
+ // Make sure we're not on the unpaired surface list or we
+ // could be assigned a surface during surface creation that
+ // was mapped before this unmap request.
+ wl_list_remove(&surface->unpaired_link);
+ surface->surface_id = 0;
+ }
+
+ if (surface->surface) {
+ wlr_surface_set_role_committed(surface->surface, NULL, NULL);
+ wl_list_remove(&surface->surface_destroy.link);
+ surface->surface = NULL;
+ }
+}
+
static void xwm_handle_create_notify(struct wlr_xwm *xwm,
xcb_create_notify_event_t *ev) {
wlr_log(L_DEBUG, "XCB_CREATE_NOTIFY (%u)", ev->window);
@@ -778,25 +802,7 @@ static void xwm_handle_unmap_notify(struct wlr_xwm *xwm,
return;
}
- if (xsurface->mapped) {
- xsurface->mapped = false;
- wlr_signal_emit_safe(&xsurface->events.unmap, xsurface);
- }
-
- if (xsurface->surface_id) {
- // Make sure we're not on the unpaired surface list or we
- // could be assigned a surface during surface creation that
- // was mapped before this unmap request.
- wl_list_remove(&xsurface->unpaired_link);
- xsurface->surface_id = 0;
- }
-
- if (xsurface->surface) {
- wlr_surface_set_role_committed(xsurface->surface, NULL, NULL);
- wl_list_remove(&xsurface->surface_destroy.link);
- }
- xsurface->surface = NULL;
-
+ xsurface_unmap(xsurface);
xsurface_set_wm_state(xsurface, ICCCM_WITHDRAWN_STATE);
}