Merge remote-tracking branch 'upstream/master' into fix-freebsd-direct-session

This commit is contained in:
sghctoma 2018-09-02 18:32:31 +02:00
commit 3b2b8c1844
16 changed files with 107 additions and 60 deletions

View file

@ -25,4 +25,4 @@ tasks:
ninja
- clang: |
cd wlroots/build-clang
ninja
ninja scan-build

View file

@ -344,7 +344,8 @@ static void drm_connector_start_renderer(struct wlr_drm_connector *conn) {
void enable_drm_connector(struct wlr_output *output, bool enable) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
if (conn->state != WLR_DRM_CONN_CONNECTED) {
if (conn->state != WLR_DRM_CONN_CONNECTED
&& conn->state != WLR_DRM_CONN_NEEDS_MODESET) {
return;
}
@ -563,7 +564,7 @@ static bool drm_connector_set_mode(struct wlr_output *output,
struct wlr_drm_crtc *crtc = conn->crtc;
if (!crtc) {
wlr_log(WLR_ERROR, "Unable to match %s with a CRTC", conn->output.name);
goto error_conn;
return false;
}
wlr_log(WLR_DEBUG, "%s: crtc=%td ovr=%td pri=%td cur=%td", conn->output.name,
crtc - drm->crtcs,
@ -867,7 +868,9 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
// +1 so length can never be 0, which is undefined behaviour.
// Last element isn't used.
bool seen[seen_len + 1];
memset(seen, 0, sizeof(seen));
memset(seen, false, sizeof(seen));
size_t new_outputs_len = 0;
struct wlr_drm_connector *new_outputs[res->count_connectors + 1];
for (int i = 0; i < res->count_connectors; ++i) {
drmModeConnector *drm_conn = drmModeGetConnector(drm->fd,
@ -973,13 +976,10 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
wl_list_insert(&wlr_conn->output.modes, &mode->wlr_mode.link);
}
wlr_output_update_enabled(&wlr_conn->output, true);
wlr_output_update_enabled(&wlr_conn->output, wlr_conn->crtc != NULL);
wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET;
wlr_log(WLR_INFO, "Sending modesetting signal for '%s'",
wlr_conn->output.name);
wlr_signal_emit_safe(&drm->backend.events.new_output,
&wlr_conn->output);
new_outputs[new_outputs_len++] = wlr_conn;
} else if (wlr_conn->state == WLR_DRM_CONN_CONNECTED &&
drm_conn->connection != DRM_MODE_CONNECTED) {
wlr_log(WLR_INFO, "'%s' disconnected", wlr_conn->output.name);
@ -1010,6 +1010,15 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
wl_list_remove(&conn->link);
free(conn);
}
for (size_t i = 0; i < new_outputs_len; ++i) {
struct wlr_drm_connector *conn = new_outputs[i];
wlr_log(WLR_INFO, "Requesting modeset for '%s'",
conn->output.name);
wlr_signal_emit_safe(&drm->backend.events.new_output,
&conn->output);
}
}
static void page_flip_handler(int fd, unsigned seq,

View file

@ -28,7 +28,7 @@ static void add_pad_group_from_libinput(struct wlr_tablet_pad *pad,
++group->ring_count;
}
}
group->rings = calloc(sizeof(int), group->ring_count);
group->rings = calloc(sizeof(unsigned int), group->ring_count);
size_t ring = 0;
for (size_t i = 0; i < pad->ring_count; ++i) {
if (libinput_tablet_pad_mode_group_has_ring(li_group, i)) {
@ -41,7 +41,7 @@ static void add_pad_group_from_libinput(struct wlr_tablet_pad *pad,
++group->strip_count;
}
}
group->strips = calloc(sizeof(int), group->strip_count);
group->strips = calloc(sizeof(unsigned int), group->strip_count);
size_t strip = 0;
for (size_t i = 0; i < pad->strip_count; ++i) {
if (libinput_tablet_pad_mode_group_has_strip(li_group, i)) {
@ -54,7 +54,7 @@ static void add_pad_group_from_libinput(struct wlr_tablet_pad *pad,
++group->button_count;
}
}
group->buttons = calloc(sizeof(int), group->button_count);
group->buttons = calloc(sizeof(unsigned int), group->button_count);
size_t button = 0;
for (size_t i = 0; i < pad->button_count; ++i) {
if (libinput_tablet_pad_mode_group_has_button(li_group, i)) {

View file

@ -152,14 +152,20 @@ int main(int argc, char *argv[]) {
.display = display,
};
if (simulate_activity_timeout != 0 && simulate_activity_timeout < close_timeout) {
bool create_t1 = (simulate_activity_timeout != 0) &&
(simulate_activity_timeout < close_timeout);
if (create_t1) {
if (pthread_create(&t1, NULL, &simulate_activity, (void *)&arg) != 0) {
return -1;
}
}
if (close_timeout != 0) {
bool create_t2 = (close_timeout != 0);
if (create_t2) {
if (pthread_create(&t2, NULL, &close_program, (void *)&arg) != 0) {
if (simulate_activity_timeout != 0) {
if (create_t1) {
pthread_cancel(t1);
}
return -1;
@ -170,18 +176,19 @@ int main(int argc, char *argv[]) {
fprintf(stdout, "waiting\n");
if (pthread_create(&t3, NULL, &main_loop, (void *)display) != 0) {
if (simulate_activity_timeout != 0) {
if (create_t1) {
pthread_cancel(t1);
}
if (close_timeout != 0 ) {
if (create_t2) {
pthread_cancel(t2);
}
return -1;
}
if (simulate_activity_timeout != 0) {
if (create_t1) {
pthread_join(t1, NULL);
}
if (close_timeout != 0) {
if (create_t2) {
pthread_join(t2, NULL);
}
pthread_cancel(t3);

View file

@ -20,31 +20,31 @@ endif
examples = {
'simple': {
'src': 'simple.c',
'dep': wlroots,
'dep': [wlroots],
},
'pointer': {
'src': 'pointer.c',
'dep': wlroots,
'dep': [wlroots],
},
'touch': {
'src': ['touch.c', 'cat.c'],
'dep': wlroots,
'dep': [wlroots],
},
'tablet': {
'src': 'tablet.c',
'dep': wlroots,
'dep': [wlroots],
},
'rotation': {
'src': ['rotation.c', 'cat.c'],
'dep': wlroots,
'dep': [wlroots],
},
'multi-pointer': {
'src': 'multi-pointer.c',
'dep': wlroots,
'dep': [wlroots],
},
'output-layout': {
'src': ['output-layout.c', 'cat.c'],
'dep': wlroots,
'dep': [wlroots],
},
'screenshot': {
'src': 'screenshot.c',
@ -93,10 +93,18 @@ examples = {
}
foreach name, info : examples
all_dep_found = true
foreach d : info.get('dep')
all_dep_found = all_dep_found and d.found()
endforeach
if all_dep_found
executable(
name,
info.get('src'),
dependencies: info.get('dep'),
build_by_default: get_option('examples'),
)
else
warning('Dependencies not satisfied for ' + name)
endif
endforeach

View file

@ -10,7 +10,6 @@
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_layer_shell.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_list.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h>
@ -53,7 +52,6 @@ struct roots_desktop {
struct wlr_idle *idle;
struct wlr_idle_inhibit_manager_v1 *idle_inhibit;
struct wlr_input_inhibit_manager *input_inhibit;
struct wlr_linux_dmabuf_v1 *linux_dmabuf;
struct wlr_layer_shell *layer_shell;
struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard;
struct wlr_screencopy_manager_v1 *screencopy;

View file

@ -10,6 +10,7 @@
#define WLR_TYPES_WLR_SCREENCOPY_V1_H
#include <wayland-server.h>
#include <wlr/types/wlr_box.h>
struct wlr_screencopy_manager_v1 {
struct wl_global *global;

View file

@ -138,6 +138,7 @@ struct wlr_xwayland_surface {
struct wl_event_source *ping_timer;
// _NET_WM_STATE
bool modal;
bool fullscreen;
bool maximized_vert, maximized_horz;
@ -150,6 +151,7 @@ struct wlr_xwayland_surface {
struct wl_signal request_resize;
struct wl_signal request_maximize;
struct wl_signal request_fullscreen;
struct wl_signal request_activate;
struct wl_signal map;
struct wl_signal unmap;

View file

@ -40,6 +40,7 @@ enum atom_name {
_NET_WM_MOVERESIZE,
_NET_WM_NAME,
_NET_SUPPORTING_WM_CHECK,
_NET_WM_STATE_MODAL,
_NET_WM_STATE_FULLSCREEN,
_NET_WM_STATE_MAXIMIZED_VERT,
_NET_WM_STATE_MAXIMIZED_HORZ,

View file

@ -1,10 +1,11 @@
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <wlr/render/gles2.h>
#include <wlr/render/interface.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/render/gles2.h>
#include <wlr/util/log.h>
#include "util/signal.h"
@ -176,6 +177,10 @@ void wlr_renderer_init_wl_display(struct wlr_renderer *r,
}
}
if (r->impl->texture_from_dmabuf) {
wlr_linux_dmabuf_v1_create(wl_display, r);
}
if (r->impl->init_wl_display) {
r->impl->init_wl_display(r, wl_display);
}

View file

@ -14,7 +14,6 @@
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_layer_shell.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_server_decoration.h>
@ -893,9 +892,6 @@ struct roots_desktop *desktop_create(struct roots_server *server,
wl_signal_add(&desktop->input_inhibit->events.deactivate,
&desktop->input_inhibit_deactivate);
desktop->linux_dmabuf = wlr_linux_dmabuf_v1_create(server->wl_display,
server->renderer);
desktop->virtual_keyboard = wlr_virtual_keyboard_manager_v1_create(
server->wl_display);
wl_signal_add(&desktop->virtual_keyboard->events.new_virtual_keyboard,

View file

@ -822,12 +822,6 @@ void handle_new_output(struct wl_listener *listener, void *data) {
wlr_output->model, wlr_output->serial, wlr_output->phys_width,
wlr_output->phys_height);
if (!wl_list_empty(&wlr_output->modes)) {
struct wlr_output_mode *mode =
wl_container_of((&wlr_output->modes)->prev, mode, link);
wlr_output_set_mode(wlr_output, mode);
}
struct roots_output *output = calloc(1, sizeof(struct roots_output));
clock_gettime(CLOCK_MONOTONIC, &output->last_frame);
output->desktop = desktop;
@ -856,22 +850,28 @@ void handle_new_output(struct wl_listener *listener, void *data) {
struct roots_output_config *output_config =
roots_config_get_output(config, wlr_output);
if ((!output_config || output_config->enable) && !wl_list_empty(&wlr_output->modes)) {
struct wlr_output_mode *mode =
wl_container_of(wlr_output->modes.prev, mode, link);
wlr_output_set_mode(wlr_output, mode);
}
if (output_config) {
if (output_config->enable) {
struct roots_output_mode_config *mode_config;
if (wlr_output_is_drm(wlr_output)) {
struct roots_output_mode_config *mode_config;
wl_list_for_each(mode_config, &output_config->modes, link) {
wlr_drm_connector_add_mode(wlr_output, &mode_config->info);
}
} else {
if (!wl_list_empty(&output_config->modes)) {
} else if (!wl_list_empty(&output_config->modes)) {
wlr_log(WLR_ERROR, "Can only add modes for DRM backend");
}
}
if (output_config->mode.width) {
set_mode(wlr_output, output_config);
}
wlr_output_set_scale(wlr_output, output_config->scale);
wlr_output_set_transform(wlr_output, output_config->transform);
wlr_output_layout_add(desktop->layout, wlr_output, output_config->x,

View file

@ -507,8 +507,6 @@ static void decoration_handle_surface_commit(struct wl_listener *listener,
}
void handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop =
wl_container_of(listener, desktop, xdg_toplevel_decoration);
struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration = data;
wlr_log(WLR_DEBUG, "new xdg toplevel decoration");

View file

@ -368,7 +368,7 @@ struct wlr_tablet_v2_tablet_pad *wlr_tablet_pad_create(
}
pad->group_count = wl_list_length(&wlr_pad->groups);
pad->groups = calloc(pad->group_count, sizeof(int));
pad->groups = calloc(pad->group_count, sizeof(uint32_t));
if (!pad->groups) {
free(pad);
return NULL;
@ -471,9 +471,9 @@ void wlr_send_tablet_v2_tablet_pad_button(
void wlr_send_tablet_v2_tablet_pad_strip(struct wlr_tablet_v2_tablet_pad *pad,
uint32_t strip, double position, bool finger, uint32_t time) {
if (!pad->current_client &&
pad->current_client->strips &&
pad->current_client->strips[strip]) {
if (!pad->current_client ||
!pad->current_client->strips ||
!pad->current_client->strips[strip]) {
return;
}
struct wl_resource *resource = pad->current_client->strips[strip];

View file

@ -332,7 +332,7 @@ static void handle_pointer_motion(struct wl_listener *listener, void *data) {
static void apply_output_transform(double *x, double *y,
enum wl_output_transform transform) {
double dx = *x, dy = *y;
double dx = 0.0, dy = 0.0;
double width = 1.0, height = 1.0;
switch (transform) {

View file

@ -39,6 +39,7 @@ const char *atom_map[ATOM_LAST] = {
"_NET_WM_MOVERESIZE",
"_NET_WM_NAME",
"_NET_SUPPORTING_WM_CHECK",
"_NET_WM_STATE_MODAL",
"_NET_WM_STATE_FULLSCREEN",
"_NET_WM_STATE_MAXIMIZED_VERT",
"_NET_WM_STATE_MAXIMIZED_HORZ",
@ -147,6 +148,7 @@ static struct wlr_xwayland_surface *xwayland_surface_create(
wl_signal_init(&surface->events.request_resize);
wl_signal_init(&surface->events.request_maximize);
wl_signal_init(&surface->events.request_fullscreen);
wl_signal_init(&surface->events.request_activate);
wl_signal_init(&surface->events.map);
wl_signal_init(&surface->events.unmap);
wl_signal_init(&surface->events.set_class);
@ -268,6 +270,9 @@ static void xsurface_set_net_wm_state(struct wlr_xwayland_surface *xsurface) {
int i;
i = 0;
if (xsurface->modal) {
property[i++] = xwm->atoms[_NET_WM_STATE_MODAL];
}
if (xsurface->fullscreen) {
property[i++] = xwm->atoms[_NET_WM_STATE_FULLSCREEN];
}
@ -575,7 +580,9 @@ static void read_surface_net_wm_state(struct wlr_xwm *xwm,
xsurface->fullscreen = 0;
xcb_atom_t *atom = xcb_get_property_value(reply);
for (uint32_t i = 0; i < reply->value_len; i++) {
if (atom[i] == xwm->atoms[_NET_WM_STATE_FULLSCREEN]) {
if (atom[i] == xwm->atoms[_NET_WM_STATE_MODAL]) {
xsurface->modal = true;
} else if (atom[i] == xwm->atoms[_NET_WM_STATE_FULLSCREEN]) {
xsurface->fullscreen = true;
} else if (atom[i] == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT]) {
xsurface->maximized_vert = true;
@ -1028,7 +1035,10 @@ static void xwm_handle_net_wm_state_message(struct wlr_xwm *xwm,
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_MODAL] &&
update_state(action, &xsurface->modal)) {
xsurface_set_net_wm_state(xsurface);
} else if (property == xwm->atoms[_NET_WM_STATE_FULLSCREEN] &&
update_state(action, &xsurface->fullscreen)) {
xsurface_set_net_wm_state(xsurface);
} else if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT] &&
@ -1087,6 +1097,15 @@ static void xwm_handle_wm_protocols_message(struct wlr_xwm *xwm,
}
}
static void xwm_handle_net_active_window_message(struct wlr_xwm *xwm,
xcb_client_message_event_t *ev) {
struct wlr_xwayland_surface *surface = lookup_surface(xwm, ev->window);
if (surface == NULL) {
return;
}
wlr_signal_emit_safe(&surface->events.request_activate, surface);
}
static void xwm_handle_client_message(struct wlr_xwm *xwm,
xcb_client_message_event_t *ev) {
wlr_log(WLR_DEBUG, "XCB_CLIENT_MESSAGE (%u)", ev->window);
@ -1099,6 +1118,8 @@ static void xwm_handle_client_message(struct wlr_xwm *xwm,
xwm_handle_net_wm_moveresize_message(xwm, ev);
} else if (ev->type == xwm->atoms[WM_PROTOCOLS]) {
xwm_handle_wm_protocols_message(xwm, ev);
} else if (ev->type == xwm->atoms[_NET_ACTIVE_WINDOW]) {
xwm_handle_net_active_window_message(xwm, ev);
} else if (!xwm_handle_selection_client_message(xwm, ev)) {
char *type_name = xwm_get_atom_name(xwm, ev->type);
wlr_log(WLR_DEBUG, "unhandled x11 client message %u (%s)", ev->type,
@ -1630,6 +1651,7 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) {
xwm->atoms[NET_WM_STATE],
xwm->atoms[_NET_ACTIVE_WINDOW],
xwm->atoms[_NET_WM_MOVERESIZE],
xwm->atoms[_NET_WM_STATE_MODAL],
xwm->atoms[_NET_WM_STATE_FULLSCREEN],
xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT],
xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ],