[metacity] Add frame type for attached modal dialogs



commit b599e6bc267c95513d62a569a03290ea20cbe11d
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Sep 27 17:06:36 2014 +0300

    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.

 doc/theme-format.txt  |    8 ++++++++
 src/core/core.c       |    8 ++++++--
 src/include/common.h  |    1 +
 src/ui/theme-parser.c |    5 +++--
 src/ui/theme-viewer.c |   11 +++++++++--
 src/ui/theme.c        |   11 +++++++++--
 6 files changed, 36 insertions(+), 8 deletions(-)
---
diff --git a/doc/theme-format.txt b/doc/theme-format.txt
index 54138e6..fb96153 100644
--- a/doc/theme-format.txt
+++ b/doc/theme-format.txt
@@ -22,6 +22,14 @@ This document has separate sections for each format version. You may
 want to read the document in reverse order, since the base features
 are discussed under version 1.
 
+New Features in Theme Format Version 3.2
+========================================
+
+A new window type 'attached' is added for modal dialogs which are
+attached to their parent window. (When the attach_modal_dialogs preference
+is turned on.) If no style is defined for the 'attached' window type,
+the 'border' window type will be used instead.
+
 New Features in Theme Format Version 3.1
 ========================================
 
diff --git a/src/core/core.c b/src/core/core.c
index 509b352..68ba70a 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -129,7 +129,11 @@ meta_core_get (Display *xdisplay,
               break;
 
             case META_WINDOW_MODAL_DIALOG:
-              base_type = META_FRAME_TYPE_MODAL_DIALOG;
+              if (meta_prefs_get_attach_modal_dialogs () &&
+                  meta_window_get_transient_for (window) != NULL)
+                base_type = META_FRAME_TYPE_ATTACHED;
+              else
+                base_type = META_FRAME_TYPE_MODAL_DIALOG;
               break;
 
             case META_WINDOW_MENU:
@@ -155,7 +159,7 @@ meta_core_get (Display *xdisplay,
               /* can't add border if undecorated */
               *((MetaFrameType*)answer) = META_FRAME_TYPE_LAST; 
             }
-          else if (window->border_only)
+          else if (window->border_only && base_type != META_FRAME_TYPE_ATTACHED)
             {
               /* override base frame type */
               *((MetaFrameType*)answer) = META_FRAME_TYPE_BORDER; 
diff --git a/src/include/common.h b/src/include/common.h
index c5171d1..0d41ada 100644
--- a/src/include/common.h
+++ b/src/include/common.h
@@ -169,6 +169,7 @@ typedef enum
   META_FRAME_TYPE_UTILITY,
   META_FRAME_TYPE_MENU,
   META_FRAME_TYPE_BORDER,
+  META_FRAME_TYPE_ATTACHED,
   META_FRAME_TYPE_LAST
 } MetaFrameType;
 
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c
index 10c6944..4c689e4 100644
--- a/src/ui/theme-parser.c
+++ b/src/ui/theme-parser.c
@@ -36,7 +36,7 @@
  * look out for.
  */
 #define THEME_MAJOR_VERSION 3
-#define THEME_MINOR_VERSION 1
+#define THEME_MINOR_VERSION 2
 #define THEME_VERSION (1000 * THEME_MAJOR_VERSION + THEME_MINOR_VERSION)
 
 #define METACITY_THEME_FILENAME_FORMAT "metacity-theme-%d.xml"
@@ -1271,7 +1271,8 @@ parse_toplevel_element (GMarkupParseContext  *context,
 
       type = meta_frame_type_from_string (type_name);
 
-      if (type == META_FRAME_TYPE_LAST)
+      if (type == META_FRAME_TYPE_LAST ||
+         (type == META_FRAME_TYPE_ATTACHED && peek_required_version (info) < 3002))
         {
           set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
                      _("Unknown type \"%s\" on <%s> element"),
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index 0ddd6ee..24e3f5d 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -417,7 +417,11 @@ get_window_contents (MetaFrameType  type,
     case META_FRAME_TYPE_BORDER:
       *title = _("Border");
       return border_only_contents ();
-      
+
+    case META_FRAME_TYPE_ATTACHED:
+      *title = _("Attached Modal Dialog");
+      return dialog_contents ();
+
     case META_FRAME_TYPE_LAST:
       g_assert_not_reached ();
       break;
@@ -464,7 +468,10 @@ get_window_flags (MetaFrameType type)
 
     case META_FRAME_TYPE_BORDER:
       break;
-      
+
+    case META_FRAME_TYPE_ATTACHED:
+      break;
+
     case META_FRAME_TYPE_LAST:
       g_assert_not_reached ();
       break;
diff --git a/src/ui/theme.c b/src/ui/theme.c
index a96a612..09dd082 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -5137,7 +5137,7 @@ meta_theme_validate (MetaTheme *theme,
     }
 
   for (i = 0; i < (int)META_FRAME_TYPE_LAST; i++)
-    if (theme->style_sets_by_type[i] == NULL)
+    if (i != (int)META_FRAME_TYPE_ATTACHED && theme->style_sets_by_type[i] == NULL)
       {
         g_set_error (error, META_THEME_ERROR, META_THEME_ERROR_FAILED,
                      _("No frame style set for window type \"%s\" in theme \"%s\", add a <window type=\"%s\" 
style_set=\"whatever\"/> element"),
@@ -5215,7 +5215,10 @@ theme_get_style (MetaTheme     *theme,
 
   style_set = theme->style_sets_by_type[type];
 
-  /* Right now the parser forces a style set for all types,
+  if (style_set == NULL && type == META_FRAME_TYPE_ATTACHED)
+    style_set = theme->style_sets_by_type[META_FRAME_TYPE_BORDER];
+
+  /* Right now the parser forces a style set for all other types,
    * but this fallback code is here in case I take that out.
    */
   if (style_set == NULL)
@@ -6066,6 +6069,8 @@ meta_frame_type_from_string (const char *str)
     return META_FRAME_TYPE_MENU;
   else if (strcmp ("border", str) == 0)
     return META_FRAME_TYPE_BORDER;
+  else if (strcmp ("attached", str) == 0)
+    return META_FRAME_TYPE_ATTACHED;
 #if 0
   else if (strcmp ("toolbar", str) == 0)
     return META_FRAME_TYPE_TOOLBAR;
@@ -6091,6 +6096,8 @@ meta_frame_type_to_string (MetaFrameType type)
       return "menu";
     case META_FRAME_TYPE_BORDER:
       return "border";
+    case META_FRAME_TYPE_ATTACHED:
+      return "attached";
 #if 0
     case META_FRAME_TYPE_TOOLBAR:
       return "toolbar";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]