mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
output: use output-local coordinates (issue #5)
This commit is contained in:
parent
58fdf9776f
commit
18b6fd7e75
1 changed files with 30 additions and 5 deletions
35
src/output.c
35
src/output.c
|
|
@ -6,6 +6,8 @@
|
||||||
#include "layers.h"
|
#include "layers.h"
|
||||||
|
|
||||||
struct draw_data {
|
struct draw_data {
|
||||||
|
struct wlr_output *output;
|
||||||
|
struct wlr_output_layout *output_layout;
|
||||||
struct wlr_renderer *renderer;
|
struct wlr_renderer *renderer;
|
||||||
float *transform_matrix;
|
float *transform_matrix;
|
||||||
float *rgba;
|
float *rgba;
|
||||||
|
|
@ -14,6 +16,10 @@ struct draw_data {
|
||||||
static void
|
static void
|
||||||
draw_rect(struct draw_data *d, struct wlr_box box)
|
draw_rect(struct draw_data *d, struct wlr_box box)
|
||||||
{
|
{
|
||||||
|
double ox = 0, oy = 0;
|
||||||
|
wlr_output_layout_output_coords(d->output_layout, d->output, &ox, &oy);
|
||||||
|
box.x += ox;
|
||||||
|
box.y += oy;
|
||||||
wlr_render_rect(d->renderer, &box, d->rgba, d->transform_matrix);
|
wlr_render_rect(d->renderer, &box, d->rgba, d->transform_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,6 +57,8 @@ shrink(struct wlr_box *box, int size)
|
||||||
static void
|
static void
|
||||||
render_cycle_box(struct output *output)
|
render_cycle_box(struct output *output)
|
||||||
{
|
{
|
||||||
|
struct wlr_output_layout *layout = output->server->output_layout;
|
||||||
|
double ox = 0, oy = 0;
|
||||||
struct wlr_box box;
|
struct wlr_box box;
|
||||||
if (!output->server->cycle_view)
|
if (!output->server->cycle_view)
|
||||||
return;
|
return;
|
||||||
|
|
@ -61,8 +69,9 @@ render_cycle_box(struct output *output)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
render_it:
|
render_it:
|
||||||
box.x = view->x - view->margin.left;
|
wlr_output_layout_output_coords(layout, output->wlr_output, &ox, &oy);
|
||||||
box.y = view->y - view->margin.top;
|
box.x = view->x - view->margin.left + ox;
|
||||||
|
box.y = view->y - view->margin.top + oy;
|
||||||
box.width = view->w + view->margin.left + view->margin.right;
|
box.width = view->w + view->margin.left + view->margin.right;
|
||||||
box.height = view->h + view->margin.top + view->margin.bottom;
|
box.height = view->h + view->margin.top + view->margin.bottom;
|
||||||
struct draw_data dd = {
|
struct draw_data dd = {
|
||||||
|
|
@ -91,14 +100,23 @@ render_rootmenu(struct output *output)
|
||||||
};
|
};
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
|
|
||||||
|
struct wlr_output_layout *output_layout = server->output_layout;
|
||||||
|
double ox = 0, oy = 0;
|
||||||
|
wlr_output_layout_output_coords(output_layout, output->wlr_output, &ox, &oy);
|
||||||
ddata.rgba = (float[4]){ 0.9, 0.3, 0.3, 0.5 };
|
ddata.rgba = (float[4]){ 0.9, 0.3, 0.3, 0.5 };
|
||||||
struct menuitem *menuitem;
|
struct menuitem *menuitem;
|
||||||
wl_list_for_each (menuitem, &server->rootmenu->menuitems, link) {
|
wl_list_for_each (menuitem, &server->rootmenu->menuitems, link) {
|
||||||
struct wlr_texture *t;
|
struct wlr_texture *t;
|
||||||
t = menuitem->selected ? menuitem->active_texture :
|
t = menuitem->selected ? menuitem->active_texture :
|
||||||
menuitem->inactive_texture;
|
menuitem->inactive_texture;
|
||||||
wlr_matrix_project_box(matrix, &menuitem->geo_box,
|
struct wlr_box box = {
|
||||||
WL_OUTPUT_TRANSFORM_NORMAL, 0, ddata.transform_matrix);
|
.x = menuitem->geo_box.x + ox,
|
||||||
|
.y = menuitem->geo_box.y + oy,
|
||||||
|
.width = menuitem->geo_box.width,
|
||||||
|
.height = menuitem->geo_box.height,
|
||||||
|
};
|
||||||
|
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
|
||||||
|
0, ddata.transform_matrix);
|
||||||
wlr_render_texture_with_matrix(ddata.renderer, t, matrix, 1);
|
wlr_render_texture_with_matrix(ddata.renderer, t, matrix, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,6 +146,11 @@ render_icon(struct draw_data *d, struct wlr_box box,
|
||||||
button.height = box.height;
|
button.height = box.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double ox = 0, oy = 0;
|
||||||
|
wlr_output_layout_output_coords(d->output_layout, d->output, &ox, &oy);
|
||||||
|
button.x += ox;
|
||||||
|
button.y += oy;
|
||||||
|
|
||||||
wlr_matrix_project_box(matrix, &button, WL_OUTPUT_TRANSFORM_NORMAL, 0,
|
wlr_matrix_project_box(matrix, &button, WL_OUTPUT_TRANSFORM_NORMAL, 0,
|
||||||
d->transform_matrix);
|
d->transform_matrix);
|
||||||
wlr_render_texture_with_matrix(d->renderer, texture, matrix, 1);
|
wlr_render_texture_with_matrix(d->renderer, texture, matrix, 1);
|
||||||
|
|
@ -147,6 +170,8 @@ render_decorations(struct wlr_output *output, struct view *view)
|
||||||
if (!view->server_side_deco)
|
if (!view->server_side_deco)
|
||||||
return;
|
return;
|
||||||
struct draw_data ddata = {
|
struct draw_data ddata = {
|
||||||
|
.output = output,
|
||||||
|
.output_layout = view->server->output_layout,
|
||||||
.renderer = view->server->renderer,
|
.renderer = view->server->renderer,
|
||||||
.transform_matrix = output->transform_matrix,
|
.transform_matrix = output->transform_matrix,
|
||||||
};
|
};
|
||||||
|
|
@ -172,7 +197,7 @@ render_decorations(struct wlr_output *output, struct view *view)
|
||||||
|
|
||||||
struct wlr_box box = deco_box(view, deco_part);
|
struct wlr_box box = deco_box(view, deco_part);
|
||||||
if (isbutton(deco_part) &&
|
if (isbutton(deco_part) &&
|
||||||
wlr_box_contains_point(&box, cur->x, cur->y)) {
|
wlr_box_contains_point(&box, cur->x, cur->y)) {
|
||||||
ddata.rgba = (float[4]){ 0.5, 0.5, 0.5, 0.5 };
|
ddata.rgba = (float[4]){ 0.5, 0.5, 0.5, 0.5 };
|
||||||
draw_rect(&ddata, deco_box(view, deco_part));
|
draw_rect(&ddata, deco_box(view, deco_part));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue