mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-07 14:06:00 +01:00
Merge remote-tracking branch 'upstream/master' into fix-freebsd-direct-session
This commit is contained in:
commit
bbeed1bd31
25 changed files with 406 additions and 232 deletions
|
@ -5,10 +5,8 @@ end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = 4
|
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
[*.xml]
|
[*.xml]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
tab_width = 8
|
|
||||||
|
|
|
@ -404,9 +404,11 @@ static void realloc_planes(struct wlr_drm_backend *drm, const uint32_t *crtc_in,
|
||||||
struct wlr_drm_plane *new = &drm->type_planes[type][crtc_res[i]];
|
struct wlr_drm_plane *new = &drm->type_planes[type][crtc_res[i]];
|
||||||
|
|
||||||
if (*old != new) {
|
if (*old != new) {
|
||||||
wlr_log(WLR_DEBUG, "Assigning plane %d -> %d to CRTC %d",
|
wlr_log(WLR_DEBUG,
|
||||||
|
"Assigning plane %d -> %d (type %zu) to CRTC %d",
|
||||||
*old ? (int)(*old)->id : -1,
|
*old ? (int)(*old)->id : -1,
|
||||||
new ? (int)new->id : -1,
|
new ? (int)new->id : -1,
|
||||||
|
type,
|
||||||
c->id);
|
c->id);
|
||||||
|
|
||||||
changed_outputs[crtc_res[i]] = true;
|
changed_outputs[crtc_res[i]] = true;
|
||||||
|
@ -420,192 +422,41 @@ static void realloc_planes(struct wlr_drm_backend *drm, const uint32_t *crtc_in,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void realloc_crtcs(struct wlr_drm_backend *drm,
|
|
||||||
struct wlr_drm_connector *conn, bool *changed_outputs) {
|
|
||||||
uint32_t crtc[drm->num_crtcs];
|
|
||||||
uint32_t crtc_res[drm->num_crtcs];
|
|
||||||
ssize_t num_outputs = wl_list_length(&drm->outputs);
|
|
||||||
uint32_t possible_crtc[num_outputs];
|
|
||||||
|
|
||||||
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
|
||||||
crtc[i] = UNMATCHED;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(possible_crtc, 0, sizeof(possible_crtc));
|
|
||||||
|
|
||||||
wlr_log(WLR_DEBUG, "Reallocating CRTCs for output '%s'", conn->output.name);
|
|
||||||
|
|
||||||
ssize_t index = -1, i = -1;
|
|
||||||
struct wlr_drm_connector *c;
|
|
||||||
wl_list_for_each(c, &drm->outputs, link) {
|
|
||||||
i++;
|
|
||||||
if (c == conn) {
|
|
||||||
index = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_log(WLR_DEBUG, "output '%s' crtc=%p state=%d",
|
|
||||||
c->output.name, c->crtc, c->state);
|
|
||||||
|
|
||||||
if (c->crtc) {
|
|
||||||
crtc[c->crtc - drm->crtcs] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c->state == WLR_DRM_CONN_CONNECTED) {
|
|
||||||
possible_crtc[i] = c->possible_crtc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert(index != -1);
|
|
||||||
|
|
||||||
possible_crtc[index] = conn->possible_crtc;
|
|
||||||
match_obj(wl_list_length(&drm->outputs), possible_crtc,
|
|
||||||
drm->num_crtcs, crtc, crtc_res);
|
|
||||||
|
|
||||||
bool matched[num_outputs];
|
|
||||||
memset(matched, false, sizeof(matched));
|
|
||||||
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
|
||||||
if (crtc_res[i] != UNMATCHED) {
|
|
||||||
matched[crtc_res[i]] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is no point doing anything if this monitor doesn't get activated
|
|
||||||
if (!matched[index]) {
|
|
||||||
wlr_log(WLR_DEBUG, "Could not match a CRTC for this output");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
|
||||||
// We don't want any of the current monitors to be deactivated.
|
|
||||||
if (crtc[i] != UNMATCHED && !matched[crtc[i]]) {
|
|
||||||
wlr_log(WLR_DEBUG, "Could not match a CRTC for other output %d",
|
|
||||||
crtc[i]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
changed_outputs[index] = true;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
|
||||||
if (crtc_res[i] == UNMATCHED) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (crtc_res[i] != crtc[i]) {
|
|
||||||
changed_outputs[crtc_res[i]] = true;
|
|
||||||
struct wlr_drm_connector *c;
|
|
||||||
size_t pos = 0;
|
|
||||||
wl_list_for_each(c, &drm->outputs, link) {
|
|
||||||
if (pos == crtc_res[i]) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
c->crtc = &drm->crtcs[i];
|
|
||||||
|
|
||||||
wlr_log(WLR_DEBUG, "Assigning CRTC %d to output '%s'",
|
|
||||||
drm->crtcs[i].id, c->output.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
realloc_planes(drm, crtc_res, changed_outputs);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t get_possible_crtcs(int fd, uint32_t conn_id) {
|
|
||||||
drmModeConnector *conn = drmModeGetConnector(fd, conn_id);
|
|
||||||
if (!conn) {
|
|
||||||
wlr_log_errno(WLR_ERROR, "Failed to get DRM connector");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conn->connection != DRM_MODE_CONNECTED || conn->count_modes == 0) {
|
|
||||||
wlr_log(WLR_ERROR, "Output is not connected");
|
|
||||||
goto error_conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
drmModeEncoder *enc = NULL;
|
|
||||||
for (int i = 0; !enc && i < conn->count_encoders; ++i) {
|
|
||||||
enc = drmModeGetEncoder(fd, conn->encoders[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!enc) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to get DRM encoder");
|
|
||||||
goto error_conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t ret = enc->possible_crtcs;
|
|
||||||
drmModeFreeEncoder(enc);
|
|
||||||
drmModeFreeConnector(conn);
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
error_conn:
|
|
||||||
drmModeFreeConnector(conn);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void drm_connector_cleanup(struct wlr_drm_connector *conn);
|
static void drm_connector_cleanup(struct wlr_drm_connector *conn);
|
||||||
|
|
||||||
static bool drm_connector_set_mode(struct wlr_output *output,
|
static bool drm_connector_set_mode(struct wlr_output *output,
|
||||||
struct wlr_output_mode *mode) {
|
struct wlr_output_mode *mode) {
|
||||||
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
|
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
|
||||||
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
|
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
|
||||||
bool changed_outputs[wl_list_length(&drm->outputs)];
|
if (conn->crtc == NULL) {
|
||||||
|
wlr_log(WLR_ERROR, "Cannot modeset '%s': no CRTC for this connector",
|
||||||
wlr_log(WLR_INFO, "Modesetting '%s' with '%ux%u@%u mHz'", conn->output.name,
|
conn->output.name);
|
||||||
mode->width, mode->height, mode->refresh);
|
// Save the desired mode for later, when we'll get a proper CRTC
|
||||||
|
conn->desired_mode = mode;
|
||||||
conn->possible_crtc = get_possible_crtcs(drm->fd, conn->id);
|
return false;
|
||||||
if (conn->possible_crtc == 0) {
|
}
|
||||||
goto error_conn;
|
|
||||||
}
|
wlr_log(WLR_INFO, "Modesetting '%s' with '%ux%u@%u mHz'",
|
||||||
|
conn->output.name, mode->width, mode->height, mode->refresh);
|
||||||
memset(changed_outputs, false, sizeof(changed_outputs));
|
|
||||||
realloc_crtcs(drm, conn, changed_outputs);
|
if (!init_drm_plane_surfaces(conn->crtc->primary, drm,
|
||||||
|
mode->width, mode->height, GBM_FORMAT_XRGB8888)) {
|
||||||
struct wlr_drm_crtc *crtc = conn->crtc;
|
wlr_log(WLR_ERROR, "Failed to initialize renderer for plane");
|
||||||
if (!crtc) {
|
|
||||||
wlr_log(WLR_ERROR, "Unable to match %s with a CRTC", conn->output.name);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
wlr_log(WLR_DEBUG, "%s: crtc=%td ovr=%td pri=%td cur=%td", conn->output.name,
|
|
||||||
crtc - drm->crtcs,
|
|
||||||
crtc->overlay ? crtc->overlay - drm->overlay_planes : -1,
|
|
||||||
crtc->primary ? crtc->primary - drm->primary_planes : -1,
|
|
||||||
crtc->cursor ? crtc->cursor - drm->cursor_planes : -1);
|
|
||||||
|
|
||||||
conn->state = WLR_DRM_CONN_CONNECTED;
|
conn->state = WLR_DRM_CONN_CONNECTED;
|
||||||
|
conn->desired_mode = NULL;
|
||||||
wlr_output_update_mode(&conn->output, mode);
|
wlr_output_update_mode(&conn->output, mode);
|
||||||
|
wlr_output_update_enabled(&conn->output, true);
|
||||||
|
|
||||||
|
drm_connector_start_renderer(conn);
|
||||||
|
|
||||||
// When switching VTs, the mode is not updated but the buffers become
|
// When switching VTs, the mode is not updated but the buffers become
|
||||||
// invalid, so we need to manually damage the output here
|
// invalid, so we need to manually damage the output here
|
||||||
wlr_output_damage_whole(&conn->output);
|
wlr_output_damage_whole(&conn->output);
|
||||||
|
|
||||||
// Since realloc_crtcs can deallocate planes on OTHER outputs,
|
|
||||||
// we actually need to reinitialize any that has changed
|
|
||||||
ssize_t output_index = -1;
|
|
||||||
wl_list_for_each(conn, &drm->outputs, link) {
|
|
||||||
output_index++;
|
|
||||||
struct wlr_output_mode *mode = conn->output.current_mode;
|
|
||||||
struct wlr_drm_crtc *crtc = conn->crtc;
|
|
||||||
|
|
||||||
if (conn->state != WLR_DRM_CONN_CONNECTED ||
|
|
||||||
!changed_outputs[output_index]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!init_drm_plane_surfaces(crtc->primary, drm,
|
|
||||||
mode->width, mode->height, GBM_FORMAT_XRGB8888)) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to initialize renderer for plane");
|
|
||||||
goto error_conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
drm_connector_start_renderer(conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error_conn:
|
|
||||||
drm_connector_cleanup(conn);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_drm_connector_add_mode(struct wlr_output *output,
|
bool wlr_drm_connector_add_mode(struct wlr_output *output,
|
||||||
|
@ -855,6 +706,172 @@ static const int32_t subpixel_map[] = {
|
||||||
[DRM_MODE_SUBPIXEL_NONE] = WL_OUTPUT_SUBPIXEL_NONE,
|
[DRM_MODE_SUBPIXEL_NONE] = WL_OUTPUT_SUBPIXEL_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void dealloc_crtc(struct wlr_drm_connector *conn) {
|
||||||
|
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)conn->output.backend;
|
||||||
|
if (conn->crtc == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_log(WLR_DEBUG, "De-allocating CRTC %zu for output '%s'",
|
||||||
|
conn->crtc - drm->crtcs, conn->output.name);
|
||||||
|
|
||||||
|
for (size_t type = 0; type < 3; ++type) {
|
||||||
|
struct wlr_drm_plane *plane = conn->crtc->planes[type];
|
||||||
|
if (plane == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
finish_drm_surface(&plane->surf);
|
||||||
|
conn->crtc->planes[type] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
drm->iface->conn_enable(drm, conn, false);
|
||||||
|
|
||||||
|
conn->crtc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void realloc_crtcs(struct wlr_drm_backend *drm, bool *changed_outputs) {
|
||||||
|
size_t num_outputs = wl_list_length(&drm->outputs);
|
||||||
|
|
||||||
|
wlr_log(WLR_DEBUG, "Reallocating CRTCs");
|
||||||
|
|
||||||
|
uint32_t crtc[drm->num_crtcs];
|
||||||
|
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
||||||
|
crtc[i] = UNMATCHED;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t possible_crtc[num_outputs];
|
||||||
|
memset(possible_crtc, 0, sizeof(possible_crtc));
|
||||||
|
|
||||||
|
wlr_log(WLR_DEBUG, "State before reallocation:");
|
||||||
|
ssize_t i = -1;
|
||||||
|
struct wlr_drm_connector *conn;
|
||||||
|
wl_list_for_each(conn, &drm->outputs, link) {
|
||||||
|
i++;
|
||||||
|
|
||||||
|
wlr_log(WLR_DEBUG, " '%s' crtc=%d state=%d", conn->output.name,
|
||||||
|
conn->crtc ? (int)(conn->crtc - drm->crtcs) : -1, conn->state);
|
||||||
|
|
||||||
|
if (conn->crtc) {
|
||||||
|
crtc[conn->crtc - drm->crtcs] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (conn->state == WLR_DRM_CONN_CONNECTED ||
|
||||||
|
conn->state == WLR_DRM_CONN_NEEDS_MODESET) {
|
||||||
|
possible_crtc[i] = conn->possible_crtc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t crtc_res[drm->num_crtcs];
|
||||||
|
match_obj(wl_list_length(&drm->outputs), possible_crtc,
|
||||||
|
drm->num_crtcs, crtc, crtc_res);
|
||||||
|
|
||||||
|
bool matched[num_outputs];
|
||||||
|
memset(matched, false, sizeof(matched));
|
||||||
|
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
||||||
|
if (crtc_res[i] != UNMATCHED) {
|
||||||
|
matched[crtc_res[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
||||||
|
// We don't want any of the current monitors to be deactivated
|
||||||
|
if (crtc[i] != UNMATCHED && !matched[crtc[i]]) {
|
||||||
|
wlr_log(WLR_DEBUG, "Could not match a CRTC for connected output %d",
|
||||||
|
crtc[i]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < drm->num_crtcs; ++i) {
|
||||||
|
if (crtc_res[i] == UNMATCHED) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crtc_res[i] != crtc[i]) {
|
||||||
|
changed_outputs[crtc_res[i]] = true;
|
||||||
|
|
||||||
|
struct wlr_drm_connector *c;
|
||||||
|
size_t pos = 0;
|
||||||
|
wl_list_for_each(c, &drm->outputs, link) {
|
||||||
|
if (pos == crtc_res[i]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
dealloc_crtc(c);
|
||||||
|
c->crtc = &drm->crtcs[i];
|
||||||
|
|
||||||
|
wlr_log(WLR_DEBUG, "Assigning CRTC %zu to output %d -> %d '%s'",
|
||||||
|
i, crtc[i], crtc_res[i], c->output.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_log(WLR_DEBUG, "State after reallocation:");
|
||||||
|
wl_list_for_each(conn, &drm->outputs, link) {
|
||||||
|
wlr_log(WLR_DEBUG, " '%s' crtc=%d state=%d", conn->output.name,
|
||||||
|
conn->crtc ? (int)(conn->crtc - drm->crtcs) : -1, conn->state);
|
||||||
|
}
|
||||||
|
|
||||||
|
realloc_planes(drm, crtc_res, changed_outputs);
|
||||||
|
|
||||||
|
// We need to reinitialize any plane that has changed
|
||||||
|
i = -1;
|
||||||
|
wl_list_for_each(conn, &drm->outputs, link) {
|
||||||
|
i++;
|
||||||
|
struct wlr_output_mode *mode = conn->output.current_mode;
|
||||||
|
|
||||||
|
if (conn->state != WLR_DRM_CONN_CONNECTED || !changed_outputs[i]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assert(conn->crtc);
|
||||||
|
|
||||||
|
if (!init_drm_plane_surfaces(conn->crtc->primary, drm,
|
||||||
|
mode->width, mode->height, GBM_FORMAT_XRGB8888)) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to initialize renderer for plane");
|
||||||
|
drm_connector_cleanup(conn);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
drm_connector_start_renderer(conn);
|
||||||
|
|
||||||
|
wlr_output_damage_whole(&conn->output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t get_possible_crtcs(int fd, uint32_t conn_id) {
|
||||||
|
drmModeConnector *conn = drmModeGetConnector(fd, conn_id);
|
||||||
|
if (!conn) {
|
||||||
|
wlr_log_errno(WLR_ERROR, "Failed to get DRM connector");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (conn->connection != DRM_MODE_CONNECTED || conn->count_modes == 0) {
|
||||||
|
wlr_log(WLR_ERROR, "Output is not connected");
|
||||||
|
goto error_conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
drmModeEncoder *enc = NULL;
|
||||||
|
for (int i = 0; !enc && i < conn->count_encoders; ++i) {
|
||||||
|
enc = drmModeGetEncoder(fd, conn->encoders[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enc) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to get DRM encoder");
|
||||||
|
goto error_conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t ret = enc->possible_crtcs;
|
||||||
|
drmModeFreeEncoder(enc);
|
||||||
|
drmModeFreeConnector(conn);
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
error_conn:
|
||||||
|
drmModeFreeConnector(conn);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
||||||
wlr_log(WLR_INFO, "Scanning DRM connectors");
|
wlr_log(WLR_INFO, "Scanning DRM connectors");
|
||||||
|
|
||||||
|
@ -910,17 +927,16 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
||||||
wlr_conn->state = WLR_DRM_CONN_DISCONNECTED;
|
wlr_conn->state = WLR_DRM_CONN_DISCONNECTED;
|
||||||
wlr_conn->id = drm_conn->connector_id;
|
wlr_conn->id = drm_conn->connector_id;
|
||||||
|
|
||||||
|
snprintf(wlr_conn->output.name, sizeof(wlr_conn->output.name),
|
||||||
|
"%s-%"PRIu32, conn_get_name(drm_conn->connector_type),
|
||||||
|
drm_conn->connector_type_id);
|
||||||
|
|
||||||
if (curr_enc) {
|
if (curr_enc) {
|
||||||
wlr_conn->old_crtc = drmModeGetCrtc(drm->fd, curr_enc->crtc_id);
|
wlr_conn->old_crtc = drmModeGetCrtc(drm->fd, curr_enc->crtc_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(wlr_conn->output.name, sizeof(wlr_conn->output.name),
|
|
||||||
"%s-%"PRIu32,
|
|
||||||
conn_get_name(drm_conn->connector_type),
|
|
||||||
drm_conn->connector_type_id);
|
|
||||||
|
|
||||||
wl_list_insert(&drm->outputs, &wlr_conn->link);
|
wl_list_insert(&drm->outputs, &wlr_conn->link);
|
||||||
wlr_log(WLR_INFO, "Found display '%s'", wlr_conn->output.name);
|
wlr_log(WLR_INFO, "Found connector '%s'", wlr_conn->output.name);
|
||||||
} else {
|
} else {
|
||||||
seen[index] = true;
|
seen[index] = true;
|
||||||
}
|
}
|
||||||
|
@ -976,6 +992,12 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
||||||
wl_list_insert(&wlr_conn->output.modes, &mode->wlr_mode.link);
|
wl_list_insert(&wlr_conn->output.modes, &mode->wlr_mode.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wlr_conn->possible_crtc = get_possible_crtcs(drm->fd, wlr_conn->id);
|
||||||
|
if (wlr_conn->possible_crtc == 0) {
|
||||||
|
wlr_log(WLR_ERROR, "No CRTC possible for connector '%s'",
|
||||||
|
wlr_conn->output.name);
|
||||||
|
}
|
||||||
|
|
||||||
wlr_output_update_enabled(&wlr_conn->output, wlr_conn->crtc != NULL);
|
wlr_output_update_enabled(&wlr_conn->output, wlr_conn->crtc != NULL);
|
||||||
|
|
||||||
wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET;
|
wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET;
|
||||||
|
@ -984,7 +1006,6 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
||||||
drm_conn->connection != DRM_MODE_CONNECTED) {
|
drm_conn->connection != DRM_MODE_CONNECTED) {
|
||||||
wlr_log(WLR_INFO, "'%s' disconnected", wlr_conn->output.name);
|
wlr_log(WLR_INFO, "'%s' disconnected", wlr_conn->output.name);
|
||||||
|
|
||||||
wlr_output_update_enabled(&wlr_conn->output, false);
|
|
||||||
drm_connector_cleanup(wlr_conn);
|
drm_connector_cleanup(wlr_conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,6 +1032,26 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
||||||
free(conn);
|
free(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool changed_outputs[wl_list_length(&drm->outputs)];
|
||||||
|
memset(changed_outputs, false, sizeof(changed_outputs));
|
||||||
|
for (size_t i = 0; i < new_outputs_len; ++i) {
|
||||||
|
struct wlr_drm_connector *conn = new_outputs[i];
|
||||||
|
|
||||||
|
ssize_t pos = -1;
|
||||||
|
struct wlr_drm_connector *c;
|
||||||
|
wl_list_for_each(c, &drm->outputs, link) {
|
||||||
|
++pos;
|
||||||
|
if (c == conn) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(pos >= 0);
|
||||||
|
|
||||||
|
changed_outputs[pos] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
realloc_crtcs(drm, changed_outputs);
|
||||||
|
|
||||||
for (size_t i = 0; i < new_outputs_len; ++i) {
|
for (size_t i = 0; i < new_outputs_len; ++i) {
|
||||||
struct wlr_drm_connector *conn = new_outputs[i];
|
struct wlr_drm_connector *conn = new_outputs[i];
|
||||||
|
|
||||||
|
@ -1019,6 +1060,15 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
||||||
wlr_signal_emit_safe(&drm->backend.events.new_output,
|
wlr_signal_emit_safe(&drm->backend.events.new_output,
|
||||||
&conn->output);
|
&conn->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to modeset any output that has a desired mode and a CRTC (ie. was
|
||||||
|
// lacking a CRTC on last modeset)
|
||||||
|
wl_list_for_each(conn, &drm->outputs, link) {
|
||||||
|
if (conn->state == WLR_DRM_CONN_NEEDS_MODESET && conn->crtc != NULL &&
|
||||||
|
conn->desired_mode != NULL) {
|
||||||
|
drm_connector_set_mode(&conn->output, conn->desired_mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void page_flip_handler(int fd, unsigned seq,
|
static void page_flip_handler(int fd, unsigned seq,
|
||||||
|
@ -1114,23 +1164,28 @@ static void drm_connector_cleanup(struct wlr_drm_connector *conn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->output.current_mode = NULL;
|
conn->output.current_mode = NULL;
|
||||||
|
conn->desired_mode = NULL;
|
||||||
struct wlr_drm_mode *mode, *tmp;
|
struct wlr_drm_mode *mode, *tmp;
|
||||||
wl_list_for_each_safe(mode, tmp, &conn->output.modes, wlr_mode.link) {
|
wl_list_for_each_safe(mode, tmp, &conn->output.modes, wlr_mode.link) {
|
||||||
wl_list_remove(&mode->wlr_mode.link);
|
wl_list_remove(&mode->wlr_mode.link);
|
||||||
free(mode);
|
free(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conn->output.enabled = false;
|
||||||
|
conn->output.width = conn->output.height = conn->output.refresh = 0;
|
||||||
|
|
||||||
memset(&conn->output.make, 0, sizeof(conn->output.make));
|
memset(&conn->output.make, 0, sizeof(conn->output.make));
|
||||||
memset(&conn->output.model, 0, sizeof(conn->output.model));
|
memset(&conn->output.model, 0, sizeof(conn->output.model));
|
||||||
memset(&conn->output.serial, 0, sizeof(conn->output.serial));
|
memset(&conn->output.serial, 0, sizeof(conn->output.serial));
|
||||||
|
|
||||||
conn->crtc = NULL;
|
|
||||||
conn->possible_crtc = 0;
|
|
||||||
conn->pageflip_pending = false;
|
conn->pageflip_pending = false;
|
||||||
/* Fallthrough */
|
/* Fallthrough */
|
||||||
case WLR_DRM_CONN_NEEDS_MODESET:
|
case WLR_DRM_CONN_NEEDS_MODESET:
|
||||||
wlr_log(WLR_INFO, "Emitting destruction signal for '%s'",
|
wlr_log(WLR_INFO, "Emitting destruction signal for '%s'",
|
||||||
conn->output.name);
|
conn->output.name);
|
||||||
|
dealloc_crtc(conn);
|
||||||
|
conn->possible_crtc = 0;
|
||||||
|
conn->desired_mode = NULL;
|
||||||
wlr_signal_emit_safe(&conn->output.events.destroy, &conn->output);
|
wlr_signal_emit_safe(&conn->output.events.destroy, &conn->output);
|
||||||
break;
|
break;
|
||||||
case WLR_DRM_CONN_DISCONNECTED:
|
case WLR_DRM_CONN_DISCONNECTED:
|
||||||
|
|
|
@ -228,9 +228,6 @@ static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_
|
||||||
st->replaced = replaced;
|
st->replaced = replaced;
|
||||||
memcpy(st->best, st->res, sizeof(st->best[0]) * st->num_res);
|
memcpy(st->best, st->res, sizeof(st->best[0]) * st->num_res);
|
||||||
|
|
||||||
if (st->score == st->num_objs && st->replaced == 0) {
|
|
||||||
st->exit_early = true;
|
|
||||||
}
|
|
||||||
st->exit_early = (st->score == st->num_res - skips
|
st->exit_early = (st->score == st->num_res - skips
|
||||||
|| st->score == st->num_objs)
|
|| st->score == st->num_objs)
|
||||||
&& st->replaced == 0;
|
&& st->replaced == 0;
|
||||||
|
@ -250,37 +247,44 @@ static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_
|
||||||
* Attempt to use the current solution first, to try and avoid
|
* Attempt to use the current solution first, to try and avoid
|
||||||
* recalculating everything
|
* recalculating everything
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (st->orig[i] != UNMATCHED && !is_taken(i, st->res, st->orig[i])) {
|
if (st->orig[i] != UNMATCHED && !is_taken(i, st->res, st->orig[i])) {
|
||||||
st->res[i] = st->orig[i];
|
st->res[i] = st->orig[i];
|
||||||
if (match_obj_(st, skips, score + 1, replaced, i + 1)) {
|
if (match_obj_(st, skips, score + 1, replaced, i + 1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (st->orig[i] == UNMATCHED) {
|
||||||
|
st->res[i] = UNMATCHED;
|
||||||
|
match_obj_(st, skips, score, replaced, i + 1);
|
||||||
|
if (st->exit_early) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (st->orig[i] != UNMATCHED) {
|
if (st->orig[i] != UNMATCHED) {
|
||||||
++replaced;
|
++replaced;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_best = false;
|
bool has_best = false;
|
||||||
for (st->res[i] = 0; st->res[i] < st->num_objs; ++st->res[i]) {
|
for (size_t candidate = 0; candidate < st->num_objs; ++candidate) {
|
||||||
// We tried this earlier
|
// We tried this earlier
|
||||||
if (st->res[i] == st->orig[i]) {
|
if (candidate == st->orig[i]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not compatible
|
// Not compatible
|
||||||
if (!(st->objs[st->res[i]] & (1 << i))) {
|
if (!(st->objs[candidate] & (1 << i))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Already taken
|
// Already taken
|
||||||
if (is_taken(i, st->res, st->res[i])) {
|
if (is_taken(i, st->res, candidate)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
st->res[i] = candidate;
|
||||||
if (match_obj_(st, skips, score + 1, replaced, i + 1)) {
|
if (match_obj_(st, skips, score + 1, replaced, i + 1)) {
|
||||||
is_best = true;
|
has_best = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st->exit_early) {
|
if (st->exit_early) {
|
||||||
|
@ -288,7 +292,7 @@ static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_best) {
|
if (has_best) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,6 +305,9 @@ size_t match_obj(size_t num_objs, const uint32_t objs[static restrict num_objs],
|
||||||
size_t num_res, const uint32_t res[static restrict num_res],
|
size_t num_res, const uint32_t res[static restrict num_res],
|
||||||
uint32_t out[static restrict num_res]) {
|
uint32_t out[static restrict num_res]) {
|
||||||
uint32_t solution[num_res];
|
uint32_t solution[num_res];
|
||||||
|
for (size_t i = 0; i < num_res; ++i) {
|
||||||
|
solution[i] = UNMATCHED;
|
||||||
|
}
|
||||||
|
|
||||||
struct match_state st = {
|
struct match_state st = {
|
||||||
.num_objs = num_objs,
|
.num_objs = num_objs,
|
||||||
|
|
|
@ -163,6 +163,8 @@ static bool backend_start(struct wlr_backend *backend) {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
free(reply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -129,6 +129,7 @@ int main(int argc, char *argv[]) {
|
||||||
wl_registry_add_listener(registry, ®istry_listener, NULL);
|
wl_registry_add_listener(registry, ®istry_listener, NULL);
|
||||||
wl_display_dispatch(display);
|
wl_display_dispatch(display);
|
||||||
wl_display_roundtrip(display);
|
wl_display_roundtrip(display);
|
||||||
|
free(registry);
|
||||||
|
|
||||||
if (idle_manager == NULL) {
|
if (idle_manager == NULL) {
|
||||||
fprintf(stderr, "display doesn't support idle protocol\n");
|
fprintf(stderr, "display doesn't support idle protocol\n");
|
||||||
|
|
|
@ -239,15 +239,21 @@ void new_input_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
|
struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
|
||||||
&rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
if (!keymap) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to create XKB keymap");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
wlr_keyboard_set_keymap(device->keyboard, keymap);
|
||||||
|
xkb_keymap_unref(keymap);
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_POINTER:;
|
case WLR_INPUT_DEVICE_POINTER:;
|
||||||
struct sample_cursor *cursor = calloc(1, sizeof(struct sample_cursor));
|
struct sample_cursor *cursor = calloc(1, sizeof(struct sample_cursor));
|
||||||
struct sample_pointer *pointer = calloc(1, sizeof(struct sample_pointer));
|
struct sample_pointer *pointer = calloc(1, sizeof(struct sample_pointer));
|
||||||
pointer->device = device;
|
pointer->device = device;
|
||||||
cursor->sample = sample;
|
cursor->sample = sample;
|
||||||
cursor->device = device;
|
cursor->device = device;
|
||||||
|
|
||||||
cursor->cursor = wlr_cursor_create();
|
cursor->cursor = wlr_cursor_create();
|
||||||
|
@ -324,6 +330,11 @@ int main(int argc, char *argv[]) {
|
||||||
cursor_destroy(cursor);
|
cursor_destroy(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct sample_pointer *pointer, *tmp_pointer;
|
||||||
|
wl_list_for_each_safe(pointer, tmp_pointer, &state.pointers, link) {
|
||||||
|
free(pointer);
|
||||||
|
}
|
||||||
|
|
||||||
wlr_xcursor_theme_destroy(theme);
|
wlr_xcursor_theme_destroy(theme);
|
||||||
wlr_output_layout_destroy(state.layout);
|
wlr_output_layout_destroy(state.layout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,8 +239,14 @@ void new_input_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
|
struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
|
||||||
&rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
if (!keymap) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to create XKB keymap");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
wlr_keyboard_set_keymap(device->keyboard, keymap);
|
||||||
|
xkb_keymap_unref(keymap);
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -285,6 +291,6 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
wlr_texture_destroy(state.cat_texture);
|
wlr_texture_destroy(state.cat_texture);
|
||||||
|
|
||||||
wlr_output_layout_destroy(state.layout);
|
|
||||||
wl_display_destroy(state.display);
|
wl_display_destroy(state.display);
|
||||||
|
wlr_output_layout_destroy(state.layout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,8 +304,14 @@ void new_input_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
|
struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
|
||||||
&rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
if (!keymap) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to create XKB keymap");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
wlr_keyboard_set_keymap(device->keyboard, keymap);
|
||||||
|
xkb_keymap_unref(keymap);
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -188,8 +188,14 @@ void new_input_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
|
struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
|
||||||
&rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
if (!keymap) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to create XKB keymap");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
wlr_keyboard_set_keymap(device->keyboard, keymap);
|
||||||
|
xkb_keymap_unref(keymap);
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -141,8 +141,14 @@ void new_input_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
|
struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
|
||||||
&rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
if (!keymap) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to create XKB keymap");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
wlr_keyboard_set_keymap(device->keyboard, keymap);
|
||||||
|
xkb_keymap_unref(keymap);
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -297,8 +297,14 @@ void new_input_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
|
struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
|
||||||
&rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
if (!keymap) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to create XKB keymap");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
wlr_keyboard_set_keymap(device->keyboard, keymap);
|
||||||
|
xkb_keymap_unref(keymap);
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_TABLET_PAD:;
|
case WLR_INPUT_DEVICE_TABLET_PAD:;
|
||||||
|
|
|
@ -210,8 +210,14 @@ void new_input_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
|
struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
|
||||||
&rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
if (!keymap) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to create XKB keymap");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
wlr_keyboard_set_keymap(device->keyboard, keymap);
|
||||||
|
xkb_keymap_unref(keymap);
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_TOUCH:;
|
case WLR_INPUT_DEVICE_TOUCH:;
|
||||||
|
|
|
@ -119,6 +119,7 @@ struct wlr_drm_connector {
|
||||||
struct wlr_output output;
|
struct wlr_output output;
|
||||||
|
|
||||||
enum wlr_drm_connector_state state;
|
enum wlr_drm_connector_state state;
|
||||||
|
struct wlr_output_mode *desired_mode;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
struct wlr_drm_crtc *crtc;
|
struct wlr_drm_crtc *crtc;
|
||||||
|
|
|
@ -93,8 +93,6 @@ struct wlr_drag_icon {
|
||||||
bool is_pointer;
|
bool is_pointer;
|
||||||
int32_t touch_id;
|
int32_t touch_id;
|
||||||
|
|
||||||
int32_t sx, sy;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal map;
|
struct wl_signal map;
|
||||||
struct wl_signal unmap;
|
struct wl_signal unmap;
|
||||||
|
|
|
@ -35,8 +35,13 @@ typedef void (*wlr_log_func_t)(enum wlr_log_importance importance,
|
||||||
|
|
||||||
// Will log all messages less than or equal to `verbosity`
|
// Will log all messages less than or equal to `verbosity`
|
||||||
// If `callback` is NULL, wlr will use its default logger.
|
// If `callback` is NULL, wlr will use its default logger.
|
||||||
|
// The function can be called multiple times to update the verbosity or
|
||||||
|
// callback function.
|
||||||
void wlr_log_init(enum wlr_log_importance verbosity, wlr_log_func_t callback);
|
void wlr_log_init(enum wlr_log_importance verbosity, wlr_log_func_t callback);
|
||||||
|
|
||||||
|
// Returns the log verbosity provided to wlr_log_init
|
||||||
|
enum wlr_log_importance wlr_log_get_verbosity(void);
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define _WLR_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end)))
|
#define _WLR_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end)))
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -116,6 +116,7 @@ struct wlr_xwayland_surface {
|
||||||
char *title;
|
char *title;
|
||||||
char *class;
|
char *class;
|
||||||
char *instance;
|
char *instance;
|
||||||
|
char *role;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
bool has_utf8_title;
|
bool has_utf8_title;
|
||||||
|
|
||||||
|
@ -157,6 +158,7 @@ struct wlr_xwayland_surface {
|
||||||
struct wl_signal unmap;
|
struct wl_signal unmap;
|
||||||
struct wl_signal set_title;
|
struct wl_signal set_title;
|
||||||
struct wl_signal set_class;
|
struct wl_signal set_class;
|
||||||
|
struct wl_signal set_role;
|
||||||
struct wl_signal set_parent;
|
struct wl_signal set_parent;
|
||||||
struct wl_signal set_pid;
|
struct wl_signal set_pid;
|
||||||
struct wl_signal set_window_type;
|
struct wl_signal set_window_type;
|
||||||
|
|
|
@ -25,6 +25,7 @@ enum atom_name {
|
||||||
WM_HINTS,
|
WM_HINTS,
|
||||||
WM_NORMAL_HINTS,
|
WM_NORMAL_HINTS,
|
||||||
WM_SIZE_HINTS,
|
WM_SIZE_HINTS,
|
||||||
|
WM_WINDOW_ROLE,
|
||||||
MOTIF_WM_HINTS,
|
MOTIF_WM_HINTS,
|
||||||
UTF8_STRING,
|
UTF8_STRING,
|
||||||
WM_S0,
|
WM_S0,
|
||||||
|
|
|
@ -26,7 +26,10 @@ static void usage(const char *name, int ret) {
|
||||||
" See `rootston.ini.example` for config\n"
|
" See `rootston.ini.example` for config\n"
|
||||||
" file documentation.\n"
|
" file documentation.\n"
|
||||||
" -E <COMMAND> Command that will be ran at startup.\n"
|
" -E <COMMAND> Command that will be ran at startup.\n"
|
||||||
" -D Enable damage tracking debugging.\n",
|
" -D Enable damage tracking debugging.\n"
|
||||||
|
" -l <LEVEL> Set log verbosity, where,\n"
|
||||||
|
" 0:SILENT, 1:ERROR, 2:INFO, 3+:DEBUG\n"
|
||||||
|
" (default: DEBUG)\n",
|
||||||
name);
|
name);
|
||||||
|
|
||||||
exit(ret);
|
exit(ret);
|
||||||
|
@ -455,7 +458,8 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) {
|
||||||
wl_list_init(&config->bindings);
|
wl_list_init(&config->bindings);
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt(argc, argv, "C:E:hD")) != -1) {
|
unsigned int log_verbosity = WLR_DEBUG;
|
||||||
|
while ((c = getopt(argc, argv, "C:E:hDl:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'C':
|
case 'C':
|
||||||
config->config_path = strdup(optarg);
|
config->config_path = strdup(optarg);
|
||||||
|
@ -466,11 +470,18 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) {
|
||||||
case 'D':
|
case 'D':
|
||||||
config->debug_damage_tracking = true;
|
config->debug_damage_tracking = true;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
log_verbosity = strtoul(optarg, NULL, 10);
|
||||||
|
if (log_verbosity >= WLR_LOG_IMPORTANCE_LAST) {
|
||||||
|
log_verbosity = WLR_LOG_IMPORTANCE_LAST - 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
usage(argv[0], c != 'h');
|
usage(argv[0], c != 'h');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
wlr_log_init(log_verbosity, NULL);
|
||||||
|
|
||||||
if (!config->config_path) {
|
if (!config->config_path) {
|
||||||
// get the config path from the current directory
|
// get the config path from the current directory
|
||||||
|
|
|
@ -502,16 +502,16 @@ void roots_drag_icon_update_position(struct roots_drag_icon *icon) {
|
||||||
struct roots_seat *seat = icon->seat;
|
struct roots_seat *seat = icon->seat;
|
||||||
struct wlr_cursor *cursor = seat->cursor->cursor;
|
struct wlr_cursor *cursor = seat->cursor->cursor;
|
||||||
if (wlr_icon->is_pointer) {
|
if (wlr_icon->is_pointer) {
|
||||||
icon->x = cursor->x + wlr_icon->sx;
|
icon->x = cursor->x;
|
||||||
icon->y = cursor->y + wlr_icon->sy;
|
icon->y = cursor->y;
|
||||||
} else {
|
} else {
|
||||||
struct wlr_touch_point *point =
|
struct wlr_touch_point *point =
|
||||||
wlr_seat_touch_get_point(seat->seat, wlr_icon->touch_id);
|
wlr_seat_touch_get_point(seat->seat, wlr_icon->touch_id);
|
||||||
if (point == NULL) {
|
if (point == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
icon->x = seat->touch_x + wlr_icon->sx;
|
icon->x = seat->touch_x;
|
||||||
icon->y = seat->touch_y + wlr_icon->sy;
|
icon->y = seat->touch_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
roots_drag_icon_damage_whole(icon);
|
roots_drag_icon_damage_whole(icon);
|
||||||
|
|
|
@ -345,9 +345,6 @@ static void drag_icon_surface_role_commit(struct wlr_surface *surface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
icon->sx += icon->surface->current.dx;
|
|
||||||
icon->sy += icon->surface->current.dy;
|
|
||||||
|
|
||||||
drag_icon_set_mapped(icon, wlr_surface_has_buffer(surface));
|
drag_icon_set_mapped(icon, wlr_surface_has_buffer(surface));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ static void get_tablet_seat(struct wl_client *wl_client, struct wl_resource *res
|
||||||
|
|
||||||
struct wlr_tablet_seat_client_v2 *seat_client =
|
struct wlr_tablet_seat_client_v2 *seat_client =
|
||||||
calloc(1, sizeof(struct wlr_tablet_seat_client_v2));
|
calloc(1, sizeof(struct wlr_tablet_seat_client_v2));
|
||||||
if (tablet_seat == NULL) {
|
if (seat_client == NULL) {
|
||||||
wl_client_post_no_memory(wl_client);
|
wl_client_post_no_memory(wl_client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -283,6 +283,7 @@ void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager) {
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_signal_emit_safe(&manager->events.destroy, manager);
|
wlr_signal_emit_safe(&manager->events.destroy, manager);
|
||||||
|
wl_list_remove(&manager->display_destroy.link);
|
||||||
wl_global_destroy(manager->wl_global);
|
wl_global_destroy(manager->wl_global);
|
||||||
free(manager);
|
free(manager);
|
||||||
}
|
}
|
||||||
|
@ -294,13 +295,6 @@ struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_signal_init(&tablet->events.destroy);
|
|
||||||
wl_list_init(&tablet->clients);
|
|
||||||
wl_list_init(&tablet->seats);
|
|
||||||
|
|
||||||
tablet->display_destroy.notify = handle_display_destroy;
|
|
||||||
wl_display_add_destroy_listener(display, &tablet->display_destroy);
|
|
||||||
|
|
||||||
tablet->wl_global = wl_global_create(display,
|
tablet->wl_global = wl_global_create(display,
|
||||||
&zwp_tablet_manager_v2_interface, TABLET_MANAGER_VERSION,
|
&zwp_tablet_manager_v2_interface, TABLET_MANAGER_VERSION,
|
||||||
tablet, tablet_v2_bind);
|
tablet, tablet_v2_bind);
|
||||||
|
@ -309,5 +303,12 @@ struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wl_signal_init(&tablet->events.destroy);
|
||||||
|
wl_list_init(&tablet->clients);
|
||||||
|
wl_list_init(&tablet->seats);
|
||||||
|
|
||||||
|
tablet->display_destroy.notify = handle_display_destroy;
|
||||||
|
wl_display_add_destroy_listener(display, &tablet->display_destroy);
|
||||||
|
|
||||||
return tablet;
|
return tablet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -768,7 +768,8 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(WLR_DEBUG, "Falling back to software cursor");
|
wlr_log(WLR_DEBUG, "Falling back to software cursor on output '%s'",
|
||||||
|
cursor->output->name);
|
||||||
output_cursor_damage_whole(cursor);
|
output_cursor_damage_whole(cursor);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,3 +85,7 @@ const char *_wlr_strip_path(const char *filepath) {
|
||||||
}
|
}
|
||||||
return filepath;
|
return filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum wlr_log_importance wlr_log_get_verbosity(void) {
|
||||||
|
return log_importance;
|
||||||
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ static int fill_arg(char ***argv, const char *fmt, ...) {
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Noreturn
|
||||||
static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) {
|
static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) {
|
||||||
if (unset_cloexec(wlr_xwayland->x_fd[0]) ||
|
if (unset_cloexec(wlr_xwayland->x_fd[0]) ||
|
||||||
unset_cloexec(wlr_xwayland->x_fd[1]) ||
|
unset_cloexec(wlr_xwayland->x_fd[1]) ||
|
||||||
|
@ -123,9 +124,26 @@ static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) {
|
||||||
wlr_xwayland->wl_fd[1], wlr_xwayland->display, wlr_xwayland->x_fd[0],
|
wlr_xwayland->wl_fd[1], wlr_xwayland->display, wlr_xwayland->x_fd[0],
|
||||||
wlr_xwayland->x_fd[1], wlr_xwayland->wm_fd[1]);
|
wlr_xwayland->x_fd[1], wlr_xwayland->wm_fd[1]);
|
||||||
|
|
||||||
// TODO: close stdout/err depending on log level
|
// Closes stdout/stderr depending on log verbosity
|
||||||
|
enum wlr_log_importance verbosity = wlr_log_get_verbosity();
|
||||||
|
int devnull = open("/dev/null", O_WRONLY | O_CREAT, 0666);
|
||||||
|
if (devnull < 0) {
|
||||||
|
wlr_log_errno(WLR_ERROR, "XWayland: failed to open /dev/null");
|
||||||
|
_exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
if (verbosity < WLR_INFO) {
|
||||||
|
dup2(devnull, STDOUT_FILENO);
|
||||||
|
}
|
||||||
|
if (verbosity < WLR_ERROR) {
|
||||||
|
dup2(devnull, STDERR_FILENO);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This returns if and only if the call fails
|
||||||
execvp("Xwayland", argv);
|
execvp("Xwayland", argv);
|
||||||
|
|
||||||
|
wlr_log_errno(WLR_ERROR, "failed to exec Xwayland");
|
||||||
|
close(devnull);
|
||||||
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xwayland_finish_server(struct wlr_xwayland *wlr_xwayland) {
|
static void xwayland_finish_server(struct wlr_xwayland *wlr_xwayland) {
|
||||||
|
@ -346,8 +364,6 @@ static bool xwayland_start_server(struct wlr_xwayland *wlr_xwayland) {
|
||||||
sigprocmask(SIG_BLOCK, &sigset, NULL);
|
sigprocmask(SIG_BLOCK, &sigset, NULL);
|
||||||
if ((pid = fork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
exec_xwayland(wlr_xwayland);
|
exec_xwayland(wlr_xwayland);
|
||||||
wlr_log_errno(WLR_ERROR, "failed to exec Xwayland");
|
|
||||||
_exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
wlr_log_errno(WLR_ERROR, "second fork failed");
|
wlr_log_errno(WLR_ERROR, "second fork failed");
|
||||||
|
|
|
@ -24,6 +24,7 @@ const char *atom_map[ATOM_LAST] = {
|
||||||
"WM_HINTS",
|
"WM_HINTS",
|
||||||
"WM_NORMAL_HINTS",
|
"WM_NORMAL_HINTS",
|
||||||
"WM_SIZE_HINTS",
|
"WM_SIZE_HINTS",
|
||||||
|
"WM_WINDOW_ROLE",
|
||||||
"_MOTIF_WM_HINTS",
|
"_MOTIF_WM_HINTS",
|
||||||
"UTF8_STRING",
|
"UTF8_STRING",
|
||||||
"WM_S0",
|
"WM_S0",
|
||||||
|
@ -152,6 +153,7 @@ static struct wlr_xwayland_surface *xwayland_surface_create(
|
||||||
wl_signal_init(&surface->events.map);
|
wl_signal_init(&surface->events.map);
|
||||||
wl_signal_init(&surface->events.unmap);
|
wl_signal_init(&surface->events.unmap);
|
||||||
wl_signal_init(&surface->events.set_class);
|
wl_signal_init(&surface->events.set_class);
|
||||||
|
wl_signal_init(&surface->events.set_role);
|
||||||
wl_signal_init(&surface->events.set_title);
|
wl_signal_init(&surface->events.set_title);
|
||||||
wl_signal_init(&surface->events.set_parent);
|
wl_signal_init(&surface->events.set_parent);
|
||||||
wl_signal_init(&surface->events.set_pid);
|
wl_signal_init(&surface->events.set_pid);
|
||||||
|
@ -327,6 +329,7 @@ static void xwayland_surface_destroy(
|
||||||
free(xsurface->title);
|
free(xsurface->title);
|
||||||
free(xsurface->class);
|
free(xsurface->class);
|
||||||
free(xsurface->instance);
|
free(xsurface->instance);
|
||||||
|
free(xsurface->role);
|
||||||
free(xsurface->window_type);
|
free(xsurface->window_type);
|
||||||
free(xsurface->protocols);
|
free(xsurface->protocols);
|
||||||
free(xsurface->hints);
|
free(xsurface->hints);
|
||||||
|
@ -365,6 +368,28 @@ static void read_surface_class(struct wlr_xwm *xwm,
|
||||||
wlr_signal_emit_safe(&surface->events.set_class, surface);
|
wlr_signal_emit_safe(&surface->events.set_class, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void read_surface_role(struct wlr_xwm *xwm,
|
||||||
|
struct wlr_xwayland_surface *xsurface,
|
||||||
|
xcb_get_property_reply_t *reply) {
|
||||||
|
if (reply->type != XCB_ATOM_STRING &&
|
||||||
|
reply->type != xwm->atoms[UTF8_STRING]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t len = xcb_get_property_value_length(reply);
|
||||||
|
char *role = xcb_get_property_value(reply);
|
||||||
|
|
||||||
|
free(xsurface->role);
|
||||||
|
if (len > 0) {
|
||||||
|
xsurface->role = strndup(role, len);
|
||||||
|
} else {
|
||||||
|
xsurface->role = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_log(WLR_DEBUG, "XCB_ATOM_WM_WINDOW_ROLE: %s", xsurface->role);
|
||||||
|
wlr_signal_emit_safe(&xsurface->events.set_role, xsurface);
|
||||||
|
}
|
||||||
|
|
||||||
static void read_surface_title(struct wlr_xwm *xwm,
|
static void read_surface_title(struct wlr_xwm *xwm,
|
||||||
struct wlr_xwayland_surface *xsurface,
|
struct wlr_xwayland_surface *xsurface,
|
||||||
xcb_get_property_reply_t *reply) {
|
xcb_get_property_reply_t *reply) {
|
||||||
|
@ -638,6 +663,8 @@ static void read_surface_property(struct wlr_xwm *xwm,
|
||||||
read_surface_normal_hints(xwm, xsurface, reply);
|
read_surface_normal_hints(xwm, xsurface, reply);
|
||||||
} else if (property == xwm->atoms[MOTIF_WM_HINTS]) {
|
} else if (property == xwm->atoms[MOTIF_WM_HINTS]) {
|
||||||
read_surface_motif_hints(xwm, xsurface, reply);
|
read_surface_motif_hints(xwm, xsurface, reply);
|
||||||
|
} else if (property == xwm->atoms[WM_WINDOW_ROLE]) {
|
||||||
|
read_surface_role(xwm, xsurface, reply);
|
||||||
} else {
|
} else {
|
||||||
char *prop_name = xwm_get_atom_name(xwm, property);
|
char *prop_name = xwm_get_atom_name(xwm, property);
|
||||||
wlr_log(WLR_DEBUG, "unhandled X11 property %u (%s) for window %u",
|
wlr_log(WLR_DEBUG, "unhandled X11 property %u (%s) for window %u",
|
||||||
|
|
Loading…
Reference in a new issue