13
13
You should have received a copy of the GNU General Public License
14
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15
Foundation, Inc., Inc., 51 Franklin Street, Fifth Floor, Boston,
17
19
oroborus - (c) 2001 Ken Lynch
18
xfwm4 - (c) 2002-2006 Olivier Fourdan
20
xfwm4 - (c) 2002-2009 Olivier Fourdan
22
24
#ifdef HAVE_CONFIG_H
252
frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap * pm)
257
frameFillTitlePixmap (Client * c, int state, int part, int x, int w, int h, xfwmPixmap * title_pm, xfwmPixmap * top_pm)
259
ScreenInfo *screen_info;
261
TRACE ("entering frameFillTitlePixmap");
263
g_return_if_fail (c);
264
g_return_if_fail (title_pm);
265
g_return_if_fail (top_pm);
267
screen_info = c->screen_info;
269
if (!xfwmPixmapNone(&screen_info->top[part][state]))
271
xfwmPixmapFill (&screen_info->top[part][state], top_pm, x, 0, w, h);
275
xfwmPixmapFill (&screen_info->title[part][state], top_pm, x, 0, w, h);
277
xfwmPixmapFill (&screen_info->title[part][state], title_pm, x, 0, w, frameTop (c));
281
frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap * title_pm, xfwmPixmap * top_pm)
254
283
ScreenInfo *screen_info;
255
284
DisplayInfo *display_info;
260
289
PangoRectangle logical_rect;
261
290
int width, x, hoffset, w1, w2, w3, w4, w5, temp;
262
291
int voffset, title_x, title_y;
292
int title_height, top_height;
264
294
TRACE ("entering frameCreateTitlePixmap");
266
296
g_return_if_fail (c);
267
g_return_if_fail (pm);
297
g_return_if_fail (title_pm);
298
g_return_if_fail (top_pm);
269
300
screen_info = c->screen_info;
270
301
display_info = screen_info->display_info;
279
310
width = frameWidth (c) - frameTopLeftWidth (c, state) - frameTopRightWidth (c, state);
316
layout = gtk_widget_create_pango_layout (myScreenGetGtkWidget (screen_info), c->name);
317
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
289
319
if (left < frameTopLeftWidth (c, state))
291
321
left = frameTopLeftWidth (c, state);
340
voffset = screen_info->params->title_vertical_offset_active;
344
voffset = screen_info->params->title_vertical_offset_inactive;
347
title_height = screen_info->font_height;
350
/* If for some reason the font height is not known,
351
* use the actual pango layout height.
353
title_height = logical_rect.height;
355
title_y = voffset + (frameTop (c) - title_height) / 2;
356
if (title_y + title_height > frameTop (c))
358
title_y = MAX (0, frameTop (c) - title_height);
361
if (!xfwmPixmapNone(&screen_info->top[3][ACTIVE]))
363
top_height = screen_info->top[3][ACTIVE].height;
367
top_height = frameTop (c) / 10 + 1;
368
if (top_height > title_y - 1)
370
top_height = MAX (title_y - 1, 0);
310
375
w2 = screen_info->title[TITLE_2][state].width;
311
376
w4 = screen_info->title[TITLE_4][state].width;
313
layout = gtk_widget_create_pango_layout (myScreenGetGtkWidget (screen_info), c->name);
314
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
316
378
if (screen_info->params->full_width_title)
372
xfwmPixmapCreate (screen_info, pm, width, frameTop (c));
373
gpixmap = gdk_pixmap_foreign_new (pm->pixmap);
434
xfwmPixmapCreate (screen_info, top_pm, width, top_height);
435
xfwmPixmapCreate (screen_info, title_pm, width, frameTop (c));
436
gpixmap = gdk_pixmap_foreign_new (title_pm->pixmap);
374
437
gdk_drawable_set_colormap (gpixmap, gdk_screen_get_rgb_colormap (screen_info->gscr));
375
438
gc = gdk_gc_new (gpixmap);
379
xfwmPixmapFill (&screen_info->title[TITLE_1][state], pm, 0, 0, w1, frameTop (c));
442
frameFillTitlePixmap (c, state, TITLE_1, x, w1, top_height, title_pm, top_pm);
383
xfwmPixmapFill (&screen_info->title[TITLE_2][state], pm, x, 0, w2, frameTop (c));
446
frameFillTitlePixmap (c, state, TITLE_2, x, w2, top_height, title_pm, top_pm);
390
voffset = screen_info->params->title_vertical_offset_active;
394
voffset = screen_info->params->title_vertical_offset_inactive;
396
xfwmPixmapFill (&screen_info->title[TITLE_3][state], pm, x, 0, w3, frameTop (c));
451
frameFillTitlePixmap (c, state, TITLE_3, x, w3, top_height, title_pm, top_pm);
397
452
title_x = hoffset + x;
398
title_y = voffset + (frameTop (c) - logical_rect.height) / 2;
399
if (title_y + logical_rect.height > frameTop (c))
401
title_y = MAX (0, frameTop (c) - logical_rect.height);
403
453
if (screen_info->params->title_shadow[state])
405
455
gdk_gc_get_values (screen_info->title_shadow_colors[state].gc, &values);
429
xfwmPixmapFill (&screen_info->title[TITLE_4][state], pm, x, 0, w4, frameTop (c));
479
frameFillTitlePixmap (c, state, TITLE_4, x, w4, top_height, title_pm, top_pm);
434
xfwmPixmapFill (&screen_info->title[TITLE_5][state], pm, x, 0, w5, frameTop (c));
484
frameFillTitlePixmap (c, state, TITLE_5, x, w5, top_height, title_pm, top_pm);
436
486
g_object_unref (G_OBJECT (gc));
437
487
g_object_unref (G_OBJECT (gpixmap));
543
frameGetPixmap (Client * c, int button, int state)
545
ScreenInfo *screen_info;
547
screen_info = c->screen_info;
551
if (screen_info->params->show_app_icon)
553
return &c->appmenu[state];
557
if (FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)
558
&& screen_info->buttons[SHADE_BUTTON][state + 3].pixmap)
560
return &screen_info->buttons[SHADE_BUTTON][state + 3];
562
return &screen_info->buttons[SHADE_BUTTON][state];
565
if (FLAG_TEST (c->flags, CLIENT_FLAG_STICKY)
566
&& screen_info->buttons[STICK_BUTTON][state + 3].pixmap)
568
return &screen_info->buttons[STICK_BUTTON][state + 3];
570
return &screen_info->buttons[STICK_BUTTON][state];
572
case MAXIMIZE_BUTTON:
573
if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED)
574
&& screen_info->buttons[MAXIMIZE_BUTTON][state + 3].pixmap)
576
return &screen_info->buttons[MAXIMIZE_BUTTON][state + 3];
578
return &screen_info->buttons[MAXIMIZE_BUTTON][state];
583
return &screen_info->buttons[button][state];
588
593
frameSetShape (Client * c, int state, FramePixmap * frame_pix, int button_x[BUTTON_COUNT])
653
658
ShapeBounding, 0, 0, frame_pix->pm_sides[SIDE_BOTTOM].mask, ShapeSet);
661
if (xfwmWindowVisible (&c->sides[SIDE_TOP]))
663
XShapeCombineMask (display_info->dpy, MYWINDOW_XWINDOW (c->sides[SIDE_TOP]),
664
ShapeBounding, 0, 0, frame_pix->pm_sides[SIDE_TOP].mask, ShapeSet);
656
667
if (xfwmWindowVisible (&c->corners[CORNER_BOTTOM_LEFT]))
658
669
XShapeCombineMask (display_info->dpy, MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_LEFT]),
677
688
ShapeBounding, 0, 0, screen_info->corners[CORNER_TOP_RIGHT][state].mask, ShapeSet);
680
for (i = 0; i < BUTTON_LAST; i++)
691
for (i = 0; i < BUTTON_COUNT; i++)
682
693
if (xfwmWindowVisible (&c->buttons[i]))
684
my_pixmap = frameGetPixmap (c, i, c->button_pressed[i] ? PRESSED : state);
695
my_pixmap = clientGetButtonPixmap (c, i, clientGetButtonState (c, i, state));
685
696
XShapeCombineMask (display_info->dpy, MYWINDOW_XWINDOW (c->buttons[i]),
686
697
ShapeBounding, 0, 0, my_pixmap->mask, ShapeSet);
772
783
MYWINDOW_XWINDOW (c->sides[SIDE_BOTTOM]), ShapeBounding, ShapeUnion);
786
if (xfwmWindowVisible (&c->sides[SIDE_TOP]))
788
XShapeCombineShape (display_info->dpy, shape_win, ShapeBounding,
789
screen_info->corners[CORNER_BOTTOM_LEFT][state].width,
790
frameTop (c) - frameBottom (c),
791
MYWINDOW_XWINDOW (c->sides[SIDE_TOP]), ShapeBounding, ShapeUnion);
775
794
if (xfwmWindowVisible (&c->corners[CORNER_BOTTOM_LEFT]))
777
796
XShapeCombineShape (display_info->dpy, shape_win, ShapeBounding, 0,
794
813
0, MYWINDOW_XWINDOW (c->corners[CORNER_TOP_RIGHT]), ShapeBounding, ShapeUnion);
797
for (i = 0; i < BUTTON_LAST; i++)
816
for (i = 0; i < BUTTON_COUNT; i++)
799
818
if (xfwmWindowVisible (&c->buttons[i]))
882
903
FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_FIRST_MAP);
906
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_NEEDS_REDRAW))
908
FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_NEEDS_REDRAW);
887
909
width_changed = TRUE;
888
910
height_changed = TRUE;
889
911
requires_clearing = TRUE;
890
frameClearQueueDraw (c);
891
if (c->frame_timeout_id)
893
g_source_remove (c->frame_timeout_id);
894
c->frame_timeout_id = 0;
913
928
&& !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
915
930
/* First, hide the buttons that we don't have... */
916
for (i = 0; i < BUTTON_LAST; i++)
931
for (i = 0; i < BUTTON_COUNT; i++)
918
933
char b = getLetterFromButton (i, c);
919
934
if ((!b) || !strchr (screen_info->params->button_layout, b))
941
956
if (x + screen_info->buttons[button][state].width + screen_info->params->button_spacing < right)
943
my_pixmap = frameGetPixmap (c, button, c->button_pressed[button] ? PRESSED : state);
944
if (my_pixmap->pixmap)
958
my_pixmap = clientGetButtonPixmap (c, button, clientGetButtonState (c, button, state));
959
if (!xfwmPixmapNone(my_pixmap))
946
961
xfwmWindowSetBG (&c->buttons[button], my_pixmap);
976
991
if (x - screen_info->buttons[button][state].width - screen_info->params->button_spacing > left)
978
my_pixmap = frameGetPixmap (c, button, c->button_pressed[button] ? PRESSED : state);
979
if (my_pixmap->pixmap)
993
my_pixmap = clientGetButtonPixmap (c, button, clientGetButtonState (c, button, state));
994
if (!xfwmPixmapNone(my_pixmap))
981
996
xfwmWindowSetBG (&c->buttons[button], my_pixmap);
1007
1022
screen_info->corners[CORNER_BOTTOM_RIGHT][state].height;
1009
1024
xfwmPixmapInit (screen_info, &frame_pix.pm_title);
1025
xfwmPixmapInit (screen_info, &frame_pix.pm_sides[SIDE_TOP]);
1026
xfwmPixmapInit (screen_info, &frame_pix.pm_sides[SIDE_BOTTOM]);
1010
1027
xfwmPixmapInit (screen_info, &frame_pix.pm_sides[SIDE_LEFT]);
1011
1028
xfwmPixmapInit (screen_info, &frame_pix.pm_sides[SIDE_RIGHT]);
1012
xfwmPixmapInit (screen_info, &frame_pix.pm_sides[SIDE_BOTTOM]);
1014
1030
/* The title is always visible */
1015
frameCreateTitlePixmap (c, state, left, right, &frame_pix.pm_title);
1031
frameCreateTitlePixmap (c, state, left, right, &frame_pix.pm_title, &frame_pix.pm_sides[SIDE_TOP]);
1016
1032
xfwmWindowSetBG (&c->title, &frame_pix.pm_title);
1017
1033
xfwmWindowShow (&c->title,
1018
1034
frameTopLeftWidth (c, state), 0, top_width,
1037
1053
xfwmWindowHide (&c->sides[SIDE_LEFT]);
1038
1054
xfwmWindowHide (&c->sides[SIDE_RIGHT]);
1039
1055
xfwmWindowHide (&c->sides[SIDE_BOTTOM]);
1056
xfwmWindowHide (&c->sides[SIDE_TOP]);
1040
1057
xfwmWindowHide (&c->corners[CORNER_TOP_LEFT]);
1041
1058
xfwmWindowHide (&c->corners[CORNER_TOP_RIGHT]);
1042
1059
xfwmWindowHide (&c->corners[CORNER_BOTTOM_LEFT]);
1085
1102
frameHeight (c) - frameBottom (c), bottom_width, frameBottom (c),
1086
1103
(requires_clearing | width_changed));
1105
if (!xfwmPixmapNone(&frame_pix.pm_sides[SIDE_TOP]))
1107
xfwmWindowSetBG (&c->sides[SIDE_TOP], &frame_pix.pm_sides[SIDE_TOP]);
1108
xfwmWindowShow (&c->sides[SIDE_TOP],
1109
screen_info->corners[CORNER_TOP_LEFT][state].width,
1110
0, top_width, frame_pix.pm_sides[SIDE_TOP].height,
1111
(requires_clearing | width_changed));
1115
xfwmWindowHide (&c->sides[SIDE_TOP]);
1088
1118
xfwmWindowShow (&c->corners[CORNER_TOP_LEFT], 0, 0,
1089
1119
frameTopLeftWidth (c, state),
1090
1120
screen_info->corners[CORNER_TOP_LEFT][state].height,
1113
1143
requires_clearing);
1115
1145
frameSetShape (c, state, &frame_pix, button_x);
1116
1147
xfwmPixmapFree (&frame_pix.pm_title);
1148
xfwmPixmapFree (&frame_pix.pm_sides[SIDE_TOP]);
1117
1149
xfwmPixmapFree (&frame_pix.pm_sides[SIDE_BOTTOM]);
1118
1150
xfwmPixmapFree (&frame_pix.pm_sides[SIDE_LEFT]);
1119
1151
xfwmPixmapFree (&frame_pix.pm_sides[SIDE_RIGHT]);
1183
frameQueueDraw (Client * c)
1215
frameDraw (Client * c, gboolean clear_all)
1217
g_return_if_fail (c);
1219
TRACE ("entering frameDraw for \"%s\" (0x%lx)", c->name, c->window);
1223
FLAG_SET (c->xfwm_flags, XFWM_FLAG_NEEDS_REDRAW);
1229
frameQueueDraw (Client * c, gboolean clear_all)
1185
1231
g_return_if_fail (c);
1187
1233
TRACE ("entering frameQueueDraw for \"%s\" (0x%lx)", c->name, c->window);
1235
/* Reschedule update */
1236
if (c->frame_timeout_id)
1238
frameClearQueueDraw (c);
1242
FLAG_SET (c->xfwm_flags, XFWM_FLAG_NEEDS_REDRAW);
1244
/* Otherwise leave previous schedule */
1189
1245
if (c->frame_timeout_id == 0)
1191
c->frame_timeout_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
1247
c->frame_timeout_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
1192
1248
update_frame_idle_cb, c, NULL);