Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2008 Kristian Høgsberg |
| 3 | * Copyright © 2012-2013 Collabora, Ltd. |
| 4 | * Copyright © 2013 Jason Ekstrand |
| 5 | * |
Bryce Harrington | 6c6164c | 2015-06-11 14:20:17 -0700 | [diff] [blame] | 6 | * Permission is hereby granted, free of charge, to any person obtaining |
| 7 | * a copy of this software and associated documentation files (the |
| 8 | * "Software"), to deal in the Software without restriction, including |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | * the following conditions: |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 13 | * |
Bryce Harrington | 6c6164c | 2015-06-11 14:20:17 -0700 | [diff] [blame] | 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial |
| 16 | * portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 22 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 23 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 | * SOFTWARE. |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #include "config.h" |
| 29 | |
Jussi Kukkonen | 649bbce | 2016-07-19 14:16:27 +0300 | [diff] [blame] | 30 | #include <stdint.h> |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 31 | #include <stdlib.h> |
| 32 | #include <string.h> |
| 33 | #include <wayland-util.h> |
| 34 | #include <linux/input.h> |
| 35 | |
| 36 | #include "cairo-util.h" |
| 37 | |
| 38 | enum frame_button_flags { |
| 39 | FRAME_BUTTON_ALIGN_RIGHT = 0x1, |
| 40 | FRAME_BUTTON_DECORATED = 0x2, |
| 41 | FRAME_BUTTON_CLICK_DOWN = 0x4, |
| 42 | }; |
| 43 | |
| 44 | struct frame_button { |
| 45 | struct frame *frame; |
| 46 | struct wl_list link; /* buttons_list */ |
| 47 | |
| 48 | cairo_surface_t *icon; |
| 49 | enum frame_button_flags flags; |
| 50 | int hover_count; |
| 51 | int press_count; |
| 52 | |
| 53 | struct { |
| 54 | int x, y; |
| 55 | int width, height; |
| 56 | } allocation; |
| 57 | |
| 58 | enum frame_status status_effect; |
| 59 | }; |
| 60 | |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 61 | struct frame_pointer_button { |
| 62 | struct wl_list link; |
| 63 | uint32_t button; |
| 64 | enum theme_location press_location; |
| 65 | struct frame_button *frame_button; |
| 66 | }; |
| 67 | |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 68 | struct frame_pointer { |
| 69 | struct wl_list link; |
| 70 | void *data; |
| 71 | |
| 72 | int x, y; |
| 73 | |
| 74 | struct frame_button *hover_button; |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 75 | struct wl_list down_buttons; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 76 | }; |
| 77 | |
Jason Ekstrand | 3f66cf9 | 2013-10-13 19:08:40 -0500 | [diff] [blame] | 78 | struct frame_touch { |
| 79 | struct wl_list link; |
| 80 | void *data; |
| 81 | |
| 82 | int x, y; |
| 83 | |
| 84 | struct frame_button *button; |
| 85 | }; |
| 86 | |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 87 | struct frame { |
| 88 | int32_t width, height; |
| 89 | char *title; |
| 90 | uint32_t flags; |
| 91 | struct theme *theme; |
| 92 | |
| 93 | struct { |
| 94 | int32_t x, y; |
| 95 | int32_t width, height; |
| 96 | } interior; |
| 97 | int shadow_margin; |
| 98 | int opaque_margin; |
| 99 | int geometry_dirty; |
| 100 | |
| 101 | uint32_t status; |
| 102 | |
| 103 | struct wl_list buttons; |
| 104 | struct wl_list pointers; |
Jason Ekstrand | 3f66cf9 | 2013-10-13 19:08:40 -0500 | [diff] [blame] | 105 | struct wl_list touches; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | static struct frame_button * |
| 109 | frame_button_create(struct frame *frame, const char *icon, |
| 110 | enum frame_status status_effect, |
| 111 | enum frame_button_flags flags) |
| 112 | { |
| 113 | struct frame_button *button; |
| 114 | |
| 115 | button = calloc(1, sizeof *button); |
| 116 | if (!button) |
| 117 | return NULL; |
| 118 | |
| 119 | button->icon = cairo_image_surface_create_from_png(icon); |
| 120 | if (!button->icon) { |
| 121 | free(button); |
| 122 | return NULL; |
| 123 | } |
| 124 | |
| 125 | button->frame = frame; |
| 126 | button->flags = flags; |
| 127 | button->status_effect = status_effect; |
| 128 | |
| 129 | wl_list_insert(frame->buttons.prev, &button->link); |
| 130 | |
| 131 | return button; |
| 132 | } |
| 133 | |
| 134 | static void |
| 135 | frame_button_destroy(struct frame_button *button) |
| 136 | { |
| 137 | cairo_surface_destroy(button->icon); |
| 138 | free(button); |
| 139 | } |
| 140 | |
| 141 | static void |
| 142 | frame_button_enter(struct frame_button *button) |
| 143 | { |
| 144 | if (!button->hover_count) |
| 145 | button->frame->status |= FRAME_STATUS_REPAINT; |
| 146 | button->hover_count++; |
| 147 | } |
| 148 | |
| 149 | static void |
| 150 | frame_button_leave(struct frame_button *button, struct frame_pointer *pointer) |
| 151 | { |
| 152 | button->hover_count--; |
| 153 | if (!button->hover_count) |
| 154 | button->frame->status |= FRAME_STATUS_REPAINT; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | static void |
| 158 | frame_button_press(struct frame_button *button) |
| 159 | { |
| 160 | if (!button->press_count) |
| 161 | button->frame->status |= FRAME_STATUS_REPAINT; |
| 162 | button->press_count++; |
| 163 | |
| 164 | if (button->flags & FRAME_BUTTON_CLICK_DOWN) |
| 165 | button->frame->status |= button->status_effect; |
| 166 | } |
| 167 | |
| 168 | static void |
| 169 | frame_button_release(struct frame_button *button) |
| 170 | { |
| 171 | button->press_count--; |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 172 | if (button->press_count) |
| 173 | return; |
| 174 | |
| 175 | button->frame->status |= FRAME_STATUS_REPAINT; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 176 | |
| 177 | if (!(button->flags & FRAME_BUTTON_CLICK_DOWN)) |
| 178 | button->frame->status |= button->status_effect; |
| 179 | } |
| 180 | |
| 181 | static void |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 182 | frame_button_cancel(struct frame_button *button) |
| 183 | { |
| 184 | button->press_count--; |
| 185 | if (!button->press_count) |
| 186 | button->frame->status |= FRAME_STATUS_REPAINT; |
| 187 | } |
| 188 | |
| 189 | static void |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 190 | frame_button_repaint(struct frame_button *button, cairo_t *cr) |
| 191 | { |
| 192 | int x, y; |
| 193 | |
| 194 | if (!button->allocation.width) |
| 195 | return; |
| 196 | if (!button->allocation.height) |
| 197 | return; |
| 198 | |
| 199 | x = button->allocation.x; |
| 200 | y = button->allocation.y; |
| 201 | |
| 202 | cairo_save(cr); |
| 203 | |
| 204 | if (button->flags & FRAME_BUTTON_DECORATED) { |
| 205 | cairo_set_line_width(cr, 1); |
| 206 | |
| 207 | cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); |
| 208 | cairo_rectangle(cr, x, y, 25, 16); |
| 209 | |
| 210 | cairo_stroke_preserve(cr); |
| 211 | |
| 212 | if (button->press_count) { |
| 213 | cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); |
| 214 | } else if (button->hover_count) { |
| 215 | cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); |
| 216 | } else { |
| 217 | cairo_set_source_rgb(cr, 0.88, 0.88, 0.88); |
| 218 | } |
| 219 | |
| 220 | cairo_fill (cr); |
| 221 | |
| 222 | x += 4; |
| 223 | } |
| 224 | |
| 225 | cairo_set_source_surface(cr, button->icon, x, y); |
| 226 | cairo_paint(cr); |
| 227 | |
| 228 | cairo_restore(cr); |
| 229 | } |
| 230 | |
| 231 | static struct frame_pointer * |
| 232 | frame_pointer_get(struct frame *frame, void *data) |
| 233 | { |
| 234 | struct frame_pointer *pointer; |
| 235 | |
| 236 | wl_list_for_each(pointer, &frame->pointers, link) |
| 237 | if (pointer->data == data) |
| 238 | return pointer; |
| 239 | |
| 240 | pointer = calloc(1, sizeof *pointer); |
| 241 | if (!pointer) |
| 242 | return NULL; |
| 243 | |
| 244 | pointer->data = data; |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 245 | wl_list_init(&pointer->down_buttons); |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 246 | wl_list_insert(&frame->pointers, &pointer->link); |
| 247 | |
| 248 | return pointer; |
| 249 | } |
| 250 | |
| 251 | static void |
| 252 | frame_pointer_destroy(struct frame_pointer *pointer) |
| 253 | { |
| 254 | wl_list_remove(&pointer->link); |
| 255 | free(pointer); |
| 256 | } |
| 257 | |
Jason Ekstrand | 3f66cf9 | 2013-10-13 19:08:40 -0500 | [diff] [blame] | 258 | static struct frame_touch * |
| 259 | frame_touch_get(struct frame *frame, void *data) |
| 260 | { |
| 261 | struct frame_touch *touch; |
| 262 | |
| 263 | wl_list_for_each(touch, &frame->touches, link) |
| 264 | if (touch->data == data) |
| 265 | return touch; |
| 266 | |
| 267 | touch = calloc(1, sizeof *touch); |
| 268 | if (!touch) |
| 269 | return NULL; |
| 270 | |
| 271 | touch->data = data; |
| 272 | wl_list_insert(&frame->touches, &touch->link); |
| 273 | |
| 274 | return touch; |
| 275 | } |
| 276 | |
| 277 | static void |
| 278 | frame_touch_destroy(struct frame_touch *touch) |
| 279 | { |
| 280 | wl_list_remove(&touch->link); |
| 281 | free(touch); |
| 282 | } |
| 283 | |
U. Artie Eoff | 107de96 | 2014-01-17 11:19:46 -0800 | [diff] [blame] | 284 | void |
| 285 | frame_destroy(struct frame *frame) |
| 286 | { |
| 287 | struct frame_button *button, *next; |
| 288 | struct frame_touch *touch, *next_touch; |
| 289 | struct frame_pointer *pointer, *next_pointer; |
| 290 | |
| 291 | wl_list_for_each_safe(button, next, &frame->buttons, link) |
| 292 | frame_button_destroy(button); |
| 293 | |
| 294 | wl_list_for_each_safe(touch, next_touch, &frame->touches, link) |
| 295 | frame_touch_destroy(touch); |
| 296 | |
| 297 | wl_list_for_each_safe(pointer, next_pointer, &frame->pointers, link) |
| 298 | frame_pointer_destroy(pointer); |
| 299 | |
| 300 | free(frame->title); |
| 301 | free(frame); |
| 302 | } |
| 303 | |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 304 | struct frame * |
| 305 | frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons, |
| 306 | const char *title) |
| 307 | { |
| 308 | struct frame *frame; |
| 309 | struct frame_button *button; |
| 310 | |
| 311 | frame = calloc(1, sizeof *frame); |
| 312 | if (!frame) |
| 313 | return NULL; |
| 314 | |
| 315 | frame->width = width; |
| 316 | frame->height = height; |
| 317 | frame->flags = 0; |
| 318 | frame->theme = t; |
| 319 | frame->status = FRAME_STATUS_REPAINT; |
| 320 | frame->geometry_dirty = 1; |
| 321 | |
U. Artie Eoff | 107de96 | 2014-01-17 11:19:46 -0800 | [diff] [blame] | 322 | wl_list_init(&frame->buttons); |
| 323 | wl_list_init(&frame->pointers); |
| 324 | wl_list_init(&frame->touches); |
| 325 | |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 326 | if (title) { |
| 327 | frame->title = strdup(title); |
| 328 | if (!frame->title) |
| 329 | goto free_frame; |
| 330 | } |
| 331 | |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 332 | if (title) { |
| 333 | button = frame_button_create(frame, |
| 334 | DATADIR "/weston/icon_window.png", |
| 335 | FRAME_STATUS_MENU, |
| 336 | FRAME_BUTTON_CLICK_DOWN); |
| 337 | if (!button) |
| 338 | goto free_frame; |
| 339 | } |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 340 | |
| 341 | if (buttons & FRAME_BUTTON_CLOSE) { |
| 342 | button = frame_button_create(frame, |
| 343 | DATADIR "/weston/sign_close.png", |
| 344 | FRAME_STATUS_CLOSE, |
| 345 | FRAME_BUTTON_ALIGN_RIGHT | |
| 346 | FRAME_BUTTON_DECORATED); |
| 347 | if (!button) |
| 348 | goto free_frame; |
| 349 | } |
| 350 | |
| 351 | if (buttons & FRAME_BUTTON_MAXIMIZE) { |
| 352 | button = frame_button_create(frame, |
| 353 | DATADIR "/weston/sign_maximize.png", |
| 354 | FRAME_STATUS_MAXIMIZE, |
| 355 | FRAME_BUTTON_ALIGN_RIGHT | |
| 356 | FRAME_BUTTON_DECORATED); |
| 357 | if (!button) |
| 358 | goto free_frame; |
| 359 | } |
| 360 | |
| 361 | if (buttons & FRAME_BUTTON_MINIMIZE) { |
| 362 | button = frame_button_create(frame, |
| 363 | DATADIR "/weston/sign_minimize.png", |
| 364 | FRAME_STATUS_MINIMIZE, |
| 365 | FRAME_BUTTON_ALIGN_RIGHT | |
| 366 | FRAME_BUTTON_DECORATED); |
| 367 | if (!button) |
| 368 | goto free_frame; |
| 369 | } |
| 370 | |
| 371 | return frame; |
| 372 | |
| 373 | free_frame: |
U. Artie Eoff | 107de96 | 2014-01-17 11:19:46 -0800 | [diff] [blame] | 374 | frame_destroy(frame); |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 375 | return NULL; |
| 376 | } |
| 377 | |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 378 | int |
| 379 | frame_set_title(struct frame *frame, const char *title) |
| 380 | { |
| 381 | char *dup = NULL; |
| 382 | |
| 383 | if (title) { |
| 384 | dup = strdup(title); |
| 385 | if (!dup) |
| 386 | return -1; |
| 387 | } |
| 388 | |
| 389 | free(frame->title); |
| 390 | frame->title = dup; |
| 391 | |
Boyan Ding | 9c5aedf | 2014-07-04 15:19:23 +0800 | [diff] [blame] | 392 | frame->geometry_dirty = 1; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 393 | frame->status |= FRAME_STATUS_REPAINT; |
| 394 | |
| 395 | return 0; |
| 396 | } |
| 397 | |
| 398 | void |
| 399 | frame_set_flag(struct frame *frame, enum frame_flag flag) |
| 400 | { |
| 401 | if (flag & FRAME_FLAG_MAXIMIZED && !(frame->flags & FRAME_FLAG_MAXIMIZED)) |
| 402 | frame->geometry_dirty = 1; |
| 403 | |
| 404 | frame->flags |= flag; |
| 405 | frame->status |= FRAME_STATUS_REPAINT; |
| 406 | } |
| 407 | |
| 408 | void |
| 409 | frame_unset_flag(struct frame *frame, enum frame_flag flag) |
| 410 | { |
| 411 | if (flag & FRAME_FLAG_MAXIMIZED && frame->flags & FRAME_FLAG_MAXIMIZED) |
| 412 | frame->geometry_dirty = 1; |
| 413 | |
| 414 | frame->flags &= ~flag; |
| 415 | frame->status |= FRAME_STATUS_REPAINT; |
| 416 | } |
| 417 | |
| 418 | void |
| 419 | frame_resize(struct frame *frame, int32_t width, int32_t height) |
| 420 | { |
| 421 | frame->width = width; |
| 422 | frame->height = height; |
| 423 | |
| 424 | frame->geometry_dirty = 1; |
| 425 | frame->status |= FRAME_STATUS_REPAINT; |
| 426 | } |
| 427 | |
| 428 | void |
| 429 | frame_resize_inside(struct frame *frame, int32_t width, int32_t height) |
| 430 | { |
| 431 | struct theme *t = frame->theme; |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 432 | int decoration_width, decoration_height, titlebar_height; |
| 433 | |
Boyan Ding | c490212 | 2014-07-04 15:19:22 +0800 | [diff] [blame] | 434 | if (frame->title || !wl_list_empty(&frame->buttons)) |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 435 | titlebar_height = t->titlebar_height; |
| 436 | else |
| 437 | titlebar_height = t->width; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 438 | |
| 439 | if (frame->flags & FRAME_FLAG_MAXIMIZED) { |
| 440 | decoration_width = t->width * 2; |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 441 | decoration_height = t->width + titlebar_height; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 442 | } else { |
| 443 | decoration_width = (t->width + t->margin) * 2; |
| 444 | decoration_height = t->width + |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 445 | titlebar_height + t->margin * 2; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | frame_resize(frame, width + decoration_width, |
| 449 | height + decoration_height); |
| 450 | } |
| 451 | |
| 452 | int32_t |
| 453 | frame_width(struct frame *frame) |
| 454 | { |
| 455 | return frame->width; |
| 456 | } |
| 457 | |
| 458 | int32_t |
| 459 | frame_height(struct frame *frame) |
| 460 | { |
| 461 | return frame->height; |
| 462 | } |
| 463 | |
| 464 | static void |
| 465 | frame_refresh_geometry(struct frame *frame) |
| 466 | { |
| 467 | struct frame_button *button; |
| 468 | struct theme *t = frame->theme; |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 469 | int x_l, x_r, y, w, h, titlebar_height; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 470 | int32_t decoration_width, decoration_height; |
| 471 | |
| 472 | if (!frame->geometry_dirty) |
| 473 | return; |
| 474 | |
Boyan Ding | c490212 | 2014-07-04 15:19:22 +0800 | [diff] [blame] | 475 | if (frame->title || !wl_list_empty(&frame->buttons)) |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 476 | titlebar_height = t->titlebar_height; |
| 477 | else |
| 478 | titlebar_height = t->width; |
| 479 | |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 480 | if (frame->flags & FRAME_FLAG_MAXIMIZED) { |
| 481 | decoration_width = t->width * 2; |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 482 | decoration_height = t->width + titlebar_height; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 483 | |
| 484 | frame->interior.x = t->width; |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 485 | frame->interior.y = titlebar_height; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 486 | frame->interior.width = frame->width - decoration_width; |
| 487 | frame->interior.height = frame->height - decoration_height; |
| 488 | |
| 489 | frame->opaque_margin = 0; |
| 490 | frame->shadow_margin = 0; |
| 491 | } else { |
| 492 | decoration_width = (t->width + t->margin) * 2; |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 493 | decoration_height = t->width + titlebar_height + t->margin * 2; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 494 | |
| 495 | frame->interior.x = t->width + t->margin; |
Kristian Høgsberg | 89f4bc4 | 2013-10-23 22:12:13 -0700 | [diff] [blame] | 496 | frame->interior.y = titlebar_height + t->margin; |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 497 | frame->interior.width = frame->width - decoration_width; |
| 498 | frame->interior.height = frame->height - decoration_height; |
| 499 | |
| 500 | frame->opaque_margin = t->margin + t->frame_radius; |
| 501 | frame->shadow_margin = t->margin; |
| 502 | } |
| 503 | |
| 504 | x_r = frame->width - t->width - frame->shadow_margin; |
| 505 | x_l = t->width + frame->shadow_margin; |
| 506 | y = t->width + frame->shadow_margin; |
| 507 | wl_list_for_each(button, &frame->buttons, link) { |
| 508 | const int button_padding = 4; |
| 509 | w = cairo_image_surface_get_width(button->icon); |
| 510 | h = cairo_image_surface_get_height(button->icon); |
| 511 | |
| 512 | if (button->flags & FRAME_BUTTON_DECORATED) |
| 513 | w += 10; |
| 514 | |
| 515 | if (button->flags & FRAME_BUTTON_ALIGN_RIGHT) { |
| 516 | x_r -= w; |
| 517 | |
| 518 | button->allocation.x = x_r; |
| 519 | button->allocation.y = y; |
| 520 | button->allocation.width = w + 1; |
| 521 | button->allocation.height = h + 1; |
| 522 | |
| 523 | x_r -= button_padding; |
| 524 | } else { |
| 525 | button->allocation.x = x_l; |
| 526 | button->allocation.y = y; |
| 527 | button->allocation.width = w + 1; |
| 528 | button->allocation.height = h + 1; |
| 529 | |
| 530 | x_l += w; |
| 531 | x_l += button_padding; |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | frame->geometry_dirty = 0; |
| 536 | } |
| 537 | |
| 538 | void |
| 539 | frame_interior(struct frame *frame, int32_t *x, int32_t *y, |
| 540 | int32_t *width, int32_t *height) |
| 541 | { |
| 542 | frame_refresh_geometry(frame); |
| 543 | |
| 544 | if (x) |
| 545 | *x = frame->interior.x; |
| 546 | if (y) |
| 547 | *y = frame->interior.y; |
| 548 | if (width) |
| 549 | *width = frame->interior.width; |
| 550 | if (height) |
| 551 | *height = frame->interior.height; |
| 552 | } |
| 553 | |
| 554 | void |
| 555 | frame_input_rect(struct frame *frame, int32_t *x, int32_t *y, |
| 556 | int32_t *width, int32_t *height) |
| 557 | { |
| 558 | frame_refresh_geometry(frame); |
| 559 | |
| 560 | if (x) |
| 561 | *x = frame->shadow_margin; |
| 562 | if (y) |
| 563 | *y = frame->shadow_margin; |
| 564 | if (width) |
| 565 | *width = frame->width - frame->shadow_margin * 2; |
| 566 | if (height) |
| 567 | *height = frame->height - frame->shadow_margin * 2; |
| 568 | } |
| 569 | |
| 570 | void |
| 571 | frame_opaque_rect(struct frame *frame, int32_t *x, int32_t *y, |
| 572 | int32_t *width, int32_t *height) |
| 573 | { |
| 574 | frame_refresh_geometry(frame); |
| 575 | |
| 576 | if (x) |
| 577 | *x = frame->opaque_margin; |
| 578 | if (y) |
| 579 | *y = frame->opaque_margin; |
| 580 | if (width) |
| 581 | *width = frame->width - frame->opaque_margin * 2; |
| 582 | if (height) |
| 583 | *height = frame->height - frame->opaque_margin * 2; |
| 584 | } |
| 585 | |
Jasper St. Pierre | 7407345 | 2014-02-01 18:36:41 -0500 | [diff] [blame] | 586 | int |
| 587 | frame_get_shadow_margin(struct frame *frame) |
| 588 | { |
| 589 | frame_refresh_geometry(frame); |
| 590 | |
| 591 | return frame->shadow_margin; |
| 592 | } |
| 593 | |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 594 | uint32_t |
| 595 | frame_status(struct frame *frame) |
| 596 | { |
| 597 | return frame->status; |
| 598 | } |
| 599 | |
| 600 | void |
| 601 | frame_status_clear(struct frame *frame, enum frame_status status) |
| 602 | { |
| 603 | frame->status &= ~status; |
| 604 | } |
| 605 | |
| 606 | static struct frame_button * |
| 607 | frame_find_button(struct frame *frame, int x, int y) |
| 608 | { |
| 609 | struct frame_button *button; |
| 610 | int rel_x, rel_y; |
| 611 | |
| 612 | wl_list_for_each(button, &frame->buttons, link) { |
| 613 | rel_x = x - button->allocation.x; |
| 614 | rel_y = y - button->allocation.y; |
| 615 | |
| 616 | if (0 <= rel_x && rel_x < button->allocation.width && |
| 617 | 0 <= rel_y && rel_y < button->allocation.height) |
| 618 | return button; |
| 619 | } |
| 620 | |
| 621 | return NULL; |
| 622 | } |
| 623 | |
| 624 | enum theme_location |
| 625 | frame_pointer_enter(struct frame *frame, void *data, int x, int y) |
| 626 | { |
| 627 | return frame_pointer_motion(frame, data, x, y); |
| 628 | } |
| 629 | |
| 630 | enum theme_location |
| 631 | frame_pointer_motion(struct frame *frame, void *data, int x, int y) |
| 632 | { |
| 633 | struct frame_pointer *pointer = frame_pointer_get(frame, data); |
| 634 | struct frame_button *button = frame_find_button(frame, x, y); |
| 635 | enum theme_location location; |
| 636 | |
| 637 | location = theme_get_location(frame->theme, x, y, |
| 638 | frame->width, frame->height, |
| 639 | frame->flags & FRAME_FLAG_MAXIMIZED ? |
| 640 | THEME_FRAME_MAXIMIZED : 0); |
| 641 | if (!pointer) |
| 642 | return location; |
| 643 | |
| 644 | pointer->x = x; |
| 645 | pointer->y = y; |
| 646 | |
| 647 | if (pointer->hover_button == button) |
| 648 | return location; |
| 649 | |
| 650 | if (pointer->hover_button) |
| 651 | frame_button_leave(pointer->hover_button, pointer); |
| 652 | |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 653 | pointer->hover_button = button; |
| 654 | |
| 655 | if (pointer->hover_button) |
| 656 | frame_button_enter(pointer->hover_button); |
| 657 | |
| 658 | return location; |
| 659 | } |
| 660 | |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 661 | static void |
| 662 | frame_pointer_button_destroy(struct frame_pointer_button *button) |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 663 | { |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 664 | wl_list_remove(&button->link); |
| 665 | free(button); |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 666 | } |
| 667 | |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 668 | static void |
| 669 | frame_pointer_button_press(struct frame *frame, struct frame_pointer *pointer, |
| 670 | struct frame_pointer_button *button) |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 671 | { |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 672 | if (button->button == BTN_RIGHT) { |
| 673 | if (button->press_location == THEME_LOCATION_TITLEBAR) |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 674 | frame->status |= FRAME_STATUS_MENU; |
| 675 | |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 676 | frame_pointer_button_destroy(button); |
| 677 | |
| 678 | } else if (button->button == BTN_LEFT) { |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 679 | if (pointer->hover_button) { |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 680 | frame_button_press(pointer->hover_button); |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 681 | } else { |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 682 | switch (button->press_location) { |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 683 | case THEME_LOCATION_TITLEBAR: |
| 684 | frame->status |= FRAME_STATUS_MOVE; |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 685 | |
| 686 | frame_pointer_button_destroy(button); |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 687 | break; |
| 688 | case THEME_LOCATION_RESIZING_TOP: |
| 689 | case THEME_LOCATION_RESIZING_BOTTOM: |
| 690 | case THEME_LOCATION_RESIZING_LEFT: |
| 691 | case THEME_LOCATION_RESIZING_RIGHT: |
| 692 | case THEME_LOCATION_RESIZING_TOP_LEFT: |
| 693 | case THEME_LOCATION_RESIZING_TOP_RIGHT: |
| 694 | case THEME_LOCATION_RESIZING_BOTTOM_LEFT: |
| 695 | case THEME_LOCATION_RESIZING_BOTTOM_RIGHT: |
| 696 | frame->status |= FRAME_STATUS_RESIZE; |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 697 | |
| 698 | frame_pointer_button_destroy(button); |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 699 | break; |
| 700 | default: |
| 701 | break; |
| 702 | } |
| 703 | } |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 704 | } |
| 705 | } |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 706 | |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 707 | static void |
| 708 | frame_pointer_button_release(struct frame *frame, struct frame_pointer *pointer, |
| 709 | struct frame_pointer_button *button) |
| 710 | { |
| 711 | if (button->button == BTN_LEFT && button->frame_button) { |
| 712 | if (button->frame_button == pointer->hover_button) |
| 713 | frame_button_release(button->frame_button); |
| 714 | else |
| 715 | frame_button_cancel(button->frame_button); |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | static void |
| 720 | frame_pointer_button_cancel(struct frame *frame, struct frame_pointer *pointer, |
| 721 | struct frame_pointer_button *button) |
| 722 | { |
| 723 | if (button->frame_button) |
| 724 | frame_button_cancel(button->frame_button); |
| 725 | } |
| 726 | |
| 727 | void |
| 728 | frame_pointer_leave(struct frame *frame, void *data) |
| 729 | { |
| 730 | struct frame_pointer *pointer = frame_pointer_get(frame, data); |
| 731 | struct frame_pointer_button *button, *next; |
| 732 | if (!pointer) |
| 733 | return; |
| 734 | |
| 735 | if (pointer->hover_button) |
| 736 | frame_button_leave(pointer->hover_button, pointer); |
| 737 | |
| 738 | wl_list_for_each_safe(button, next, &pointer->down_buttons, link) { |
| 739 | frame_pointer_button_cancel(frame, pointer, button); |
| 740 | frame_pointer_button_destroy(button); |
| 741 | } |
| 742 | |
| 743 | frame_pointer_destroy(pointer); |
| 744 | } |
| 745 | |
| 746 | enum theme_location |
| 747 | frame_pointer_button(struct frame *frame, void *data, |
Quentin Glidic | d8b17bc | 2016-07-10 11:00:55 +0200 | [diff] [blame] | 748 | uint32_t btn, enum wl_pointer_button_state state) |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 749 | { |
| 750 | struct frame_pointer *pointer = frame_pointer_get(frame, data); |
| 751 | struct frame_pointer_button *button; |
U. Artie Eoff | 6d71c3c | 2014-01-17 14:44:05 -0800 | [diff] [blame] | 752 | enum theme_location location = THEME_LOCATION_EXTERIOR; |
| 753 | |
| 754 | if (!pointer) |
| 755 | return location; |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 756 | |
| 757 | location = theme_get_location(frame->theme, pointer->x, pointer->y, |
| 758 | frame->width, frame->height, |
| 759 | frame->flags & FRAME_FLAG_MAXIMIZED ? |
| 760 | THEME_FRAME_MAXIMIZED : 0); |
| 761 | |
Quentin Glidic | d8b17bc | 2016-07-10 11:00:55 +0200 | [diff] [blame] | 762 | if (state == WL_POINTER_BUTTON_STATE_PRESSED) { |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 763 | button = malloc(sizeof *button); |
| 764 | if (!button) |
| 765 | return location; |
| 766 | |
| 767 | button->button = btn; |
| 768 | button->press_location = location; |
| 769 | button->frame_button = pointer->hover_button; |
| 770 | wl_list_insert(&pointer->down_buttons, &button->link); |
| 771 | |
| 772 | frame_pointer_button_press(frame, pointer, button); |
Quentin Glidic | d8b17bc | 2016-07-10 11:00:55 +0200 | [diff] [blame] | 773 | } else if (state == WL_POINTER_BUTTON_STATE_RELEASED) { |
Jason Ekstrand | 0bdd58f | 2013-10-27 22:25:03 -0500 | [diff] [blame] | 774 | button = NULL; |
| 775 | wl_list_for_each(button, &pointer->down_buttons, link) |
| 776 | if (button->button == btn) |
| 777 | break; |
| 778 | /* Make sure we didn't hit the end */ |
| 779 | if (&button->link == &pointer->down_buttons) |
| 780 | return location; |
| 781 | |
| 782 | location = button->press_location; |
| 783 | frame_pointer_button_release(frame, pointer, button); |
| 784 | frame_pointer_button_destroy(button); |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | return location; |
| 788 | } |
| 789 | |
Derek Foreman | 9690641 | 2015-11-06 15:56:07 -0600 | [diff] [blame] | 790 | enum theme_location |
Jason Ekstrand | 3f66cf9 | 2013-10-13 19:08:40 -0500 | [diff] [blame] | 791 | frame_touch_down(struct frame *frame, void *data, int32_t id, int x, int y) |
| 792 | { |
| 793 | struct frame_touch *touch = frame_touch_get(frame, data); |
| 794 | struct frame_button *button = frame_find_button(frame, x, y); |
| 795 | enum theme_location location; |
| 796 | |
Jason Ekstrand | 3f66cf9 | 2013-10-13 19:08:40 -0500 | [diff] [blame] | 797 | location = theme_get_location(frame->theme, x, y, |
| 798 | frame->width, frame->height, |
| 799 | frame->flags & FRAME_FLAG_MAXIMIZED ? |
| 800 | THEME_FRAME_MAXIMIZED : 0); |
| 801 | |
Derek Foreman | 9690641 | 2015-11-06 15:56:07 -0600 | [diff] [blame] | 802 | if (id > 0) |
| 803 | return location; |
| 804 | |
| 805 | if (touch && button) { |
| 806 | touch->button = button; |
| 807 | frame_button_press(touch->button); |
| 808 | return location; |
| 809 | } |
| 810 | |
Jason Ekstrand | 3f66cf9 | 2013-10-13 19:08:40 -0500 | [diff] [blame] | 811 | switch (location) { |
| 812 | case THEME_LOCATION_TITLEBAR: |
| 813 | frame->status |= FRAME_STATUS_MOVE; |
| 814 | break; |
| 815 | case THEME_LOCATION_RESIZING_TOP: |
| 816 | case THEME_LOCATION_RESIZING_BOTTOM: |
| 817 | case THEME_LOCATION_RESIZING_LEFT: |
| 818 | case THEME_LOCATION_RESIZING_RIGHT: |
| 819 | case THEME_LOCATION_RESIZING_TOP_LEFT: |
| 820 | case THEME_LOCATION_RESIZING_TOP_RIGHT: |
| 821 | case THEME_LOCATION_RESIZING_BOTTOM_LEFT: |
| 822 | case THEME_LOCATION_RESIZING_BOTTOM_RIGHT: |
| 823 | frame->status |= FRAME_STATUS_RESIZE; |
| 824 | break; |
| 825 | default: |
| 826 | break; |
| 827 | } |
Derek Foreman | 9690641 | 2015-11-06 15:56:07 -0600 | [diff] [blame] | 828 | return location; |
Jason Ekstrand | 3f66cf9 | 2013-10-13 19:08:40 -0500 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | void |
| 832 | frame_touch_up(struct frame *frame, void *data, int32_t id) |
| 833 | { |
| 834 | struct frame_touch *touch = frame_touch_get(frame, data); |
| 835 | |
| 836 | if (id > 0) |
| 837 | return; |
| 838 | |
U. Artie Eoff | 6d71c3c | 2014-01-17 14:44:05 -0800 | [diff] [blame] | 839 | if (touch && touch->button) { |
Jason Ekstrand | 3f66cf9 | 2013-10-13 19:08:40 -0500 | [diff] [blame] | 840 | frame_button_release(touch->button); |
| 841 | frame_touch_destroy(touch); |
Jason Ekstrand | 3f66cf9 | 2013-10-13 19:08:40 -0500 | [diff] [blame] | 842 | } |
| 843 | } |
| 844 | |
Xiong Zhang | bfb4ade | 2014-06-12 11:06:25 +0800 | [diff] [blame] | 845 | enum theme_location |
| 846 | frame_double_click(struct frame *frame, void *data, |
Quentin Glidic | d8b17bc | 2016-07-10 11:00:55 +0200 | [diff] [blame] | 847 | uint32_t btn, enum wl_pointer_button_state state) |
Xiong Zhang | bfb4ade | 2014-06-12 11:06:25 +0800 | [diff] [blame] | 848 | { |
| 849 | struct frame_pointer *pointer = frame_pointer_get(frame, data); |
| 850 | struct frame_button *button; |
| 851 | enum theme_location location = THEME_LOCATION_EXTERIOR; |
| 852 | |
| 853 | location = theme_get_location(frame->theme, pointer->x, pointer->y, |
| 854 | frame->width, frame->height, |
| 855 | frame->flags & FRAME_FLAG_MAXIMIZED ? |
| 856 | THEME_FRAME_MAXIMIZED : 0); |
| 857 | |
| 858 | button = frame_find_button(frame, pointer->x, pointer->y); |
| 859 | |
| 860 | if (location != THEME_LOCATION_TITLEBAR || btn != BTN_LEFT) |
| 861 | return location; |
| 862 | |
Quentin Glidic | d8b17bc | 2016-07-10 11:00:55 +0200 | [diff] [blame] | 863 | if (state == WL_POINTER_BUTTON_STATE_PRESSED) { |
Xiong Zhang | bfb4ade | 2014-06-12 11:06:25 +0800 | [diff] [blame] | 864 | if (button) |
| 865 | frame_button_press(button); |
| 866 | else |
| 867 | frame->status |= FRAME_STATUS_MAXIMIZE; |
Quentin Glidic | d8b17bc | 2016-07-10 11:00:55 +0200 | [diff] [blame] | 868 | } else if (state == WL_POINTER_BUTTON_STATE_RELEASED) { |
Xiong Zhang | bfb4ade | 2014-06-12 11:06:25 +0800 | [diff] [blame] | 869 | if (button) |
| 870 | frame_button_release(button); |
| 871 | } |
| 872 | |
| 873 | return location; |
| 874 | } |
| 875 | |
Jason Ekstrand | 3f66cf9 | 2013-10-13 19:08:40 -0500 | [diff] [blame] | 876 | void |
Xiong Zhang | 382de46 | 2014-06-12 11:06:26 +0800 | [diff] [blame] | 877 | frame_double_touch_down(struct frame *frame, void *data, int32_t id, |
| 878 | int x, int y) |
| 879 | { |
| 880 | struct frame_touch *touch = frame_touch_get(frame, data); |
| 881 | struct frame_button *button = frame_find_button(frame, x, y); |
| 882 | enum theme_location location; |
| 883 | |
| 884 | if (touch && button) { |
| 885 | touch->button = button; |
| 886 | frame_button_press(touch->button); |
| 887 | return; |
| 888 | } |
| 889 | |
| 890 | location = theme_get_location(frame->theme, x, y, |
| 891 | frame->width, frame->height, |
| 892 | frame->flags & FRAME_FLAG_MAXIMIZED ? |
| 893 | THEME_FRAME_MAXIMIZED : 0); |
| 894 | |
| 895 | switch (location) { |
| 896 | case THEME_LOCATION_TITLEBAR: |
| 897 | frame->status |= FRAME_STATUS_MAXIMIZE; |
| 898 | break; |
| 899 | case THEME_LOCATION_RESIZING_TOP: |
| 900 | case THEME_LOCATION_RESIZING_BOTTOM: |
| 901 | case THEME_LOCATION_RESIZING_LEFT: |
| 902 | case THEME_LOCATION_RESIZING_RIGHT: |
| 903 | case THEME_LOCATION_RESIZING_TOP_LEFT: |
| 904 | case THEME_LOCATION_RESIZING_TOP_RIGHT: |
| 905 | case THEME_LOCATION_RESIZING_BOTTOM_LEFT: |
| 906 | case THEME_LOCATION_RESIZING_BOTTOM_RIGHT: |
| 907 | frame->status |= FRAME_STATUS_RESIZE; |
| 908 | break; |
| 909 | default: |
| 910 | break; |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | void |
| 915 | frame_double_touch_up(struct frame *frame, void *data, int32_t id) |
| 916 | { |
| 917 | struct frame_touch *touch = frame_touch_get(frame, data); |
| 918 | |
| 919 | if (touch && touch->button) { |
| 920 | frame_button_release(touch->button); |
| 921 | frame_touch_destroy(touch); |
| 922 | } |
| 923 | } |
| 924 | |
| 925 | void |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 926 | frame_repaint(struct frame *frame, cairo_t *cr) |
| 927 | { |
| 928 | struct frame_button *button; |
| 929 | uint32_t flags = 0; |
| 930 | |
| 931 | frame_refresh_geometry(frame); |
| 932 | |
| 933 | if (frame->flags & FRAME_FLAG_MAXIMIZED) |
| 934 | flags |= THEME_FRAME_MAXIMIZED; |
| 935 | |
| 936 | if (frame->flags & FRAME_FLAG_ACTIVE) |
| 937 | flags |= THEME_FRAME_ACTIVE; |
| 938 | |
| 939 | cairo_save(cr); |
| 940 | theme_render_frame(frame->theme, cr, frame->width, frame->height, |
Boyan Ding | 850a514 | 2014-08-05 15:22:04 +0800 | [diff] [blame] | 941 | frame->title, &frame->buttons, flags); |
Jason Ekstrand | 01c9ec3 | 2013-10-13 19:08:39 -0500 | [diff] [blame] | 942 | cairo_restore(cr); |
| 943 | |
| 944 | wl_list_for_each(button, &frame->buttons, link) |
| 945 | frame_button_repaint(button, cr); |
| 946 | |
| 947 | frame_status_clear(frame, FRAME_STATUS_REPAINT); |
| 948 | } |