Skip to content

Commit c9c3f85

Browse files
owtaylorvkareh
authored andcommitted
Add frame type for attached modal dialogs
Add a new frame type META_FRAME_TYPE_ATTACHED which is used for attached modal dialogs. The theme format version is bumped to 3.2, and attached windows can have borders defined in a metacity-theme-3.xml as: <window version=">= 3.2" type="attached" style_set="[name]"/> If no style is defined for "attached", drawing will fall back to the "border" type. https://bugzilla.gnome.org/show_bug.cgi?id=592382 NOTE: Patch copied from mutter and adapted for metacity.
1 parent 37fecf4 commit c9c3f85

File tree

6 files changed

+34
-6
lines changed

6 files changed

+34
-6
lines changed

doc/theme-format.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ This document has separate sections for each format version. You may
2222
want to read the document in reverse order, since the base features
2323
are discussed under version 1.
2424

25+
New Features in Theme Format Version 3.2
26+
========================================
27+
28+
A new window type 'attached' is added for modal dialogs which are
29+
attached to their parent window. (When the attach_modal_dialogs preference
30+
is turned on.) If no style is defined for the 'attached' window type,
31+
the 'border' window type will be used instead.
32+
2533
New Features in Theme Format Version 3.1
2634
========================================
2735

src/core/core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ meta_core_get (Display *xdisplay,
131131
break;
132132

133133
case META_WINDOW_MODAL_DIALOG:
134-
base_type = META_FRAME_TYPE_MODAL_DIALOG;
134+
if (meta_prefs_get_attach_modal_dialogs () &&
135+
meta_window_get_transient_for (window) != NULL)
136+
base_type = META_FRAME_TYPE_ATTACHED;
137+
else
138+
base_type = META_FRAME_TYPE_MODAL_DIALOG;
135139
break;
136140

137141
case META_WINDOW_MENU:
@@ -157,7 +161,7 @@ meta_core_get (Display *xdisplay,
157161
/* can't add border if undecorated */
158162
*((MetaFrameType*)answer) = META_FRAME_TYPE_LAST;
159163
}
160-
else if (window->border_only)
164+
else if (window->border_only && base_type != META_FRAME_TYPE_ATTACHED)
161165
{
162166
/* override base frame type */
163167
*((MetaFrameType*)answer) = META_FRAME_TYPE_BORDER;

src/include/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ typedef enum
208208
META_FRAME_TYPE_UTILITY,
209209
META_FRAME_TYPE_MENU,
210210
META_FRAME_TYPE_BORDER,
211+
META_FRAME_TYPE_ATTACHED,
211212
META_FRAME_TYPE_LAST
212213
} MetaFrameType;
213214

src/ui/theme-parser.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* look out for.
3939
*/
4040
#define THEME_MAJOR_VERSION 3
41-
#define THEME_MINOR_VERSION 1
41+
#define THEME_MINOR_VERSION 2
4242
#define THEME_VERSION (1000 * THEME_MAJOR_VERSION + THEME_MINOR_VERSION)
4343

4444
#define MARCO_THEME_FILENAME_FORMAT "metacity-theme-%d.xml"
@@ -1277,7 +1277,8 @@ parse_toplevel_element (GMarkupParseContext *context,
12771277

12781278
type = meta_frame_type_from_string (type_name);
12791279

1280-
if (type == META_FRAME_TYPE_LAST)
1280+
if (type == META_FRAME_TYPE_LAST ||
1281+
(type == META_FRAME_TYPE_ATTACHED && peek_required_version (info) < 3002))
12811282
{
12821283
set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
12831284
_("Unknown type \"%s\" on <%s> element"),

src/ui/theme-viewer.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ get_window_contents (MetaFrameType type,
427427
*title = _("Border");
428428
return border_only_contents ();
429429

430+
case META_FRAME_TYPE_ATTACHED:
431+
*title = _("Attached Modal Dialog");
432+
return dialog_contents ();
433+
430434
case META_FRAME_TYPE_LAST:
431435
g_assert_not_reached ();
432436
break;
@@ -474,6 +478,9 @@ get_window_flags (MetaFrameType type)
474478
case META_FRAME_TYPE_BORDER:
475479
break;
476480

481+
case META_FRAME_TYPE_ATTACHED:
482+
break;
483+
477484
case META_FRAME_TYPE_LAST:
478485
g_assert_not_reached ();
479486
break;

src/ui/theme.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5193,7 +5193,7 @@ meta_theme_validate (MetaTheme *theme,
51935193
}
51945194

51955195
for (i = 0; i < (int)META_FRAME_TYPE_LAST; i++)
5196-
if (theme->style_sets_by_type[i] == NULL)
5196+
if (i != (int)META_FRAME_TYPE_ATTACHED && theme->style_sets_by_type[i] == NULL)
51975197
{
51985198
g_set_error (error, META_THEME_ERROR, META_THEME_ERROR_FAILED,
51995199
_("No frame style set for window type \"%s\" in theme \"%s\", add a <window type=\"%s\" style_set=\"whatever\"/> element"),
@@ -5271,7 +5271,10 @@ theme_get_style (MetaTheme *theme,
52715271

52725272
style_set = theme->style_sets_by_type[type];
52735273

5274-
/* Right now the parser forces a style set for all types,
5274+
if (style_set == NULL && type == META_FRAME_TYPE_ATTACHED)
5275+
style_set = theme->style_sets_by_type[META_FRAME_TYPE_BORDER];
5276+
5277+
/* Right now the parser forces a style set for all other types,
52755278
* but this fallback code is here in case I take that out.
52765279
*/
52775280
if (style_set == NULL)
@@ -6229,6 +6232,8 @@ meta_frame_type_from_string (const char *str)
62296232
return META_FRAME_TYPE_MENU;
62306233
else if (strcmp ("border", str) == 0)
62316234
return META_FRAME_TYPE_BORDER;
6235+
else if (strcmp ("attached", str) == 0)
6236+
return META_FRAME_TYPE_ATTACHED;
62326237
#if 0
62336238
else if (strcmp ("toolbar", str) == 0)
62346239
return META_FRAME_TYPE_TOOLBAR;
@@ -6254,6 +6259,8 @@ meta_frame_type_to_string (MetaFrameType type)
62546259
return "menu";
62556260
case META_FRAME_TYPE_BORDER:
62566261
return "border";
6262+
case META_FRAME_TYPE_ATTACHED:
6263+
return "attached";
62576264
#if 0
62586265
case META_FRAME_TYPE_TOOLBAR:
62596266
return "toolbar";

0 commit comments

Comments
 (0)