Merge branch 'master' into feature/data-device-selection

master
Tony Crisci 7 years ago
commit b7c622a319

@ -7,3 +7,7 @@ charset = utf-8
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
[*.xml]
indent_style = space
indent_size = 2

@ -470,7 +470,7 @@ static void wlr_drm_connector_transform(struct wlr_output *output,
static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
int32_t hotspot_x, int32_t hotspot_y) {
int32_t hotspot_x, int32_t hotspot_y, bool update_pixels) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
struct wlr_drm_backend *drm = conn->drm;
struct wlr_drm_renderer *renderer = &drm->renderer;
@ -478,7 +478,8 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
struct wlr_drm_crtc *crtc = conn->crtc;
struct wlr_drm_plane *plane = crtc->cursor;
if (!buf) {
if (!buf && update_pixels) {
// Hide the cursor
return drm->iface->crtc_set_cursor(drm, crtc, NULL);
}
@ -566,6 +567,11 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
break;
}
if (!update_pixels) {
// Only update the cursor hotspot
return true;
}
struct gbm_bo *bo = plane->cursor_bo;
uint32_t bo_width = gbm_bo_get_width(bo);
uint32_t bo_height = gbm_bo_get_height(bo);

@ -54,13 +54,24 @@ static void wlr_wl_output_transform(struct wlr_output *_output,
static bool wlr_wl_output_set_cursor(struct wlr_output *_output,
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
int32_t hotspot_x, int32_t hotspot_y) {
int32_t hotspot_x, int32_t hotspot_y, bool update_pixels) {
struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
struct wlr_wl_backend *backend = output->backend;
if (!update_pixels) {
// Update hotspot without changing cursor image
wlr_wl_output_update_cursor(output, output->enter_serial, hotspot_x,
hotspot_y);
return true;
}
if (!buf) {
wl_pointer_set_cursor(output->backend->pointer, output->enter_serial,
NULL, 0, 0);
// Hide cursor
wl_surface_destroy(output->cursor_surface);
munmap(output->cursor_data, output->cursor_buf_size);
output->cursor_surface = NULL;
output->cursor_buf_size = 0;
wlr_wl_output_update_cursor(output, output->enter_serial, hotspot_x,
hotspot_y);
return true;
}
@ -153,7 +164,7 @@ static void wlr_wl_output_destroy(struct wlr_output *_output) {
void wlr_wl_output_update_cursor(struct wlr_wl_backend_output *output,
uint32_t serial, int32_t hotspot_x, int32_t hotspot_y) {
if (output->cursor_surface && output->backend->pointer && serial) {
if (output->backend->pointer && serial) {
wl_pointer_set_cursor(output->backend->pointer, serial,
output->cursor_surface, hotspot_x, hotspot_y);
}

@ -88,8 +88,8 @@ struct roots_input {
struct wlr_xcursor_theme *theme;
struct wlr_xcursor *xcursor;
struct wlr_seat *wl_seat;
struct roots_view *client_cursor_view;
struct wl_list drag_icons;
struct wl_client *cursor_client;
enum roots_cursor_mode mode;
struct roots_view *active_view, *last_active_view;

@ -17,8 +17,6 @@ struct roots_wl_shell_surface {
struct wl_listener request_set_maximized;
struct wl_listener surface_commit;
bool initialized;
};
struct roots_xdg_surface_v6 {
@ -32,8 +30,6 @@ struct roots_xdg_surface_v6 {
struct wl_listener request_move;
struct wl_listener request_resize;
struct wl_listener request_show_window_menu;
bool initialized;
};
struct roots_xwayland_surface {
@ -85,6 +81,6 @@ void view_activate(struct roots_view *view, bool active);
void view_resize(struct roots_view *view, uint32_t width, uint32_t height);
void view_close(struct roots_view *view);
bool view_center(struct roots_view *view);
bool view_initialize(struct roots_view *view);
void view_initialize(struct roots_view *view);
#endif

@ -8,16 +8,16 @@ struct wlr_output_impl {
void (*enable)(struct wlr_output *output, bool enable);
bool (*set_mode)(struct wlr_output *output, struct wlr_output_mode *mode);
void (*transform)(struct wlr_output *output,
enum wl_output_transform transform);
enum wl_output_transform transform);
bool (*set_cursor)(struct wlr_output *output, const uint8_t *buf,
int32_t stride, uint32_t width, uint32_t height,
int32_t hotspot_x, int32_t hotspot_y);
int32_t stride, uint32_t width, uint32_t height,
int32_t hotspot_x, int32_t hotspot_y, bool update_pixels);
bool (*move_cursor)(struct wlr_output *output, int x, int y);
void (*destroy)(struct wlr_output *output);
void (*make_current)(struct wlr_output *output);
void (*swap_buffers)(struct wlr_output *output);
void (*set_gamma)(struct wlr_output *output,
uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b);
uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b);
uint16_t (*get_gamma_size)(struct wlr_output *output);
};
@ -25,6 +25,6 @@ void wlr_output_init(struct wlr_output *output, const struct wlr_output_impl *im
void wlr_output_free(struct wlr_output *output);
void wlr_output_update_matrix(struct wlr_output *output);
struct wl_global *wlr_output_create_global(
struct wlr_output *wlr_output, struct wl_display *display);
struct wlr_output *wlr_output, struct wl_display *display);
#endif

@ -84,4 +84,10 @@ struct wlr_box *wlr_output_layout_get_box(
void wlr_output_layout_add_auto(struct wlr_output_layout *layout,
struct wlr_output *output);
/**
* Get the output closest to the center of the layout extents.
*/
struct wlr_output *wlr_output_layout_get_center_output(
struct wlr_output_layout *layout);
#endif

@ -106,6 +106,7 @@ struct wlr_xdg_surface_v6 {
struct wl_list popup_link;
bool configured;
bool added;
struct wl_event_source *configure_idle;
struct wl_list configure_list;

@ -86,10 +86,16 @@ void cursor_update_position(struct roots_input *input, uint32_t time) {
case ROOTS_CURSOR_PASSTHROUGH:
view = view_at(desktop, input->cursor->x, input->cursor->y, &surface,
&sx, &sy);
if (view != input->client_cursor_view) {
bool set_compositor_cursor = !view && input->cursor_client;
if (view) {
struct wl_client *view_client =
wl_resource_get_client(view->wlr_surface->resource);
set_compositor_cursor = view_client != input->cursor_client;
}
if (set_compositor_cursor) {
wlr_log(L_DEBUG, "Switching to compositor cursor");
cursor_set_xcursor_image(input, input->xcursor->images[0]);
input->client_cursor_view = NULL;
input->cursor_client = NULL;
}
if (view) {
wlr_seat_pointer_notify_enter(input->wl_seat, surface, sx, sy);
@ -355,18 +361,16 @@ static void handle_request_set_cursor(struct wl_listener *listener,
request_set_cursor);
struct wlr_seat_pointer_request_set_cursor_event *event = data;
struct wlr_surface *focused_surface = NULL;
double sx, sy;
struct roots_view *focused_view = view_at(input->server->desktop,
input->cursor->x, input->cursor->y, &focused_surface, &sx, &sy);
bool ok = focused_surface != NULL;
if (focused_surface != NULL) {
struct wlr_surface *focused_surface =
event->seat_handle->wlr_seat->pointer_state.focused_surface;
bool ok = focused_surface != NULL && focused_surface->resource != NULL;
if (ok) {
struct wl_client *focused_client =
wl_resource_get_client(focused_surface->resource);
ok = event->client == focused_client;
}
if (!ok) {
wlr_log(L_DEBUG, "Denying request to set cursor outside view");
wlr_log(L_DEBUG, "Denying request to set cursor from unfocused client");
return;
}
@ -378,7 +382,7 @@ static void handle_request_set_cursor(struct wl_listener *listener,
event->hotspot_x, event->hotspot_y);
}
input->client_cursor_view = focused_view;
input->cursor_client = event->client;
}
void cursor_initialize(struct roots_input *input) {

@ -67,35 +67,42 @@ void view_close(struct roots_view *view) {
bool view_center(struct roots_view *view) {
struct wlr_box size;
view_get_size(view, &size);
if (size.width == 0 && size.height == 0) {
return false;
}
struct roots_desktop *desktop = view->desktop;
struct wlr_cursor *cursor = desktop->server->input->cursor;
struct wlr_output *output = wlr_output_layout_output_at(desktop->layout,
cursor->x, cursor->y);
const struct wlr_output_layout_output *output_layout =
wlr_output_layout_get(desktop->layout, output);
struct wlr_output *output =
wlr_output_layout_output_at(desktop->layout, cursor->x, cursor->y);
if (!output) {
output = wlr_output_layout_get_center_output(desktop->layout);
}
if (!output) {
// empty layout
return false;
}
view->x = (double)(output->width - size.width) / 2
+ output_layout->x;
view->y = (double)(output->height - size.height) / 2
+ output_layout->y;
const struct wlr_output_layout_output *l_output =
wlr_output_layout_get(desktop->layout, output);
int width, height;
wlr_output_effective_resolution(output, &width, &height);
view->x = (double)(width - size.width) / 2
+ l_output->x;
view->y = (double)(height - size.height) / 2
+ l_output->y;
return true;
}
bool view_initialize(struct roots_view *view) {
bool centered = view_center(view);
if (centered) {
struct roots_input *input = view->desktop->server->input;
set_view_focus(input, view->desktop, view);
wlr_seat_keyboard_notify_enter(input->wl_seat, view->wlr_surface);
}
return centered;
void view_initialize(struct roots_view *view) {
view_center(view);
struct roots_input *input = view->desktop->server->input;
set_view_focus(input, view->desktop, view);
wlr_seat_keyboard_notify_enter(input->wl_seat, view->wlr_surface);
}
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,

@ -50,14 +50,7 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
}
static void handle_surface_commit(struct wl_listener *listener, void *data) {
struct roots_wl_shell_surface *roots_surface =
wl_container_of(listener, roots_surface, surface_commit);
struct roots_view *view = roots_surface->view;
if (view->wl_shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL &&
!roots_surface->initialized) {
roots_surface->initialized = view_initialize(view);
}
// TODO do we need to do anything here?
}
static void handle_destroy(struct wl_listener *listener, void *data) {
@ -137,4 +130,5 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
view->desktop = desktop;
roots_surface->view = view;
list_add(desktop->views, view);
view_initialize(view);
}

@ -68,14 +68,7 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
}
static void handle_commit(struct wl_listener *listener, void *data) {
struct roots_xdg_surface_v6 *roots_xdg_surface =
wl_container_of(listener, roots_xdg_surface, commit);
struct roots_view *view = roots_xdg_surface->view;
if (view->xdg_surface_v6->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL &&
!roots_xdg_surface->initialized) {
roots_xdg_surface->initialized = view_initialize(view);
}
// TODO is there anything we need to do here?
}
static void handle_destroy(struct wl_listener *listener, void *data) {
@ -141,4 +134,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
view->desktop = desktop;
roots_surface->view = view;
list_add(desktop->views, view);
view_initialize(view);
}

@ -127,7 +127,7 @@ static bool set_cursor(struct wlr_output *output, const uint8_t *buf,
int32_t hotspot_y) {
if (output->impl->set_cursor
&& output->impl->set_cursor(output, buf, stride, width, height,
hotspot_x, hotspot_y)) {
hotspot_x, hotspot_y, true)) {
output->cursor.is_sw = false;
return true;
}
@ -179,6 +179,10 @@ static inline int64_t timespec_to_msec(const struct timespec *a) {
static void commit_cursor_surface(struct wlr_output *output,
struct wlr_surface *surface) {
if (output->cursor.is_sw) {
return;
}
struct wl_shm_buffer *buffer = wl_shm_buffer_get(surface->current->buffer);
if (buffer == NULL) {
return;
@ -231,14 +235,19 @@ static void handle_cursor_surface_destroy(struct wl_listener *listener,
void wlr_output_set_cursor_surface(struct wlr_output *output,
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y) {
if (surface && strcmp(surface->role, "cursor") != 0) {
if (surface && strcmp(surface->role, "wl_pointer-cursor") != 0) {
return;
}
output->cursor.hotspot_x = hotspot_x;
output->cursor.hotspot_y = hotspot_y;
if (surface && output->cursor.surface == surface) {
if (surface && surface == output->cursor.surface) {
if (output->impl->set_cursor && !output->cursor.is_sw) {
// Only update the hotspot
output->impl->set_cursor(output, NULL, 0, 0, 0, hotspot_x,
hotspot_y, false);
}
return;
}
@ -248,11 +257,22 @@ void wlr_output_set_cursor_surface(struct wlr_output *output,
output->cursor.surface = NULL;
}
// Disable hardware cursor
// TODO: support hardware cursors
output->cursor.is_sw = true;
if (output->impl->set_cursor) {
output->impl->set_cursor(output, NULL, 0, 0, 0, hotspot_x, hotspot_y,
true);
}
//output->cursor.is_sw = output->impl->set_cursor == NULL;
output->cursor.surface = surface;
if (surface != NULL) {
wl_signal_add(&surface->events.commit, &output->cursor.surface_commit);
wl_signal_add(&surface->events.destroy, &output->cursor.surface_destroy);
wl_signal_add(&surface->events.destroy,
&output->cursor.surface_destroy);
commit_cursor_surface(output, surface);
} else {
set_cursor(output, NULL, 0, 0, 0, hotspot_x, hotspot_y);
}
@ -333,10 +353,20 @@ void wlr_output_swap_buffers(struct wlr_output *output) {
glViewport(0, 0, output->width, output->height);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
float matrix[16];
wlr_texture_get_matrix(output->cursor.texture, &matrix, &output->transform_matrix,
output->cursor.x, output->cursor.y);
wlr_render_with_matrix(output->cursor.renderer, output->cursor.texture, &matrix);
struct wlr_texture *texture = output->cursor.texture;
struct wlr_renderer *renderer = output->cursor.renderer;
if (output->cursor.surface) {
texture = output->cursor.surface->texture;
renderer = output->cursor.surface->renderer;
}
if (texture && renderer) {
float matrix[16];
wlr_texture_get_matrix(texture, &matrix, &output->transform_matrix,
output->cursor.x, output->cursor.y);
wlr_render_with_matrix(renderer, texture, &matrix);
}
}
wl_signal_emit(&output->events.swap_buffers, &output);

@ -343,3 +343,20 @@ void wlr_output_layout_add_auto(struct wlr_output_layout *layout,
l_output->state->auto_configured = true;
wlr_output_layout_reconfigure(layout);
}
struct wlr_output *wlr_output_layout_get_center_output(
struct wlr_output_layout *layout) {
if (wl_list_empty(&layout->outputs)) {
return NULL;
}
struct wlr_box *extents = wlr_output_layout_get_box(layout, NULL);
double center_x = extents->width / 2 + extents->x;
double center_y = extents->height / 2 + extents->y;
double dest_x = 0, dest_y = 0;
wlr_output_layout_closest_point(layout, NULL, center_x, center_y,
&dest_x, &dest_y);
return wlr_output_layout_output_at(layout, dest_x, dest_y);
}

@ -29,7 +29,7 @@ static void wl_pointer_set_cursor(struct wl_client *client,
if (surface_resource != NULL) {
surface = wl_resource_get_user_data(surface_resource);
if (wlr_surface_set_role(surface, "cursor", resource,
if (wlr_surface_set_role(surface, "wl_pointer-cursor", resource,
WL_POINTER_ERROR_ROLE) < 0) {
return;
}

@ -9,6 +9,7 @@
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/util/log.h>
#include <wlr/render/interface.h>
#include "xdg-shell-unstable-v6-protocol.h"
static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel";
@ -802,10 +803,7 @@ static void xdg_surface_ack_configure(struct wl_client *client,
break;
}
if (!surface->configured) {
surface->configured = true;
wl_signal_emit(&surface->client->shell->events.new_surface, surface);
}
surface->configured = true;
wl_signal_emit(&surface->events.ack_configure, surface);
@ -843,6 +841,10 @@ static const struct zxdg_surface_v6_interface zxdg_surface_v6_implementation = {
static bool wlr_xdg_surface_v6_toplevel_state_compare(
struct wlr_xdg_toplevel_v6 *state) {
// is pending state different from current state?
if (!state->base->configured) {
return false;
}
if (state->pending.activated != state->current.activated) {
return false;
}
@ -996,7 +998,7 @@ static void wlr_xdg_surface_v6_toplevel_committed(
struct wlr_xdg_surface_v6 *surface) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
if (!surface->surface->current->buffer && !surface->toplevel_state->added) {
if (!surface->surface->texture->valid && !surface->toplevel_state->added) {
// on the first commit, send a configure request to tell the client it
// is added
wlr_xdg_surface_v6_schedule_configure(surface, true);
@ -1004,7 +1006,7 @@ static void wlr_xdg_surface_v6_toplevel_committed(
return;
}
if (!surface->surface->current->buffer) {
if (!surface->surface->texture->valid) {
return;
}
@ -1026,7 +1028,7 @@ static void handle_wlr_surface_committed(struct wl_listener *listener,
struct wlr_xdg_surface_v6 *surface =
wl_container_of(listener, surface, surface_commit_listener);
if (surface->surface->current->buffer && !surface->configured) {
if (surface->surface->texture->valid && !surface->configured) {
wl_resource_post_error(surface->resource,
ZXDG_SURFACE_V6_ERROR_UNCONFIGURED_BUFFER,
"xdg_surface has never been configured");
@ -1055,6 +1057,11 @@ static void handle_wlr_surface_committed(struct wl_listener *listener,
break;
}
if (surface->configured && !surface->added) {
surface->added = true;
wl_signal_emit(&surface->client->shell->events.new_surface, surface);
}
wl_signal_emit(&surface->events.commit, surface);
}
@ -1090,7 +1097,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
&zxdg_surface_v6_interface, wl_resource_get_version(client_resource),
id);
if (surface->surface->current->buffer != NULL) {
if (surface->surface->texture->valid) {
wl_resource_post_error(surface->resource,
ZXDG_SURFACE_V6_ERROR_UNCONFIGURED_BUFFER,
"xdg_surface must not have a buffer at creation");
@ -1258,42 +1265,49 @@ void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface) {
void wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface,
uint32_t width, uint32_t height) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
bool force =
(surface->toplevel_state->pending.width != width ||
surface->toplevel_state->pending.height != height);
surface->toplevel_state->pending.width = width;
surface->toplevel_state->pending.height = height;
wlr_xdg_surface_v6_schedule_configure(surface, false);
wlr_xdg_surface_v6_schedule_configure(surface, force);
}
void wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface,
bool activated) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
bool force = surface->toplevel_state->pending.activated != activated;
surface->toplevel_state->pending.activated = activated;
wlr_xdg_surface_v6_schedule_configure(surface, false);
wlr_xdg_surface_v6_schedule_configure(surface, force);
}
void wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface,
bool maximized) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
bool force = surface->toplevel_state->pending.maximized != maximized;
surface->toplevel_state->pending.maximized = maximized;
wlr_xdg_surface_v6_schedule_configure(surface, false);
wlr_xdg_surface_v6_schedule_configure(surface, force);
}
void wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface,
bool fullscreen) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
bool force = surface->toplevel_state->pending.fullscreen != fullscreen;
surface->toplevel_state->pending.fullscreen = fullscreen;
wlr_xdg_surface_v6_schedule_configure(surface, false);
wlr_xdg_surface_v6_schedule_configure(surface, force);
}
void wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface,
bool resizing) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
surface->toplevel_state->pending.fullscreen = resizing;
bool force = surface->toplevel_state->pending.resizing != resizing;
surface->toplevel_state->pending.resizing = resizing;
wlr_xdg_surface_v6_schedule_configure(surface, false);
wlr_xdg_surface_v6_schedule_configure(surface, force);
}
void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface) {

Loading…
Cancel
Save