mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 22:55:58 +01:00
Merge branch 'master' into feature/multiseat
This commit is contained in:
commit
2a9dc60f28
27 changed files with 375 additions and 93 deletions
|
@ -70,6 +70,8 @@ void handle_tablet_tool_axis(struct libinput_event *event,
|
||||||
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL;
|
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL;
|
||||||
wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent);
|
wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent);
|
||||||
}
|
}
|
||||||
|
wlr_log(L_DEBUG, "Tablet tool axis event %d @ %f,%f",
|
||||||
|
wlr_event.updated_axes, wlr_event.x_mm, wlr_event.y_mm);
|
||||||
wl_signal_emit(&wlr_dev->tablet_tool->events.axis, &wlr_event);
|
wl_signal_emit(&wlr_dev->tablet_tool->events.axis, &wlr_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ static bool logind_change_vt(struct wlr_session *base, unsigned vt) {
|
||||||
return ret >= 0;
|
return ret >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool find_sesion_path(struct logind_session *session) {
|
static bool find_session_path(struct logind_session *session) {
|
||||||
int ret;
|
int ret;
|
||||||
sd_bus_message *msg = NULL;
|
sd_bus_message *msg = NULL;
|
||||||
sd_bus_error error = SD_BUS_ERROR_NULL;
|
sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
|
@ -303,7 +303,7 @@ static bool add_signal_matches(struct logind_session *session) {
|
||||||
"member='%s',"
|
"member='%s',"
|
||||||
"path='%s'";
|
"path='%s'";
|
||||||
|
|
||||||
snprintf(str, sizeof(str), fmt, "Manager", "SesssionRemoved", "/org/freedesktop/login1");
|
snprintf(str, sizeof(str), fmt, "Manager", "SessionRemoved", "/org/freedesktop/login1");
|
||||||
ret = sd_bus_add_match(session->bus, NULL, str, session_removed, session);
|
ret = sd_bus_add_match(session->bus, NULL, str, session_removed, session);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wlr_log(L_ERROR, "Failed to add D-Bus match: %s", strerror(-ret));
|
wlr_log(L_ERROR, "Failed to add D-Bus match: %s", strerror(-ret));
|
||||||
|
@ -368,7 +368,7 @@ static struct wlr_session *logind_session_create(struct wl_display *disp) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!find_sesion_path(session)) {
|
if (!find_session_path(session)) {
|
||||||
sd_bus_unref(session->bus);
|
sd_bus_unref(session->bus);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ static size_t explicit_find_gpus(struct wlr_session *session,
|
||||||
* If it's not found, it returns the first valid GPU it finds.
|
* If it's not found, it returns the first valid GPU it finds.
|
||||||
*/
|
*/
|
||||||
size_t wlr_session_find_gpus(struct wlr_session *session,
|
size_t wlr_session_find_gpus(struct wlr_session *session,
|
||||||
size_t ret_len, int ret[static ret_len]) {
|
size_t ret_len, int *ret) {
|
||||||
const char *explicit = getenv("WLR_DRM_DEVICES");
|
const char *explicit = getenv("WLR_DRM_DEVICES");
|
||||||
if (explicit) {
|
if (explicit) {
|
||||||
return explicit_find_gpus(session, ret_len, ret, explicit);
|
return explicit_find_gpus(session, ret_len, ret, explicit);
|
||||||
|
|
|
@ -249,7 +249,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
||||||
wlr_output_init(&output->wlr_output, &backend->backend, &output_impl);
|
wlr_output_init(&output->wlr_output, &backend->backend, &output_impl);
|
||||||
struct wlr_output *wlr_output = &output->wlr_output;
|
struct wlr_output *wlr_output = &output->wlr_output;
|
||||||
|
|
||||||
wlr_output_update_size(wlr_output, 640, 480);
|
wlr_output_update_size(wlr_output, 1280, 720);
|
||||||
strncpy(wlr_output->make, "wayland", sizeof(wlr_output->make));
|
strncpy(wlr_output->make, "wayland", sizeof(wlr_output->make));
|
||||||
strncpy(wlr_output->model, "wayland", sizeof(wlr_output->model));
|
strncpy(wlr_output->model, "wayland", sizeof(wlr_output->model));
|
||||||
snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%d",
|
snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%d",
|
||||||
|
|
|
@ -8,6 +8,7 @@ struct output_config {
|
||||||
char *name;
|
char *name;
|
||||||
enum wl_output_transform transform;
|
enum wl_output_transform transform;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
int scale;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct {
|
struct {
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
|
@ -11,9 +11,10 @@ struct roots_wl_shell_surface {
|
||||||
|
|
||||||
// TODO: Maybe destroy listener should go in roots_view
|
// TODO: Maybe destroy listener should go in roots_view
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
struct wl_listener ping_timeout;
|
|
||||||
struct wl_listener request_move;
|
struct wl_listener request_move;
|
||||||
struct wl_listener request_resize;
|
struct wl_listener request_resize;
|
||||||
|
struct wl_listener request_set_maximized;
|
||||||
|
struct wl_listener set_state;
|
||||||
|
|
||||||
struct wl_listener surface_commit;
|
struct wl_listener surface_commit;
|
||||||
};
|
};
|
||||||
|
@ -26,6 +27,7 @@ struct roots_xdg_surface_v6 {
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
struct wl_listener request_move;
|
struct wl_listener request_move;
|
||||||
struct wl_listener request_resize;
|
struct wl_listener request_resize;
|
||||||
|
struct wl_listener request_maximize;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct roots_xwayland_surface {
|
struct roots_xwayland_surface {
|
||||||
|
@ -36,6 +38,7 @@ struct roots_xwayland_surface {
|
||||||
struct wl_listener request_configure;
|
struct wl_listener request_configure;
|
||||||
struct wl_listener request_move;
|
struct wl_listener request_move;
|
||||||
struct wl_listener request_resize;
|
struct wl_listener request_resize;
|
||||||
|
struct wl_listener request_maximize;
|
||||||
struct wl_listener map_notify;
|
struct wl_listener map_notify;
|
||||||
struct wl_listener unmap_notify;
|
struct wl_listener unmap_notify;
|
||||||
};
|
};
|
||||||
|
@ -48,8 +51,17 @@ enum roots_view_type {
|
||||||
|
|
||||||
struct roots_view {
|
struct roots_view {
|
||||||
struct roots_desktop *desktop;
|
struct roots_desktop *desktop;
|
||||||
|
|
||||||
double x, y;
|
double x, y;
|
||||||
float rotation;
|
float rotation;
|
||||||
|
|
||||||
|
bool maximized;
|
||||||
|
struct {
|
||||||
|
double x, y;
|
||||||
|
uint32_t width, height;
|
||||||
|
float rotation;
|
||||||
|
} saved;
|
||||||
|
|
||||||
// TODO: Something for roots-enforced width/height
|
// TODO: Something for roots-enforced width/height
|
||||||
enum roots_view_type type;
|
enum roots_view_type type;
|
||||||
union {
|
union {
|
||||||
|
@ -67,25 +79,28 @@ struct roots_view {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
struct wlr_surface *wlr_surface;
|
struct wlr_surface *wlr_surface;
|
||||||
|
|
||||||
// TODO: This would probably be better as a field that's updated on a
|
// TODO: This would probably be better as a field that's updated on a
|
||||||
// configure event from the xdg_shell
|
// configure event from the xdg_shell
|
||||||
// If not then this should follow the typical type/impl pattern we use
|
// If not then this should follow the typical type/impl pattern we use
|
||||||
// elsewhere
|
// elsewhere
|
||||||
void (*get_size)(struct roots_view *view, struct wlr_box *box);
|
void (*get_size)(const struct roots_view *view, struct wlr_box *box);
|
||||||
void (*activate)(struct roots_view *view, bool active);
|
void (*activate)(struct roots_view *view, bool active);
|
||||||
void (*move)(struct roots_view *view, double x, double y);
|
void (*move)(struct roots_view *view, double x, double y);
|
||||||
void (*resize)(struct roots_view *view, uint32_t width, uint32_t height);
|
void (*resize)(struct roots_view *view, uint32_t width, uint32_t height);
|
||||||
void (*move_resize)(struct roots_view *view, double x, double y,
|
void (*move_resize)(struct roots_view *view, double x, double y,
|
||||||
uint32_t width, uint32_t height);
|
uint32_t width, uint32_t height);
|
||||||
|
void (*maximize)(struct roots_view *view, bool maximized);
|
||||||
void (*close)(struct roots_view *view);
|
void (*close)(struct roots_view *view);
|
||||||
};
|
};
|
||||||
|
|
||||||
void view_get_size(struct roots_view *view, struct wlr_box *box);
|
void view_get_box(const struct roots_view *view, struct wlr_box *box);
|
||||||
void view_activate(struct roots_view *view, bool active);
|
void view_activate(struct roots_view *view, bool active);
|
||||||
void view_move(struct roots_view *view, double x, double y);
|
void view_move(struct roots_view *view, double x, double y);
|
||||||
void view_resize(struct roots_view *view, uint32_t width, uint32_t height);
|
void view_resize(struct roots_view *view, uint32_t width, uint32_t height);
|
||||||
void view_move_resize(struct roots_view *view, double x, double y,
|
void view_move_resize(struct roots_view *view, double x, double y,
|
||||||
uint32_t width, uint32_t height);
|
uint32_t width, uint32_t height);
|
||||||
|
void view_maximize(struct roots_view *view, bool maximized);
|
||||||
void view_close(struct roots_view *view);
|
void view_close(struct roots_view *view);
|
||||||
bool view_center(struct roots_view *view);
|
bool view_center(struct roots_view *view);
|
||||||
void view_setup(struct roots_view *view);
|
void view_setup(struct roots_view *view);
|
||||||
|
|
|
@ -79,6 +79,6 @@ void wlr_session_signal_add(struct wlr_session *session, int fd,
|
||||||
bool wlr_session_change_vt(struct wlr_session *session, unsigned vt);
|
bool wlr_session_change_vt(struct wlr_session *session, unsigned vt);
|
||||||
|
|
||||||
size_t wlr_session_find_gpus(struct wlr_session *session,
|
size_t wlr_session_find_gpus(struct wlr_session *session,
|
||||||
size_t ret_len, int ret[static ret_len]);
|
size_t ret_len, int *ret);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -74,6 +74,11 @@ struct wlr_drag {
|
||||||
struct wlr_data_device_manager *wlr_data_device_manager_create(
|
struct wlr_data_device_manager *wlr_data_device_manager_create(
|
||||||
struct wl_display *display);
|
struct wl_display *display);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys a wlr_data_device_manager and removes its wl_data_device_manager global.
|
||||||
|
*/
|
||||||
|
void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new wl_data_offer if there is a wl_data_source currently set as
|
* Creates a new wl_data_offer if there is a wl_data_source currently set as
|
||||||
* the seat selection and sends it to the seat client, followed by the
|
* the seat selection and sends it to the seat client, followed by the
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct wlr_output_mode {
|
||||||
|
|
||||||
struct wlr_output_cursor {
|
struct wlr_output_cursor {
|
||||||
struct wlr_output *output;
|
struct wlr_output *output;
|
||||||
int32_t x, y;
|
double x, y;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
uint32_t width, height;
|
uint32_t width, height;
|
||||||
int32_t hotspot_x, hotspot_y;
|
int32_t hotspot_x, hotspot_y;
|
||||||
|
@ -95,7 +95,8 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
|
||||||
int32_t hotspot_x, int32_t hotspot_y);
|
int32_t hotspot_x, int32_t hotspot_y);
|
||||||
void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
|
void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
|
||||||
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y);
|
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y);
|
||||||
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y);
|
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
|
||||||
|
double x, double y);
|
||||||
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);
|
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef WLR_TYPES_WLR_SURFACE_H
|
#ifndef WLR_TYPES_WLR_SURFACE_H
|
||||||
#define WLR_TYPES_WLR_SURFACE_H
|
#define WLR_TYPES_WLR_SURFACE_H
|
||||||
|
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
#include <pixman.h>
|
#include <pixman.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <wlr/types/wlr_output.h>
|
||||||
|
|
||||||
struct wlr_frame_callback {
|
struct wlr_frame_callback {
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
|
@ -135,4 +135,11 @@ struct wlr_surface *wlr_surface_get_main_surface(struct wlr_surface *surface);
|
||||||
*/
|
*/
|
||||||
struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
|
struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
|
||||||
double sx, double sy, double *sub_x, double *sub_y);
|
double sx, double sy, double *sub_x, double *sub_y);
|
||||||
|
|
||||||
|
void wlr_surface_send_enter(struct wlr_surface *surface,
|
||||||
|
struct wlr_output *output);
|
||||||
|
|
||||||
|
void wlr_surface_send_leave(struct wlr_surface *surface,
|
||||||
|
struct wlr_output *output);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,6 +42,8 @@ struct wlr_wl_shell_popup_grab {
|
||||||
enum wlr_wl_shell_surface_state {
|
enum wlr_wl_shell_surface_state {
|
||||||
WLR_WL_SHELL_SURFACE_STATE_NONE,
|
WLR_WL_SHELL_SURFACE_STATE_NONE,
|
||||||
WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL,
|
WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL,
|
||||||
|
WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED,
|
||||||
|
WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN,
|
||||||
WLR_WL_SHELL_SURFACE_STATE_TRANSIENT,
|
WLR_WL_SHELL_SURFACE_STATE_TRANSIENT,
|
||||||
WLR_WL_SHELL_SURFACE_STATE_POPUP,
|
WLR_WL_SHELL_SURFACE_STATE_POPUP,
|
||||||
};
|
};
|
||||||
|
|
|
@ -126,6 +126,8 @@ struct wlr_xdg_surface_v6 {
|
||||||
struct wl_signal ack_configure;
|
struct wl_signal ack_configure;
|
||||||
struct wl_signal ping_timeout;
|
struct wl_signal ping_timeout;
|
||||||
|
|
||||||
|
struct wl_signal request_maximize;
|
||||||
|
struct wl_signal request_fullscreen;
|
||||||
struct wl_signal request_minimize;
|
struct wl_signal request_minimize;
|
||||||
struct wl_signal request_move;
|
struct wl_signal request_move;
|
||||||
struct wl_signal request_resize;
|
struct wl_signal request_resize;
|
||||||
|
|
|
@ -221,6 +221,7 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
||||||
oc = calloc(1, sizeof(struct output_config));
|
oc = calloc(1, sizeof(struct output_config));
|
||||||
oc->name = strdup(output_name);
|
oc->name = strdup(output_name);
|
||||||
oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
|
oc->scale = 1;
|
||||||
wl_list_insert(&config->outputs, &oc->link);
|
wl_list_insert(&config->outputs, &oc->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +229,9 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
||||||
oc->x = strtol(value, NULL, 10);
|
oc->x = strtol(value, NULL, 10);
|
||||||
} else if (strcmp(name, "y") == 0) {
|
} else if (strcmp(name, "y") == 0) {
|
||||||
oc->y = strtol(value, NULL, 10);
|
oc->y = strtol(value, NULL, 10);
|
||||||
|
} else if (strcmp(name, "scale") == 0) {
|
||||||
|
oc->scale = strtol(value, NULL, 10);
|
||||||
|
assert(oc->scale >= 1);
|
||||||
} else if (strcmp(name, "rotate") == 0) {
|
} else if (strcmp(name, "rotate") == 0) {
|
||||||
if (strcmp(value, "normal") == 0) {
|
if (strcmp(value, "normal") == 0) {
|
||||||
oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
|
|
|
@ -273,6 +273,14 @@ void roots_cursor_handle_tool_axis(struct roots_cursor *cursor,
|
||||||
wlr_cursor_warp_absolute(cursor->cursor, event->device,
|
wlr_cursor_warp_absolute(cursor->cursor, event->device,
|
||||||
event->x_mm / event->width_mm, event->y_mm / event->height_mm);
|
event->x_mm / event->width_mm, event->y_mm / event->height_mm);
|
||||||
roots_cursor_update_position(cursor, event->time_msec);
|
roots_cursor_update_position(cursor, event->time_msec);
|
||||||
|
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
|
||||||
|
wlr_cursor_warp_absolute(cursor->cursor, event->device,
|
||||||
|
event->x_mm / event->width_mm, -1);
|
||||||
|
roots_cursor_update_position(cursor, event->time_msec);
|
||||||
|
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
|
||||||
|
wlr_cursor_warp_absolute(cursor->cursor, event->device,
|
||||||
|
-1, event->y_mm / event->height_mm);
|
||||||
|
roots_cursor_update_position(cursor, event->time_msec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,14 +39,49 @@ void view_destroy(struct roots_view *view) {
|
||||||
free(view);
|
free(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_get_size(struct roots_view *view, struct wlr_box *box) {
|
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
|
||||||
|
box->x = view->x;
|
||||||
|
box->y = view->y;
|
||||||
if (view->get_size) {
|
if (view->get_size) {
|
||||||
view->get_size(view, box);
|
view->get_size(view, box);
|
||||||
return;
|
} else {
|
||||||
|
box->width = view->wlr_surface->current->width;
|
||||||
|
box->height = view->wlr_surface->current->height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void view_update_output(const struct roots_view *view,
|
||||||
|
const struct wlr_box *before) {
|
||||||
|
struct roots_desktop *desktop = view->desktop;
|
||||||
|
struct roots_output *output;
|
||||||
|
struct wlr_box box;
|
||||||
|
view_get_box(view, &box);
|
||||||
|
wl_list_for_each(output, &desktop->outputs, link) {
|
||||||
|
bool intersected = before->x != -1 && wlr_output_layout_intersects(
|
||||||
|
desktop->layout, output->wlr_output,
|
||||||
|
before->x, before->y, before->x + before->width,
|
||||||
|
before->y + before->height);
|
||||||
|
bool intersects = wlr_output_layout_intersects(
|
||||||
|
desktop->layout, output->wlr_output,
|
||||||
|
view->x, view->y, view->x + box.width, view->y + box.height);
|
||||||
|
if (intersected && !intersects) {
|
||||||
|
wlr_surface_send_leave(view->wlr_surface, output->wlr_output);
|
||||||
|
}
|
||||||
|
if (!intersected && intersects) {
|
||||||
|
wlr_surface_send_enter(view->wlr_surface, output->wlr_output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void view_move(struct roots_view *view, double x, double y) {
|
||||||
|
struct wlr_box before;
|
||||||
|
view_get_box(view, &before);
|
||||||
|
if (view->move) {
|
||||||
|
view->move(view, x, y);
|
||||||
|
} else {
|
||||||
|
view->x = x;
|
||||||
|
view->y = y;
|
||||||
}
|
}
|
||||||
box->x = box->y = 0;
|
|
||||||
box->width = view->wlr_surface->current->width;
|
|
||||||
box->height = view->wlr_surface->current->height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_activate(struct roots_view *view, bool activate) {
|
void view_activate(struct roots_view *view, bool activate) {
|
||||||
|
@ -55,20 +90,13 @@ void view_activate(struct roots_view *view, bool activate) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_move(struct roots_view *view, double x, double y) {
|
|
||||||
if (view->move) {
|
|
||||||
view->move(view, x, y);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
view->x = x;
|
|
||||||
view->y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void view_resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
void view_resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
||||||
|
struct wlr_box before;
|
||||||
|
view_get_box(view, &before);
|
||||||
if (view->resize) {
|
if (view->resize) {
|
||||||
view->resize(view, width, height);
|
view->resize(view, width, height);
|
||||||
}
|
}
|
||||||
|
view_update_output(view, &before);
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_move_resize(struct roots_view *view, double x, double y,
|
void view_move_resize(struct roots_view *view, double x, double y,
|
||||||
|
@ -82,6 +110,50 @@ void view_move_resize(struct roots_view *view, double x, double y,
|
||||||
view_resize(view, width, height);
|
view_resize(view, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void view_maximize(struct roots_view *view, bool maximized) {
|
||||||
|
if (view->maximized == maximized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view->maximize) {
|
||||||
|
view->maximize(view, maximized);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!view->maximized && maximized) {
|
||||||
|
struct wlr_box view_box;
|
||||||
|
view_get_box(view, &view_box);
|
||||||
|
|
||||||
|
view->maximized = true;
|
||||||
|
view->saved.x = view->x;
|
||||||
|
view->saved.y = view->y;
|
||||||
|
view->saved.rotation = view->rotation;
|
||||||
|
view->saved.width = view_box.width;
|
||||||
|
view->saved.height = view_box.height;
|
||||||
|
|
||||||
|
double output_x, output_y;
|
||||||
|
wlr_output_layout_closest_point(view->desktop->layout, NULL,
|
||||||
|
view->x + (double)view_box.width/2,
|
||||||
|
view->y + (double)view_box.height/2,
|
||||||
|
&output_x, &output_y);
|
||||||
|
struct wlr_output *output = wlr_output_layout_output_at(
|
||||||
|
view->desktop->layout, output_x, output_y);
|
||||||
|
struct wlr_box *output_box =
|
||||||
|
wlr_output_layout_get_box(view->desktop->layout, output);
|
||||||
|
|
||||||
|
view_move_resize(view, output_box->x, output_box->y, output_box->width,
|
||||||
|
output_box->height);
|
||||||
|
view->rotation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view->maximized && !maximized) {
|
||||||
|
view->maximized = false;
|
||||||
|
|
||||||
|
view_move_resize(view, view->saved.x, view->saved.y, view->saved.width,
|
||||||
|
view->saved.height);
|
||||||
|
view->rotation = view->saved.rotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void view_close(struct roots_view *view) {
|
void view_close(struct roots_view *view) {
|
||||||
if (view->close) {
|
if (view->close) {
|
||||||
view->close(view);
|
view->close(view);
|
||||||
|
@ -89,8 +161,8 @@ void view_close(struct roots_view *view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool view_center(struct roots_view *view) {
|
bool view_center(struct roots_view *view) {
|
||||||
struct wlr_box size;
|
struct wlr_box box;
|
||||||
view_get_size(view, &size);
|
view_get_box(view, &box);
|
||||||
|
|
||||||
struct roots_desktop *desktop = view->desktop;
|
struct roots_desktop *desktop = view->desktop;
|
||||||
|
|
||||||
|
@ -107,23 +179,25 @@ bool view_center(struct roots_view *view) {
|
||||||
int width, height;
|
int width, height;
|
||||||
wlr_output_effective_resolution(output, &width, &height);
|
wlr_output_effective_resolution(output, &width, &height);
|
||||||
|
|
||||||
double view_x = (double)(width - size.width) / 2 + l_output->x;
|
double view_x = (double)(width - box.width) / 2 + l_output->x;
|
||||||
double view_y = (double)(height - size.height) / 2 + l_output->y;
|
double view_y = (double)(height - box.height) / 2 + l_output->y;
|
||||||
|
|
||||||
view_move(view, view_x, view_y);
|
view_move(view, view_x, view_y);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_setup(struct roots_view *view) {
|
void view_setup(struct roots_view *view) {
|
||||||
view_center(view);
|
|
||||||
|
|
||||||
struct roots_input *input = view->desktop->server->input;
|
struct roots_input *input = view->desktop->server->input;
|
||||||
// TODO what seat gets focus? the one with the last input event?
|
// TODO what seat gets focus? the one with the last input event?
|
||||||
struct roots_seat *seat;
|
struct roots_seat *seat;
|
||||||
wl_list_for_each(seat, &input->seats, link) {
|
wl_list_for_each(seat, &input->seats, link) {
|
||||||
roots_seat_focus_view(seat, view);
|
roots_seat_focus_view(seat, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view_center(view);
|
||||||
|
struct wlr_box before;
|
||||||
|
view_get_box(view, &before);
|
||||||
|
view_update_output(view, &before);
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_teardown(struct roots_view *view) {
|
void view_teardown(struct roots_view *view) {
|
||||||
|
|
|
@ -20,10 +20,13 @@ static void render_surface(struct wlr_surface *surface,
|
||||||
struct roots_desktop *desktop, struct wlr_output *wlr_output,
|
struct roots_desktop *desktop, struct wlr_output *wlr_output,
|
||||||
struct timespec *when, double lx, double ly, float rotation) {
|
struct timespec *when, double lx, double ly, float rotation) {
|
||||||
if (surface->texture->valid) {
|
if (surface->texture->valid) {
|
||||||
int width = surface->current->buffer_width;
|
float scale_factor = (float)wlr_output->scale / surface->current->scale;
|
||||||
int height = surface->current->buffer_height;
|
int width = surface->current->buffer_width * scale_factor;
|
||||||
|
int height = surface->current->buffer_height * scale_factor;
|
||||||
double ox = lx, oy = ly;
|
double ox = lx, oy = ly;
|
||||||
wlr_output_layout_output_coords(desktop->layout, wlr_output, &ox, &oy);
|
wlr_output_layout_output_coords(desktop->layout, wlr_output, &ox, &oy);
|
||||||
|
ox *= wlr_output->scale;
|
||||||
|
oy *= wlr_output->scale;
|
||||||
|
|
||||||
if (wlr_output_layout_intersects(desktop->layout, wlr_output,
|
if (wlr_output_layout_intersects(desktop->layout, wlr_output,
|
||||||
lx, ly, lx + width, ly + height)) {
|
lx, ly, lx + width, ly + height)) {
|
||||||
|
@ -32,15 +35,22 @@ static void render_surface(struct wlr_surface *surface,
|
||||||
float translate_origin[16];
|
float translate_origin[16];
|
||||||
wlr_matrix_translate(&translate_origin,
|
wlr_matrix_translate(&translate_origin,
|
||||||
(int)ox + width / 2, (int)oy + height / 2, 0);
|
(int)ox + width / 2, (int)oy + height / 2, 0);
|
||||||
|
|
||||||
float rotate[16];
|
float rotate[16];
|
||||||
wlr_matrix_rotate(&rotate, rotation);
|
wlr_matrix_rotate(&rotate, rotation);
|
||||||
|
|
||||||
float translate_center[16];
|
float translate_center[16];
|
||||||
wlr_matrix_translate(&translate_center, -width / 2, -height / 2, 0);
|
wlr_matrix_translate(&translate_center, -width / 2, -height / 2, 0);
|
||||||
|
|
||||||
|
float scale[16];
|
||||||
|
wlr_matrix_scale(&scale, width, height, 1);
|
||||||
|
|
||||||
float transform[16];
|
float transform[16];
|
||||||
wlr_matrix_mul(&translate_origin, &rotate, &transform);
|
wlr_matrix_mul(&translate_origin, &rotate, &transform);
|
||||||
wlr_matrix_mul(&transform, &translate_center, &transform);
|
wlr_matrix_mul(&transform, &translate_center, &transform);
|
||||||
wlr_surface_get_matrix(surface, &matrix,
|
wlr_matrix_mul(&transform, &scale, &transform);
|
||||||
&wlr_output->transform_matrix, &transform);
|
wlr_matrix_mul(&wlr_output->transform_matrix, &transform, &matrix);
|
||||||
|
|
||||||
wlr_render_with_matrix(desktop->server->renderer,
|
wlr_render_with_matrix(desktop->server->renderer,
|
||||||
surface->texture, &matrix);
|
surface->texture, &matrix);
|
||||||
|
|
||||||
|
@ -220,6 +230,7 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
||||||
if (output_config->mode.width) {
|
if (output_config->mode.width) {
|
||||||
set_mode(wlr_output, output_config);
|
set_mode(wlr_output, output_config);
|
||||||
}
|
}
|
||||||
|
wlr_output->scale = output_config->scale;
|
||||||
wlr_output_transform(wlr_output, output_config->transform);
|
wlr_output_transform(wlr_output, output_config->transform);
|
||||||
wlr_output_layout_add(desktop->layout,
|
wlr_output_layout_add(desktop->layout,
|
||||||
wlr_output, output_config->x, output_config->y);
|
wlr_output, output_config->x, output_config->y);
|
||||||
|
|
|
@ -548,8 +548,14 @@ void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) {
|
||||||
cursor->mode = ROOTS_CURSOR_MOVE;
|
cursor->mode = ROOTS_CURSOR_MOVE;
|
||||||
cursor->offs_x = cursor->cursor->x;
|
cursor->offs_x = cursor->cursor->x;
|
||||||
cursor->offs_y = cursor->cursor->y;
|
cursor->offs_y = cursor->cursor->y;
|
||||||
cursor->view_x = view->x;
|
if (view->maximized) {
|
||||||
cursor->view_y = view->y;
|
cursor->view_x = view->saved.x;
|
||||||
|
cursor->view_y = view->saved.y;
|
||||||
|
} else {
|
||||||
|
cursor->view_x = view->x;
|
||||||
|
cursor->view_y = view->y;
|
||||||
|
}
|
||||||
|
view_maximize(view, false);
|
||||||
wlr_seat_pointer_clear_focus(seat->seat);
|
wlr_seat_pointer_clear_focus(seat->seat);
|
||||||
|
|
||||||
struct wlr_xcursor *xcursor = get_move_xcursor(seat->cursor->xcursor_theme);
|
struct wlr_xcursor *xcursor = get_move_xcursor(seat->cursor->xcursor_theme);
|
||||||
|
@ -565,13 +571,21 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view,
|
||||||
cursor->mode = ROOTS_CURSOR_RESIZE;
|
cursor->mode = ROOTS_CURSOR_RESIZE;
|
||||||
cursor->offs_x = cursor->cursor->x;
|
cursor->offs_x = cursor->cursor->x;
|
||||||
cursor->offs_y = cursor->cursor->y;
|
cursor->offs_y = cursor->cursor->y;
|
||||||
cursor->view_x = view->x;
|
if (view->maximized) {
|
||||||
cursor->view_y = view->y;
|
cursor->view_x = view->saved.x;
|
||||||
struct wlr_box size;
|
cursor->view_y = view->saved.y;
|
||||||
view_get_size(view, &size);
|
cursor->view_width = view->saved.width;
|
||||||
cursor->view_width = size.width;
|
cursor->view_height = view->saved.height;
|
||||||
cursor->view_height = size.height;
|
} else {
|
||||||
|
cursor->view_x = view->x;
|
||||||
|
cursor->view_y = view->y;
|
||||||
|
struct wlr_box box;
|
||||||
|
view_get_box(view, &box);
|
||||||
|
cursor->view_width = box.width;
|
||||||
|
cursor->view_height = box.height;
|
||||||
|
}
|
||||||
cursor->resize_edges = edges;
|
cursor->resize_edges = edges;
|
||||||
|
view_maximize(view, false);
|
||||||
wlr_seat_pointer_clear_focus(seat->seat);
|
wlr_seat_pointer_clear_focus(seat->seat);
|
||||||
|
|
||||||
struct wlr_xcursor *xcursor = get_resize_xcursor(cursor->xcursor_theme, edges);
|
struct wlr_xcursor *xcursor = get_resize_xcursor(cursor->xcursor_theme, edges);
|
||||||
|
@ -587,6 +601,7 @@ void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view) {
|
||||||
cursor->offs_x = cursor->cursor->x;
|
cursor->offs_x = cursor->cursor->x;
|
||||||
cursor->offs_y = cursor->cursor->y;
|
cursor->offs_y = cursor->cursor->y;
|
||||||
cursor->view_rotation = view->rotation;
|
cursor->view_rotation = view->rotation;
|
||||||
|
view_maximize(view, false);
|
||||||
wlr_seat_pointer_clear_focus(seat->seat);
|
wlr_seat_pointer_clear_focus(seat->seat);
|
||||||
|
|
||||||
struct wlr_xcursor *xcursor = get_rotate_xcursor(cursor->xcursor_theme);
|
struct wlr_xcursor *xcursor = get_rotate_xcursor(cursor->xcursor_theme);
|
||||||
|
|
|
@ -50,6 +50,26 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
roots_seat_begin_resize(seat, view, e->edges);
|
roots_seat_begin_resize(seat, view, e->edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_request_set_maximized(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
|
wl_container_of(listener, roots_surface, request_set_maximized);
|
||||||
|
struct roots_view *view = roots_surface->view;
|
||||||
|
//struct wlr_wl_shell_surface_set_maximized_event *e = data;
|
||||||
|
view_maximize(view, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_set_state(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
|
wl_container_of(listener, roots_surface, set_state);
|
||||||
|
struct roots_view *view = roots_surface->view;
|
||||||
|
struct wlr_wl_shell_surface *surface = view->wl_shell_surface;
|
||||||
|
if (view->maximized &&
|
||||||
|
surface->state != WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED) {
|
||||||
|
view_maximize(view, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
// TODO do we need to do anything here?
|
// TODO do we need to do anything here?
|
||||||
}
|
}
|
||||||
|
@ -61,6 +81,9 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
wl_list_remove(&roots_surface->destroy.link);
|
wl_list_remove(&roots_surface->destroy.link);
|
||||||
wl_list_remove(&roots_surface->request_move.link);
|
wl_list_remove(&roots_surface->request_move.link);
|
||||||
wl_list_remove(&roots_surface->request_resize.link);
|
wl_list_remove(&roots_surface->request_resize.link);
|
||||||
|
wl_list_remove(&roots_surface->request_set_maximized.link);
|
||||||
|
wl_list_remove(&roots_surface->set_state.link);
|
||||||
|
wl_list_remove(&roots_surface->surface_commit.link);
|
||||||
view_destroy(roots_surface->view);
|
view_destroy(roots_surface->view);
|
||||||
free(roots_surface);
|
free(roots_surface);
|
||||||
}
|
}
|
||||||
|
@ -94,6 +117,11 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->request_resize.notify = handle_request_resize;
|
roots_surface->request_resize.notify = handle_request_resize;
|
||||||
wl_signal_add(&surface->events.request_resize,
|
wl_signal_add(&surface->events.request_resize,
|
||||||
&roots_surface->request_resize);
|
&roots_surface->request_resize);
|
||||||
|
roots_surface->request_set_maximized.notify = handle_request_set_maximized;
|
||||||
|
wl_signal_add(&surface->events.request_set_maximized,
|
||||||
|
&roots_surface->request_set_maximized);
|
||||||
|
roots_surface->set_state.notify = handle_set_state;
|
||||||
|
wl_signal_add(&surface->events.set_state, &roots_surface->set_state);
|
||||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||||
wl_signal_add(&surface->surface->events.commit,
|
wl_signal_add(&surface->surface->events.commit,
|
||||||
&roots_surface->surface_commit);
|
&roots_surface->surface_commit);
|
||||||
|
|
|
@ -10,11 +10,17 @@
|
||||||
#include "rootston/server.h"
|
#include "rootston/server.h"
|
||||||
#include "rootston/input.h"
|
#include "rootston/input.h"
|
||||||
|
|
||||||
static void get_size(struct roots_view *view, struct wlr_box *box) {
|
static void get_size(const struct roots_view *view, struct wlr_box *box) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
||||||
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
|
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
|
||||||
// TODO: surf->geometry can be NULL
|
|
||||||
memcpy(box, surf->geometry, sizeof(struct wlr_box));
|
if (surf->geometry->width > 0 && surf->geometry->height > 0) {
|
||||||
|
box->width = surf->geometry->width;
|
||||||
|
box->height = surf->geometry->height;
|
||||||
|
} else {
|
||||||
|
box->width = view->wlr_surface->current->width;
|
||||||
|
box->height = view->wlr_surface->current->height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void activate(struct roots_view *view, bool active) {
|
static void activate(struct roots_view *view, bool active) {
|
||||||
|
@ -84,6 +90,16 @@ static void move_resize(struct roots_view *view, double x, double y,
|
||||||
wlr_xdg_toplevel_v6_set_size(surf, contrained_width, contrained_height);
|
wlr_xdg_toplevel_v6_set_size(surf, contrained_width, contrained_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void maximize(struct roots_view *view, bool maximized) {
|
||||||
|
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
||||||
|
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
||||||
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_xdg_toplevel_v6_set_maximized(surface, maximized);
|
||||||
|
}
|
||||||
|
|
||||||
static void close(struct roots_view *view) {
|
static void close(struct roots_view *view) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
||||||
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
|
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
|
||||||
|
@ -121,8 +137,25 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
roots_seat_begin_resize(seat, view, e->edges);
|
roots_seat_begin_resize(seat, view, e->edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
|
wl_container_of(listener, roots_xdg_surface, request_maximize);
|
||||||
|
struct roots_view *view = roots_xdg_surface->view;
|
||||||
|
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
||||||
|
|
||||||
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
view_maximize(view, surface->toplevel_state->next.maximized);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_commit(struct wl_listener *listener, void *data) {
|
static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
// TODO is there anything we need to do here?
|
//struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
|
// wl_container_of(listener, roots_xdg_surface, commit);
|
||||||
|
//struct roots_view *view = roots_xdg_surface->view;
|
||||||
|
//struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
@ -167,6 +200,9 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->request_resize.notify = handle_request_resize;
|
roots_surface->request_resize.notify = handle_request_resize;
|
||||||
wl_signal_add(&surface->events.request_resize,
|
wl_signal_add(&surface->events.request_resize,
|
||||||
&roots_surface->request_resize);
|
&roots_surface->request_resize);
|
||||||
|
roots_surface->request_maximize.notify = handle_request_maximize;
|
||||||
|
wl_signal_add(&surface->events.request_maximize,
|
||||||
|
&roots_surface->request_maximize);
|
||||||
|
|
||||||
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
||||||
if (!view) {
|
if (!view) {
|
||||||
|
@ -181,6 +217,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
view->activate = activate;
|
view->activate = activate;
|
||||||
view->resize = resize;
|
view->resize = resize;
|
||||||
view->move_resize = move_resize;
|
view->move_resize = move_resize;
|
||||||
|
view->maximize = maximize;
|
||||||
view->close = close;
|
view->close = close;
|
||||||
view->desktop = desktop;
|
view->desktop = desktop;
|
||||||
roots_surface->view = view;
|
roots_surface->view = view;
|
||||||
|
|
|
@ -85,11 +85,22 @@ static void close(struct roots_view *view) {
|
||||||
wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface);
|
wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void maximize(struct roots_view *view, bool maximized) {
|
||||||
|
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
||||||
|
|
||||||
|
wlr_xwayland_surface_set_maximized(view->desktop->xwayland,
|
||||||
|
view->xwayland_surface, maximized);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, destroy);
|
wl_container_of(listener, roots_surface, destroy);
|
||||||
view_teardown(roots_surface->view);
|
view_teardown(roots_surface->view);
|
||||||
wl_list_remove(&roots_surface->destroy.link);
|
wl_list_remove(&roots_surface->destroy.link);
|
||||||
|
wl_list_remove(&roots_surface->request_configure.link);
|
||||||
|
wl_list_remove(&roots_surface->request_move.link);
|
||||||
|
wl_list_remove(&roots_surface->request_resize.link);
|
||||||
|
wl_list_remove(&roots_surface->request_maximize.link);
|
||||||
wl_list_remove(&roots_surface->map_notify.link);
|
wl_list_remove(&roots_surface->map_notify.link);
|
||||||
wl_list_remove(&roots_surface->unmap_notify.link);
|
wl_list_remove(&roots_surface->unmap_notify.link);
|
||||||
view_destroy(roots_surface->view);
|
view_destroy(roots_surface->view);
|
||||||
|
@ -149,6 +160,17 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
roots_seat_begin_resize(seat, view, e->edges);
|
roots_seat_begin_resize(seat, view, e->edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_xwayland_surface *roots_surface =
|
||||||
|
wl_container_of(listener, roots_surface, request_maximize);
|
||||||
|
struct roots_view *view = roots_surface->view;
|
||||||
|
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
|
||||||
|
|
||||||
|
bool maximized = xwayland_surface->maximized_vert &&
|
||||||
|
xwayland_surface->maximized_horz;
|
||||||
|
view_maximize(view, maximized);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_map_notify(struct wl_listener *listener, void *data) {
|
static void handle_map_notify(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, map_notify);
|
wl_container_of(listener, roots_surface, map_notify);
|
||||||
|
@ -190,24 +212,24 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
if (roots_surface == NULL) {
|
if (roots_surface == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
roots_surface->destroy.notify = handle_destroy;
|
roots_surface->destroy.notify = handle_destroy;
|
||||||
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
||||||
|
|
||||||
roots_surface->request_configure.notify = handle_request_configure;
|
roots_surface->request_configure.notify = handle_request_configure;
|
||||||
wl_signal_add(&surface->events.request_configure,
|
wl_signal_add(&surface->events.request_configure,
|
||||||
&roots_surface->request_configure);
|
&roots_surface->request_configure);
|
||||||
|
|
||||||
roots_surface->map_notify.notify = handle_map_notify;
|
roots_surface->map_notify.notify = handle_map_notify;
|
||||||
wl_signal_add(&surface->events.map_notify, &roots_surface->map_notify);
|
wl_signal_add(&surface->events.map_notify, &roots_surface->map_notify);
|
||||||
|
|
||||||
roots_surface->unmap_notify.notify = handle_unmap_notify;
|
roots_surface->unmap_notify.notify = handle_unmap_notify;
|
||||||
wl_signal_add(&surface->events.unmap_notify, &roots_surface->unmap_notify);
|
wl_signal_add(&surface->events.unmap_notify, &roots_surface->unmap_notify);
|
||||||
|
|
||||||
roots_surface->request_move.notify = handle_request_move;
|
roots_surface->request_move.notify = handle_request_move;
|
||||||
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
|
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
|
||||||
|
|
||||||
roots_surface->request_resize.notify = handle_request_resize;
|
roots_surface->request_resize.notify = handle_request_resize;
|
||||||
wl_signal_add(&surface->events.request_resize, &roots_surface->request_resize);
|
wl_signal_add(&surface->events.request_resize,
|
||||||
|
&roots_surface->request_resize);
|
||||||
|
roots_surface->request_maximize.notify = handle_request_maximize;
|
||||||
|
wl_signal_add(&surface->events.request_maximize,
|
||||||
|
&roots_surface->request_maximize);
|
||||||
|
|
||||||
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
||||||
if (view == NULL) {
|
if (view == NULL) {
|
||||||
|
@ -225,6 +247,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
view->resize = resize;
|
view->resize = resize;
|
||||||
view->move = move;
|
view->move = move;
|
||||||
view->move_resize = move_resize;
|
view->move_resize = move_resize;
|
||||||
|
view->maximize = maximize;
|
||||||
view->close = close;
|
view->close = close;
|
||||||
roots_surface->view = view;
|
roots_surface->view = view;
|
||||||
wlr_list_add(desktop->views, view);
|
wlr_list_add(desktop->views, view);
|
||||||
|
|
|
@ -261,8 +261,8 @@ void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
|
||||||
mapping = wlr_output_layout_get_box(cur->state->layout, NULL);
|
mapping = wlr_output_layout_get_box(cur->state->layout, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
double x = mapping->width * x_mm + mapping->x;
|
double x = x_mm > 0 ? mapping->width * x_mm + mapping->x : cur->x;
|
||||||
double y = mapping->height * y_mm + mapping->y;
|
double y = y_mm > 0 ? mapping->height * y_mm + mapping->y : cur->y;
|
||||||
|
|
||||||
wlr_cursor_warp_unchecked(cur, x, y);
|
wlr_cursor_warp_unchecked(cur, x, y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -815,3 +815,11 @@ struct wlr_data_device_manager *wlr_data_device_manager_create(
|
||||||
|
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager) {
|
||||||
|
if (!manager) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wl_global_destroy(manager->global);
|
||||||
|
free(manager);
|
||||||
|
}
|
||||||
|
|
|
@ -231,7 +231,6 @@ void wlr_output_destroy(struct wlr_output *output) {
|
||||||
|
|
||||||
void wlr_output_effective_resolution(struct wlr_output *output,
|
void wlr_output_effective_resolution(struct wlr_output *output,
|
||||||
int *width, int *height) {
|
int *width, int *height) {
|
||||||
// TODO: Scale factor
|
|
||||||
if (output->transform % 2 == 1) {
|
if (output->transform % 2 == 1) {
|
||||||
*width = output->height;
|
*width = output->height;
|
||||||
*height = output->width;
|
*height = output->width;
|
||||||
|
@ -239,6 +238,8 @@ void wlr_output_effective_resolution(struct wlr_output *output,
|
||||||
*width = output->width;
|
*width = output->width;
|
||||||
*height = output->height;
|
*height = output->height;
|
||||||
}
|
}
|
||||||
|
*width /= output->scale;
|
||||||
|
*height /= output->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_output_make_current(struct wlr_output *output) {
|
void wlr_output_make_current(struct wlr_output *output) {
|
||||||
|
@ -269,6 +270,8 @@ static void output_cursor_render(struct wlr_output_cursor *cursor) {
|
||||||
output_box.x = output_box.y = 0;
|
output_box.x = output_box.y = 0;
|
||||||
wlr_output_effective_resolution(cursor->output, &output_box.width,
|
wlr_output_effective_resolution(cursor->output, &output_box.width,
|
||||||
&output_box.height);
|
&output_box.height);
|
||||||
|
output_box.width *= cursor->output->scale;
|
||||||
|
output_box.height *= cursor->output->scale;
|
||||||
|
|
||||||
struct wlr_box cursor_box;
|
struct wlr_box cursor_box;
|
||||||
output_cursor_get_box(cursor, &cursor_box);
|
output_cursor_get_box(cursor, &cursor_box);
|
||||||
|
@ -471,7 +474,10 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y) {
|
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
|
||||||
|
double x, double y) {
|
||||||
|
x *= cursor->output->scale;
|
||||||
|
y *= cursor->output->scale;
|
||||||
cursor->x = x;
|
cursor->x = x;
|
||||||
cursor->y = y;
|
cursor->y = y;
|
||||||
|
|
||||||
|
@ -483,7 +489,7 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y) {
|
||||||
if (!cursor->output->impl->move_cursor) {
|
if (!cursor->output->impl->move_cursor) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return cursor->output->impl->move_cursor(cursor->output, x, y);
|
return cursor->output->impl->move_cursor(cursor->output, (int)x, (int)y);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) {
|
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) {
|
||||||
|
|
|
@ -649,8 +649,8 @@ void wlr_surface_get_matrix(struct wlr_surface *surface,
|
||||||
float (*matrix)[16],
|
float (*matrix)[16],
|
||||||
const float (*projection)[16],
|
const float (*projection)[16],
|
||||||
const float (*transform)[16]) {
|
const float (*transform)[16]) {
|
||||||
int width = surface->texture->width / surface->current->scale;
|
int width = surface->texture->width;
|
||||||
int height = surface->texture->height / surface->current->scale;
|
int height = surface->texture->height;
|
||||||
float scale[16];
|
float scale[16];
|
||||||
wlr_matrix_identity(matrix);
|
wlr_matrix_identity(matrix);
|
||||||
if (transform) {
|
if (transform) {
|
||||||
|
@ -905,3 +905,27 @@ struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_surface_send_enter(struct wlr_surface *surface,
|
||||||
|
struct wlr_output *output) {
|
||||||
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
||||||
|
struct wl_resource *resource;
|
||||||
|
wl_resource_for_each(resource, &output->wl_resources) {
|
||||||
|
if (client == wl_resource_get_client(resource)) {
|
||||||
|
wl_surface_send_enter(surface->resource, resource);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_surface_send_leave(struct wlr_surface *surface,
|
||||||
|
struct wlr_output *output) {
|
||||||
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
||||||
|
struct wl_resource *resource;
|
||||||
|
wl_resource_for_each(resource, &output->wl_resources) {
|
||||||
|
if (client == wl_resource_get_client(resource)) {
|
||||||
|
wl_surface_send_leave(surface->resource, resource);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -171,7 +171,6 @@ static void shell_surface_destroy_popup_state(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void shell_surface_protocol_resize(struct wl_client *client,
|
static void shell_surface_protocol_resize(struct wl_client *client,
|
||||||
struct wl_resource *resource, struct wl_resource *seat_resource,
|
struct wl_resource *resource, struct wl_resource *seat_resource,
|
||||||
uint32_t serial, enum wl_shell_surface_resize edges) {
|
uint32_t serial, enum wl_shell_surface_resize edges) {
|
||||||
|
@ -287,9 +286,8 @@ static void shell_surface_protocol_set_fullscreen(struct wl_client *client,
|
||||||
output = wl_resource_get_user_data(output_resource);
|
output = wl_resource_get_user_data(output_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL) {
|
shell_surface_set_state(surface, WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN,
|
||||||
return;
|
NULL, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_wl_shell_surface_set_fullscreen_event *event =
|
struct wlr_wl_shell_surface_set_fullscreen_event *event =
|
||||||
calloc(1, sizeof(struct wlr_wl_shell_surface_set_fullscreen_event));
|
calloc(1, sizeof(struct wlr_wl_shell_surface_set_fullscreen_event));
|
||||||
|
@ -377,9 +375,8 @@ static void shell_surface_protocol_set_maximized(struct wl_client *client,
|
||||||
output = wl_resource_get_user_data(output_resource);
|
output = wl_resource_get_user_data(output_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL) {
|
shell_surface_set_state(surface, WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED,
|
||||||
return;
|
NULL, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_wl_shell_surface_set_maximized_event *event =
|
struct wlr_wl_shell_surface_set_maximized_event *event =
|
||||||
calloc(1, sizeof(struct wlr_wl_shell_surface_set_maximized_event));
|
calloc(1, sizeof(struct wlr_wl_shell_surface_set_maximized_event));
|
||||||
|
|
|
@ -664,24 +664,28 @@ static void xdg_toplevel_protocol_set_maximized(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
surface->toplevel_state->next.maximized = true;
|
surface->toplevel_state->next.maximized = true;
|
||||||
|
wl_signal_emit(&surface->events.request_maximize, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client,
|
static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
surface->toplevel_state->next.maximized = false;
|
surface->toplevel_state->next.maximized = false;
|
||||||
|
wl_signal_emit(&surface->events.request_maximize, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
||||||
struct wl_resource *resource, struct wl_resource *output_resource) {
|
struct wl_resource *resource, struct wl_resource *output_resource) {
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
surface->toplevel_state->next.fullscreen = true;
|
surface->toplevel_state->next.fullscreen = true;
|
||||||
|
wl_signal_emit(&surface->events.request_fullscreen, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
surface->toplevel_state->next.fullscreen = false;
|
surface->toplevel_state->next.fullscreen = false;
|
||||||
|
wl_signal_emit(&surface->events.request_fullscreen, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_set_minimized(struct wl_client *client,
|
static void xdg_toplevel_protocol_set_minimized(struct wl_client *client,
|
||||||
|
@ -1143,6 +1147,8 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
||||||
wl_list_init(&surface->configure_list);
|
wl_list_init(&surface->configure_list);
|
||||||
wl_list_init(&surface->popups);
|
wl_list_init(&surface->popups);
|
||||||
|
|
||||||
|
wl_signal_init(&surface->events.request_maximize);
|
||||||
|
wl_signal_init(&surface->events.request_fullscreen);
|
||||||
wl_signal_init(&surface->events.request_minimize);
|
wl_signal_init(&surface->events.request_minimize);
|
||||||
wl_signal_init(&surface->events.request_move);
|
wl_signal_init(&surface->events.request_move);
|
||||||
wl_signal_init(&surface->events.request_resize);
|
wl_signal_init(&surface->events.request_resize);
|
||||||
|
|
|
@ -823,41 +823,47 @@ static void xwm_handle_net_wm_state_message(struct wlr_xwm *xwm,
|
||||||
if (!xsurface) {
|
if (!xsurface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (client_message->format != 32) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int maximized = xsurface_is_maximized(xsurface);
|
bool fullscreen = xsurface->fullscreen;
|
||||||
|
bool maximized = xsurface_is_maximized(xsurface);
|
||||||
|
|
||||||
uint32_t action = client_message->data.data32[0];
|
uint32_t action = client_message->data.data32[0];
|
||||||
uint32_t property = client_message->data.data32[1];
|
for (size_t i = 0; i < 2; ++i) {
|
||||||
|
uint32_t property = client_message->data.data32[1 + i];
|
||||||
|
|
||||||
if (property == xwm->atoms[_NET_WM_STATE_FULLSCREEN] &&
|
if (property == xwm->atoms[_NET_WM_STATE_FULLSCREEN] &&
|
||||||
update_state(action, &xsurface->fullscreen)) {
|
update_state(action, &xsurface->fullscreen)) {
|
||||||
xsurface_set_net_wm_state(xsurface);
|
xsurface_set_net_wm_state(xsurface);
|
||||||
|
} else if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT] &&
|
||||||
|
update_state(action, &xsurface->maximized_vert)) {
|
||||||
|
xsurface_set_net_wm_state(xsurface);
|
||||||
|
} else if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ] &&
|
||||||
|
update_state(action, &xsurface->maximized_horz)) {
|
||||||
|
xsurface_set_net_wm_state(xsurface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// client_message->data.data32[3] is the source indication
|
||||||
|
// all other values are set to 0
|
||||||
|
|
||||||
|
if (fullscreen != xsurface->fullscreen) {
|
||||||
if (xsurface->fullscreen) {
|
if (xsurface->fullscreen) {
|
||||||
xsurface->saved_width = xsurface->width;
|
xsurface->saved_width = xsurface->width;
|
||||||
xsurface->saved_height = xsurface->height;
|
xsurface->saved_height = xsurface->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_signal_emit(&xsurface->events.request_fullscreen, xsurface);
|
wl_signal_emit(&xsurface->events.request_fullscreen, xsurface);
|
||||||
} else {
|
}
|
||||||
if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT] &&
|
|
||||||
update_state(action, &xsurface->maximized_vert)) {
|
if (maximized != xsurface_is_maximized(xsurface)) {
|
||||||
xsurface_set_net_wm_state(xsurface);
|
if (xsurface_is_maximized(xsurface)) {
|
||||||
|
xsurface->saved_width = xsurface->width;
|
||||||
|
xsurface->saved_height = xsurface->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ] &&
|
wl_signal_emit(&xsurface->events.request_maximize, xsurface);
|
||||||
update_state(action, &xsurface->maximized_horz)) {
|
|
||||||
xsurface_set_net_wm_state(xsurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maximized != xsurface_is_maximized(xsurface)) {
|
|
||||||
if (xsurface_is_maximized(xsurface)) {
|
|
||||||
xsurface->saved_width = xsurface->width;
|
|
||||||
xsurface->saved_height = xsurface->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_signal_emit(&xsurface->events.request_maximize, xsurface);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,8 +1316,8 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) {
|
||||||
xwm->atoms[_NET_ACTIVE_WINDOW],
|
xwm->atoms[_NET_ACTIVE_WINDOW],
|
||||||
xwm->atoms[_NET_WM_MOVERESIZE],
|
xwm->atoms[_NET_WM_MOVERESIZE],
|
||||||
xwm->atoms[_NET_WM_STATE_FULLSCREEN],
|
xwm->atoms[_NET_WM_STATE_FULLSCREEN],
|
||||||
xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ],
|
|
||||||
xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT],
|
xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT],
|
||||||
|
xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ],
|
||||||
};
|
};
|
||||||
xcb_change_property(xwm->xcb_conn,
|
xcb_change_property(xwm->xcb_conn,
|
||||||
XCB_PROP_MODE_REPLACE,
|
XCB_PROP_MODE_REPLACE,
|
||||||
|
|
Loading…
Reference in a new issue