Compare commits

...

6 Commits

Author SHA1 Message Date
Peter van der Perk
538667eca2 Merge branch 'new_buttons_no_borders' into 'main'
Draft: Modify Weston server decoration new buttons & omitting borders

See merge request wayland/weston!1154
2024-06-26 11:40:46 +00:00
Daniel Stone
de669aeb60 doc: Tie Sphinx -W to Werror configuration
Only pass -W (warnings are fatal) to Sphinx if we've set Werror in
Meson.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Closes: wayland/weston#917
2024-06-25 17:45:37 +00:00
Michael Olbrich
f843ba34d1 drm-backend: limit reset/restart to output of a failed commit
When a commit fails, then only the outputs that where part of this commit should
be reset or restarted.

Otherwise an unrelated output that has another successful pending commit may be
restarted incorrectly. Then the output is in an inconsistent state and will
trigger an assertion:

weston: ../libweston/backend-drm/state-propose.c:627: drm_output_propose_state: Assertion `!output->state_last' failed.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-06-21 21:39:32 +02:00
Peter van der Perk
65a6db5c5f Weston server decoration handle borderless windows resizing
Xwayland borderless window needs seperate handling

Signed-off-by: Peter van der Perk <info@petervanderperk.nl>
2023-02-10 21:29:17 +01:00
Peter van der Perk
d633b3e252 Weston server decoration redesign buttons and add restore from maximized icon
Signed-off-by: Peter van der Perk <info@petervanderperk.nl>
2023-02-10 21:29:17 +01:00
Peter van der Perk
522006d104 Weston server decoration omit window borders
Signed-off-by: Peter van der Perk <info@petervanderperk.nl>
2023-02-10 21:29:08 +01:00
11 changed files with 102 additions and 43 deletions

View File

@ -1650,18 +1650,12 @@ window_destroy(struct window *window)
}
static struct widget *
widget_find_widget(struct widget *widget, int32_t x, int32_t y)
widget_find_widget(struct widget *widget, int32_t x, int32_t y, bool get_parent)
{
struct widget *child, *target;
int alloc_x, alloc_y, width, height;
double scale;
wl_list_for_each(child, &widget->child_list, link) {
target = widget_find_widget(child, x, y);
if (target)
return target;
}
alloc_x = widget->allocation.x;
alloc_y = widget->allocation.y;
width = widget->allocation.width;
@ -1678,6 +1672,15 @@ widget_find_widget(struct widget *widget, int32_t x, int32_t y)
height = widget->viewport_dest_height;
}
wl_list_for_each(child, &widget->child_list, link) {
target = widget_find_widget(child, x, y, get_parent);
if (target && get_parent) {
return widget;
} else if(target) {
return target;
}
}
if (alloc_x <= x && x < alloc_x + width &&
alloc_y <= y && y < alloc_y + height) {
return widget;
@ -1687,13 +1690,13 @@ widget_find_widget(struct widget *widget, int32_t x, int32_t y)
}
static struct widget *
window_find_widget(struct window *window, int32_t x, int32_t y)
window_find_widget(struct window *window, int32_t x, int32_t y, bool get_parent)
{
struct surface *surface;
struct widget *widget;
wl_list_for_each(surface, &window->subsurface_list, link) {
widget = widget_find_widget(surface->widget, x, y);
widget = widget_find_widget(surface->widget, x, y, get_parent);
if (widget)
return widget;
}
@ -2803,7 +2806,7 @@ input_ungrab(struct input *input)
input->grab = NULL;
if (input->pointer_focus) {
widget = window_find_widget(input->pointer_focus,
input->sx, input->sy);
input->sx, input->sy, false);
input_set_focus_widget(input, widget, input->sx, input->sy);
}
}
@ -2879,8 +2882,19 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
input->sx = sx;
input->sy = sy;
widget = window_find_widget(window, sx, sy);
widget = window_find_widget(window, sx, sy, false);
input_set_focus_widget(input, widget, sx, sy);
widget = window_find_widget(window, sx, sy, true);
if (widget) {
if (widget->enter_handler) {
if(widget->enter_handler(input->focus_widget,
input, sx, sy,
widget->user_data) != CURSOR_LEFT_PTR) {
input_set_focus_widget(input, widget, sx, sy);
}
}
}
}
static void
@ -2900,7 +2914,7 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer,
struct input *input = data;
struct window *window = input->pointer_focus;
struct widget *widget;
int cursor;
int cursor, parent_cursor;
float sx = wl_fixed_to_double(sx_w);
float sy = wl_fixed_to_double(sy_w);
@ -2922,7 +2936,7 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer,
return;
if (!(input->grab && input->grab_button)) {
widget = window_find_widget(window, sx, sy);
widget = window_find_widget(window, sx, sy, false);
input_set_focus_widget(input, widget, sx, sy);
}
@ -2940,6 +2954,20 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer,
} else
cursor = CURSOR_LEFT_PTR;
widget = window_find_widget(window, sx, sy, true);
if (widget) {
if (widget->motion_handler) {
parent_cursor = widget->motion_handler(input->focus_widget,
input, time, sx, sy,
widget->user_data);
if(parent_cursor != CURSOR_LEFT_PTR) {
input_set_focus_widget(input, widget, sx, sy);
cursor = parent_cursor;
}
}
}
input_set_pointer_image(input, cursor);
}
@ -3422,7 +3450,7 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
else
widget = window_find_widget(input->touch_focus,
wl_fixed_to_double(x_w),
wl_fixed_to_double(y_w));
wl_fixed_to_double(y_w), false);
if (widget) {
struct touch_point *tp = xmalloc(sizeof *tp);
if (tp) {

View File

@ -20,6 +20,7 @@ install_data(
'sign_close.png',
'sign_maximize.png',
'sign_minimize.png',
'sign_restorenormal.png',
'terminal.png',
'tiling.png',
'wayland.png',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 B

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 B

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

After

Width:  |  Height:  |  Size: 145 B

BIN
data/sign_restorenormal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -55,6 +55,7 @@ script_data.set('DOCTREES_DIR', meson.current_build_dir() + '/doctrees')
script_data.set('DOXYGEN_CONF', meson.current_build_dir() + '/doxygen.ini')
script_data.set('DOXYGEN_CMD', doxygen.full_path())
script_data.set('MESON_WERROR', get_option('werror') == true ? 'YES' : 'NO')
script_data.set('SPHINX_CMD', sphinx.full_path())
script_doxy_sphinx = configure_file(
input: 'run_doxygen_sphinx.sh.in',

View File

@ -1,2 +1,9 @@
#!/bin/sh
@DOXYGEN_CMD@ @DOXYGEN_CONF@ && @SPHINX_CMD@ -E -W -q -j auto -d @DOCTREES_DIR@ @SRCDIR@ @OUTDIR@
if [ "@MESON_WERROR@" = "YES" ]; then
SPHINX_WERROR="-W"
else
SPHINX_WERROR=""
fi
@DOXYGEN_CMD@ @DOXYGEN_CONF@ && @SPHINX_CMD@ $SPHINX_WERROR -E -q -j auto -d @DOCTREES_DIR@ @SRCDIR@ @OUTDIR@

View File

@ -946,7 +946,7 @@ drm_repaint_flush_device(struct drm_device *device)
{
struct drm_backend *b = device->backend;
struct drm_pending_state *pending_state;
struct weston_output *base;
struct drm_output_state *output_state;
int ret;
pending_state = device->repaint_data;
@ -964,15 +964,13 @@ drm_repaint_flush_device(struct drm_device *device)
if (ret == 0)
return;
wl_list_for_each(base, &b->compositor->output_list, link) {
struct drm_output *tmp = to_drm_output(base);
if (!tmp || tmp->device != device)
continue;
wl_list_for_each(output_state, &pending_state->output_list, link) {
struct drm_output *tmp = output_state->output;
if (ret == -EBUSY)
weston_output_schedule_repaint_restart(base);
weston_output_schedule_repaint_restart(&tmp->base);
else
weston_output_schedule_repaint_reset(base);
weston_output_schedule_repaint_reset(&tmp->base);
}
}

View File

@ -431,8 +431,8 @@ theme_create(void)
t = xzalloc(sizeof *t);
t->margin = 32;
t->width = 6;
t->titlebar_height = 27;
t->width = 0;
t->titlebar_height = 28;
t->frame_radius = 3;
t->shadow = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128);
cr = cairo_create(t->shadow);

View File

@ -47,6 +47,7 @@ struct frame_button {
struct wl_list link; /* buttons_list */
cairo_surface_t *icon;
cairo_surface_t *icon_restore;
enum frame_button_flags flags;
int hover_count;
int press_count;
@ -110,6 +111,7 @@ struct frame {
static struct frame_button *
frame_button_create_from_surface(struct frame *frame, cairo_surface_t *icon,
cairo_surface_t *icon_maximized,
enum frame_status status_effect,
enum frame_button_flags flags)
{
@ -120,6 +122,7 @@ frame_button_create_from_surface(struct frame *frame, cairo_surface_t *icon,
return NULL;
button->icon = icon;
button->icon_restore = icon_maximized;
button->frame = frame;
button->flags = flags;
button->status_effect = status_effect;
@ -131,18 +134,26 @@ frame_button_create_from_surface(struct frame *frame, cairo_surface_t *icon,
static struct frame_button *
frame_button_create(struct frame *frame, const char *icon_name,
const char *icon_maximized_name,
enum frame_status status_effect,
enum frame_button_flags flags)
{
struct frame_button *button;
cairo_surface_t *icon;
cairo_surface_t *icon_maximized = NULL;
icon = cairo_image_surface_create_from_png(icon_name);
if (cairo_surface_status(icon) != CAIRO_STATUS_SUCCESS)
goto error;
button = frame_button_create_from_surface(frame, icon, status_effect,
flags);
if (icon_maximized_name != NULL) {
icon_maximized = cairo_image_surface_create_from_png(icon_maximized_name);
if (cairo_surface_status(icon) != CAIRO_STATUS_SUCCESS)
goto error;
}
button = frame_button_create_from_surface(frame, icon, icon_maximized,
status_effect, flags);
if (!button)
goto error;
@ -209,7 +220,7 @@ frame_button_cancel(struct frame_button *button)
}
static void
frame_button_repaint(struct frame_button *button, cairo_t *cr)
frame_button_repaint(struct frame_button *button, cairo_t *cr, uint32_t flags)
{
int x, y;
@ -224,27 +235,36 @@ frame_button_repaint(struct frame_button *button, cairo_t *cr)
cairo_save(cr);
if (button->flags & FRAME_BUTTON_DECORATED) {
cairo_set_line_width(cr, 1);
cairo_set_line_width(cr, 0);
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
cairo_rectangle(cr, x, y, 25, 16);
cairo_rectangle(cr, x, y, 42, 28);
cairo_stroke_preserve(cr);
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0);
if (button->press_count) {
cairo_set_source_rgb(cr, 0.7, 0.7, 0.7);
} else if (button->hover_count) {
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
} else {
cairo_set_source_rgb(cr, 0.88, 0.88, 0.88);
if(button->status_effect == FRAME_STATUS_CLOSE) {
cairo_set_source_rgb(cr, 0.768, 0.184, 0.109);
} else {
cairo_set_source_rgb(cr, 0.8, 0.8, 0.8);
}
}
cairo_fill (cr);
x += 4;
}
cairo_set_source_surface(cr, button->icon, x, y);
if(flags & THEME_FRAME_MAXIMIZED && button->icon_restore != NULL) {
cairo_set_source_surface(cr, button->icon_restore, x, y);
} else if (button->status_effect & FRAME_STATUS_MENU){
cairo_set_source_surface(cr, button->icon, x+7, y+5);
} else {
cairo_set_source_surface(cr, button->icon, x, y);
}
cairo_paint(cr);
cairo_restore(cr);
@ -355,6 +375,7 @@ frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
if (icon) {
button = frame_button_create_from_surface(frame,
icon,
NULL,
FRAME_STATUS_MENU,
FRAME_BUTTON_CLICK_DOWN);
} else {
@ -365,6 +386,7 @@ frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
button = frame_button_create(frame,
name,
NULL,
FRAME_STATUS_MENU,
FRAME_BUTTON_CLICK_DOWN);
free(name);
@ -381,6 +403,7 @@ frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
button = frame_button_create(frame,
name,
NULL,
FRAME_STATUS_CLOSE,
FRAME_BUTTON_ALIGN_RIGHT |
FRAME_BUTTON_DECORATED);
@ -391,12 +414,14 @@ frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
if (buttons & FRAME_BUTTON_MAXIMIZE) {
char *name = file_name_with_datadir("sign_maximize.png");
char *name_restore = file_name_with_datadir("sign_restorenormal.png");
if (!name)
goto free_frame;
button = frame_button_create(frame,
name,
name_restore,
FRAME_STATUS_MAXIMIZE,
FRAME_BUTTON_ALIGN_RIGHT |
FRAME_BUTTON_DECORATED);
@ -413,6 +438,7 @@ frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
button = frame_button_create(frame,
name,
NULL,
FRAME_STATUS_MINIMIZE,
FRAME_BUTTON_ALIGN_RIGHT |
FRAME_BUTTON_DECORATED);
@ -593,27 +619,25 @@ frame_refresh_geometry(struct frame *frame)
x_l = t->width + frame->shadow_margin;
y = t->width + frame->shadow_margin;
wl_list_for_each(button, &frame->buttons, link) {
const int button_padding = 4;
const int button_padding = 0;
w = cairo_image_surface_get_width(button->icon);
h = cairo_image_surface_get_height(button->icon);
if (button->flags & FRAME_BUTTON_DECORATED)
w += 10;
if (button->flags & FRAME_BUTTON_ALIGN_RIGHT) {
x_r -= w;
button->allocation.x = x_r;
button->allocation.y = y;
button->allocation.width = w + 1;
button->allocation.height = h + 1;
button->allocation.width = w;
button->allocation.height = h;
x_r -= button_padding;
} else {
button->allocation.x = x_l;
button->allocation.y = y;
button->allocation.width = w + 1;
button->allocation.height = h + 1;
button->allocation.width = w;
button->allocation.height = h;
x_l += w;
x_l += button_padding;
@ -1074,7 +1098,7 @@ frame_repaint(struct frame *frame, cairo_t *cr)
cairo_restore(cr);
wl_list_for_each(button, &frame->buttons, link)
frame_button_repaint(button, cr);
frame_button_repaint(button, cr, flags);
frame_status_clear(frame, FRAME_STATUS_REPAINT);
}