2
* Copyright © 2006 Novell, Inc.
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
19
* Author: David Reveman <davidr@novell.com>
21
* 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com>
22
* Frames Management: Copright © 2011 Canonical Ltd.
23
* Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
1
26
#include "gtk-window-decorator.h"
5
double meta_opacity = META_OPACITY;
6
gboolean meta_shade_opacity = META_SHADE_OPACITY;
7
double meta_active_opacity = META_ACTIVE_OPACITY;
8
gboolean meta_active_shade_opacity = META_ACTIVE_SHADE_OPACITY;
10
gboolean meta_button_layout_set = FALSE;
11
MetaButtonLayout meta_button_layout;
14
31
decor_update_meta_window_property (decor_t *d,
59
77
top_stretch_offset,
60
78
bottom_stretch_offset);
62
extents = _win_extents;
63
max_extents = _max_win_extents;
65
extents.top += titlebar_height;
66
max_extents.top += max_titlebar_height;
80
win_extents.top += d->frame->titlebar_height;
81
max_win_extents.top += d->frame->max_titlebar_height;
68
83
if (d->frame_window)
69
decor_gen_window_property (data, &extents, &max_extents, 20, 20);
84
decor_gen_window_property (data, &win_extents, &max_win_extents, 20, 20);
71
86
decor_quads_to_property (data, GDK_PIXMAP_XID (d->pixmap),
72
&extents, &max_extents,
87
&win_extents, &win_extents,
88
&max_win_extents, &max_win_extents,
73
89
ICON_SPACE + d->button_width,
350
366
case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
351
type = meta_function_to_type (meta_button_layout.left_buttons[0]);
367
type = meta_function_to_type (settings->meta_button_layout.left_buttons[0]);
353
369
case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND:
354
type = meta_function_to_type (meta_button_layout.left_buttons[1]);
370
type = meta_function_to_type (settings->meta_button_layout.left_buttons[1]);
356
372
case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND:
357
type = meta_function_to_type (meta_button_layout.left_buttons[2]);
373
type = meta_function_to_type (settings->meta_button_layout.left_buttons[2]);
359
375
case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
360
type = meta_function_to_type (meta_button_layout.right_buttons[0]);
376
type = meta_function_to_type (settings->meta_button_layout.right_buttons[0]);
362
378
case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND:
363
type = meta_function_to_type (meta_button_layout.right_buttons[1]);
379
type = meta_function_to_type (settings->meta_button_layout.right_buttons[1]);
365
381
case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND:
366
type = meta_function_to_type (meta_button_layout.right_buttons[2]);
382
type = meta_function_to_type (settings->meta_button_layout.right_buttons[2]);
406
422
MetaFrameFlags *flags,
407
423
MetaFrameGeometry *fgeom,
408
424
MetaButtonLayout *button_layout,
425
MetaFrameType frame_type,
409
426
GdkRectangle *clip)
411
428
gint left_width, right_width, top_height, bottom_height;
413
if (meta_button_layout_set)
430
if (!(frame_type < META_FRAME_TYPE_LAST))
431
frame_type = META_FRAME_TYPE_NORMAL;
433
if (settings->meta_button_layout_set)
415
*button_layout = meta_button_layout;
435
*button_layout = settings->meta_button_layout;
535
556
Region bottom_region = NULL;
536
557
Region left_region = NULL;
537
558
Region right_region = NULL;
538
double alpha = (d->active) ? meta_active_opacity : meta_opacity;
539
gboolean shade_alpha = (d->active) ? meta_active_shade_opacity :
559
double alpha = (d->active) ? settings->meta_active_opacity : settings->meta_opacity;
560
gboolean shade_alpha = (d->active) ? settings->meta_active_shade_opacity :
561
settings->meta_shade_opacity;
541
562
MetaFrameStyle *frame_style;
542
563
GtkWidget *style_window;
543
564
GdkColor bg_color;
555
576
gdk_drawable_set_colormap (GDK_DRAWABLE (d->buffer_pixmap), cmap);
558
if (decoration_alpha == 1.0)
579
if (settings->decoration_alpha == 1.0)
561
582
if (gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)) == 32)
563
style = gtk_widget_get_style (style_window_rgba);
564
style_window = style_window_rgba;
584
style = gtk_widget_get_style (d->frame->style_window_rgba);
585
style_window = d->frame->style_window_rgba;
568
style = gtk_widget_get_style (style_window_rgb);
569
style_window = style_window_rgb;
589
style = gtk_widget_get_style (d->frame->style_window_rgb);
590
style_window = d->frame->style_window_rgb;
572
593
drawable = d->buffer_pixmap ? d->buffer_pixmap : d->pixmap;
578
599
theme = meta_theme_get_current ();
601
frame_type = meta_frame_type_from_string (d->frame->type);
603
if (frame_type == META_FRAME_TYPE_LAST)
604
frame_type = META_FRAME_TYPE_NORMAL;
580
606
meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout,
583
609
/* we only have to redraw the shadow background when decoration
626
652
cmap = get_colormap_for_drawable (GDK_DRAWABLE (d->pixmap));
627
653
depth = gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window));
628
pixmap = create_pixmap (rect.width, size, depth);
654
pixmap = create_pixmap (rect.width, size, d->frame->style_window_rgb);
629
655
gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap);
632
pixmap = create_pixmap (rect.width, size, 32);
658
pixmap = create_pixmap (rect.width, size, d->frame->style_window_rgba);
634
660
cr = gdk_cairo_create (GDK_DRAWABLE (pixmap));
635
661
gdk_cairo_set_source_color_alpha (cr, &bg_color, bg_alpha);
742
768
cmap = get_colormap_for_drawable (GDK_DRAWABLE (d->pixmap));
743
769
depth = gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window));
744
pixmap = create_pixmap (size, rect.height, depth);
770
pixmap = create_pixmap (size, rect.height, d->frame->style_window_rgb);
745
771
gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap);
748
pixmap = create_pixmap (size, rect.height, 32);
774
pixmap = create_pixmap (size, rect.height, d->frame->style_window_rgba);
750
776
cr = gdk_cairo_create (GDK_DRAWABLE (pixmap));
751
777
gdk_cairo_set_source_color_alpha (cr, &bg_color, bg_alpha);
1058
1071
if (d->frame_window)
1060
*x += _win_extents.left + 4;
1061
*y += _win_extents.top + 2;
1073
*x += d->frame->win_extents.left + 4;
1074
*y += d->frame->win_extents.top + 2;
1081
meta_get_title_scale (decor_frame_t *frame)
1083
MetaTheme *theme = meta_theme_get_current ();
1085
MetaFrameFlags flags = 0xc33; /* fixme */
1087
type = meta_frame_type_from_string (frame->type);
1089
if (type == META_FRAME_TYPE_LAST)
1092
gfloat scale = meta_theme_get_title_scale (theme, type, flags);
1068
1098
meta_calc_decoration_size (decor_t *d,
1081
1111
if (!d->frame_window)
1083
context = &max_window_context;
1084
shadow = max_border_shadow;
1113
context = &d->frame->max_window_context;
1114
shadow = d->frame->max_border_shadow;
1088
context = &max_window_context_no_shadow;
1089
shadow = max_border_no_shadow;
1118
context = &d->frame->max_window_context_no_shadow;
1119
shadow = d->frame->max_border_no_shadow;
1094
1124
if (!d->frame_window)
1096
context = &window_context;
1097
shadow = border_shadow;
1126
context = &d->frame->window_context;
1127
shadow = d->frame->border_shadow;
1101
context = &window_context_no_shadow;
1102
shadow = border_no_shadow;
1131
context = &d->frame->window_context_no_shadow;
1132
shadow = d->frame->border_no_shadow;
1127
1157
if ((d->state & META_MAXIMIZED) == META_MAXIMIZED)
1128
1158
decor_get_default_layout (context, d->client_width,
1129
d->client_height - titlebar_height,
1159
d->client_height - d->frame->titlebar_height,
1132
1162
decor_get_default_layout (context, d->client_width,
1182
1212
MetaFrameGeometry fgeom;
1183
1213
MetaFrameFlags flags;
1184
1214
MetaTheme *theme;
1215
WnckWindowType win_type;
1185
1216
GdkRectangle clip;
1187
1218
theme = meta_theme_get_current ();
1220
win_type = wnck_window_get_window_type (d->win);
1189
1221
meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout,
1222
meta_frame_type_from_string (d->frame->type),
1192
1225
width += fgeom.right_width + fgeom.left_width;
1215
1248
*x = fgeom.left_width + RESIZE_EXTENDS;
1216
1249
*y = height - fgeom.bottom_height;
1217
1250
if (d->frame_window)
1218
*y += _win_extents.top + 2;
1251
*y += d->frame->win_extents.top + 2;
1219
1252
*w = width - fgeom.left_width - fgeom.right_width -
1220
1253
(2 * RESIZE_EXTENDS);
1221
1254
*h = fgeom.bottom_height;
1226
1259
*y = height - fgeom.bottom_height - RESIZE_EXTENDS;
1227
1260
if (d->frame_window)
1229
*x += _win_extents.left + 4;
1230
*y += _win_extents.bottom + 2;
1262
*x += d->frame->win_extents.left + 4;
1263
*y += d->frame->win_extents.bottom + 2;
1232
1265
*w = fgeom.left_width + RESIZE_EXTENDS;
1233
1266
*h = fgeom.bottom_height + RESIZE_EXTENDS;
1271
1304
if (d->frame_window)
1273
*x += _win_extents.left + 2;
1274
*y += _win_extents.top + 2 - fgeom.title_rect.height;
1306
*x += d->frame->win_extents.left + 2;
1307
*y += d->frame->win_extents.top + 2 - fgeom.title_rect.height;
1276
1309
*w = fgeom.right_width + RESIZE_EXTENDS;
1277
1310
*h = fgeom.top_height + RESIZE_EXTENDS;
1292
1325
if (d->frame_window)
1294
*x += _win_extents.left + 4;
1295
*y += _win_extents.top + 2 - fgeom.title_rect.height;
1327
*x += d->frame->win_extents.left + 4;
1328
*y += d->frame->win_extents.top + 2 - fgeom.title_rect.height;
1297
1330
*w = fgeom.left_width + RESIZE_EXTENDS;
1298
1331
*h = fgeom.top_height + RESIZE_EXTENDS;
1546
1579
new_layout = rtl_layout;
1549
meta_button_layout = new_layout;
1582
settings->meta_button_layout = new_layout;
1553
meta_update_border_extents (gint text_height)
1586
meta_update_border_extents (decor_frame_t *frame)
1556
gint top_height, bottom_height, left_width, right_width;
1558
theme = meta_theme_get_current ();
1560
meta_theme_get_frame_borders (theme,
1561
META_FRAME_TYPE_NORMAL,
1568
_win_extents.top = _default_win_extents.top;
1569
_win_extents.bottom = bottom_height;
1570
_win_extents.left = left_width;
1571
_win_extents.right = right_width;
1573
titlebar_height = top_height - _win_extents.top;
1575
meta_theme_get_frame_borders (theme,
1576
META_FRAME_TYPE_NORMAL,
1577
text_height, META_FRAME_MAXIMIZED,
1583
_max_win_extents.top = _default_win_extents.top;
1584
_max_win_extents.bottom = bottom_height;
1585
_max_win_extents.left = left_width;
1586
_max_win_extents.right = right_width;
1588
max_titlebar_height = top_height - _max_win_extents.top;
1588
MetaTheme *theme = meta_theme_get_current ();
1590
gwd_decor_frame_ref (frame);
1591
decor_frame_t *default_frame = gwd_get_decor_frame ("default");
1592
MetaFrameType frame_type = meta_frame_type_from_string (frame->type);
1593
gint top_height, bottom_height, left_width, right_width;
1595
if (!(frame_type < META_FRAME_TYPE_LAST))
1596
frame_type = META_FRAME_TYPE_NORMAL;
1598
meta_theme_get_frame_borders (theme,
1607
frame->win_extents.top = default_frame->win_extents.top;
1608
frame->win_extents.bottom = bottom_height;
1609
frame->win_extents.left = left_width;
1610
frame->win_extents.right = right_width;
1612
frame->titlebar_height = top_height - frame->win_extents.top;
1614
meta_theme_get_frame_borders (theme,
1617
META_FRAME_MAXIMIZED,
1623
frame->max_win_extents.top = default_frame->win_extents.top;
1624
frame->max_win_extents.bottom = bottom_height;
1625
frame->max_win_extents.left = left_width;
1626
frame->max_win_extents.right = right_width;
1628
frame->max_titlebar_height = top_height - frame->max_win_extents.top;
1630
gwd_decor_frame_unref (frame);
1631
gwd_decor_frame_unref (default_frame);