Cage: implement output transform

This commit adds the command line switch -r, which rotates the output 90
degrees clockwise and can be specified up to three times.
This commit is contained in:
Tristan Daniel 2019-04-14 01:50:12 +02:00 committed by Jente Hidskes
parent 69872baead
commit 9e6a5ad44f
4 changed files with 20 additions and 6 deletions

11
cage.c
View file

@ -87,6 +87,7 @@ usage(FILE *file, const char *cage)
fprintf(file, "Usage: %s [OPTIONS] [--] APPLICATION\n"
"\n"
" -d\t Don't draw client side decorations, when possible\n"
" -r\t Rotate the output 90 degrees clockwise, specify up to three times\n"
#ifdef DEBUG
" -D\t Turn on damage tracking debugging\n"
#endif
@ -101,14 +102,20 @@ parse_args(struct cg_server *server, int argc, char *argv[])
{
int c;
#ifdef DEBUG
while ((c = getopt(argc, argv, "dDh")) != -1) {
while ((c = getopt(argc, argv, "drDh")) != -1) {
#else
while ((c = getopt(argc, argv, "dh")) != -1) {
while ((c = getopt(argc, argv, "drh")) != -1) {
#endif
switch (c) {
case 'd':
server->xdg_decoration = true;
break;
case 'r':
server->output_transform++;
if (server->output_transform > WL_OUTPUT_TRANSFORM_270) {
server->output_transform = WL_OUTPUT_TRANSFORM_NORMAL;
}
break;
#ifdef DEBUG
case 'D':
server->debug_damage_tracking = true;

View file

@ -211,10 +211,7 @@ handle_output_damage_frame(struct wl_listener *listener, void *data)
goto damage_finish;
}
int output_width, output_height;
wlr_output_transformed_resolution(output->wlr_output, &output_width, &output_height);
wlr_renderer_begin(renderer, output_width, output_height);
wlr_renderer_begin(renderer, output->wlr_output->width, output->wlr_output->height);
if (!pixman_region32_not_empty(&damage)) {
wlr_log(WLR_DEBUG, "Output isn't damaged but needs a buffer swap");
@ -258,6 +255,9 @@ handle_output_damage_frame(struct wl_listener *listener, void *data)
wlr_renderer_scissor(renderer, NULL);
wlr_renderer_end(renderer);
int output_width, output_height;
wlr_output_transformed_resolution(output->wlr_output, &output_width, &output_height);
#ifdef DEBUG
if (output->server->debug_damage_tracking) {
pixman_region32_union_rect(&damage, &damage, 0, 0, output_width, output_height);
@ -366,6 +366,8 @@ handle_new_output(struct wl_listener *listener, void *data)
server->output->damage_destroy.notify = handle_output_damage_destroy;
wl_signal_add(&server->output->damage->events.destroy, &server->output->damage_destroy);
wlr_output_set_transform(wlr_output, server->output_transform);
wlr_output_layout_add_auto(server->output_layout, wlr_output);
/* Disconnect the signal now, because we only use one static output. */

4
seat.c
View file

@ -157,6 +157,8 @@ handle_new_touch(struct cg_seat *seat, struct wlr_input_device *device)
wl_list_insert(&seat->touch, &touch->link);
touch->destroy.notify = handle_touch_destroy;
wl_signal_add(&touch->device->events.destroy, &touch->destroy);
wlr_cursor_map_input_to_output(seat->cursor, device, seat->server->output->wlr_output);
}
static void
@ -189,6 +191,8 @@ handle_new_pointer(struct cg_seat *seat, struct wlr_input_device *device)
wl_list_insert(&seat->pointers, &pointer->link);
pointer->destroy.notify = handle_pointer_destroy;
wl_signal_add(&device->events.destroy, &pointer->destroy);
wlr_cursor_map_input_to_output(seat->cursor, device, seat->server->output->wlr_output);
}
static void

View file

@ -39,6 +39,7 @@ struct cg_server {
#endif
bool xdg_decoration;
enum wl_output_transform output_transform;
#ifdef DEBUG
bool debug_damage_tracking;
#endif