diff --git a/clients/window.c b/clients/window.c index ca7e62d07..e3c37b91c 100644 --- a/clients/window.c +++ b/clients/window.c @@ -1613,18 +1613,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; @@ -1641,6 +1635,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; @@ -1650,13 +1653,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; } @@ -2711,7 +2714,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); } } @@ -2777,8 +2780,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->motion_handler) { + if(widget->motion_handler(input->focus_widget, + input, time, sx, sy, + widget->user_data) != CURSOR_LEFT_PTR) { + input_set_focus_widget(input, widget, sx, sy); + } + } + } } static void @@ -2798,7 +2812,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); @@ -2820,7 +2834,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); } @@ -2838,6 +2852,21 @@ 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); } @@ -3320,7 +3349,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) { diff --git a/data/sign_close.png b/data/sign_close.png index 56182a3c4..029c34571 100644 Binary files a/data/sign_close.png and b/data/sign_close.png differ diff --git a/data/sign_maximize.png b/data/sign_maximize.png index ae9e86abe..dae700cb3 100644 Binary files a/data/sign_maximize.png and b/data/sign_maximize.png differ diff --git a/data/sign_minimize.png b/data/sign_minimize.png index fd3a64aaf..6c2e450af 100644 Binary files a/data/sign_minimize.png and b/data/sign_minimize.png differ diff --git a/shared/cairo-util.c b/shared/cairo-util.c index f558e1d0c..19de7ebbc 100644 --- a/shared/cairo-util.c +++ b/shared/cairo-util.c @@ -391,9 +391,9 @@ theme_create(void) if (t == NULL) return NULL; - t->margin = 32; - t->width = 6; - t->titlebar_height = 27; + t->margin = 20; + 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); diff --git a/shared/frame.c b/shared/frame.c index cf58d66b7..0f318cab2 100644 --- a/shared/frame.c +++ b/shared/frame.c @@ -209,7 +209,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,24 +224,30 @@ 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); 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 if (button->hover_count) { + if(button->status_effect == FRAME_STATUS_CLOSE) { + cairo_set_source_rgb(cr, 0.768, 0.184, 0.109); + } else { + cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + } } else { - cairo_set_source_rgb(cr, 0.88, 0.88, 0.88); + if (flags & THEME_FRAME_ACTIVE) { + cairo_set_source_rgb(cr, 0.941, 0.953, 0.976); + } else { + cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); + } } cairo_fill (cr); - - x += 4; } cairo_set_source_surface(cr, button->icon, x, y); @@ -357,17 +363,6 @@ frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons, icon, FRAME_STATUS_MENU, FRAME_BUTTON_CLICK_DOWN); - } else { - char *name = file_name_with_datadir("icon_window.png"); - - if (!name) - goto free_frame; - - button = frame_button_create(frame, - name, - FRAME_STATUS_MENU, - FRAME_BUTTON_CLICK_DOWN); - free(name); } if (!button) goto free_frame; @@ -585,27 +580,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; @@ -1028,7 +1021,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); }