[metacity] add meta_window_get_frame_type()
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] add meta_window_get_frame_type()
- Date: Sat, 4 Mar 2017 16:50:11 +0000 (UTC)
commit e11d8767f740a74983fe557d190a4a60530b192e
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Thu Nov 11 16:12:11 2010 -0500
add meta_window_get_frame_type()
Add a public function to get the frame type for a window; the
code is refactored from existing code in core.c.
https://bugzilla.gnome.org/show_bug.cgi?id=592382
src/core/core.c | 67 +---------------------------------------
src/core/window-private.h | 2 +
src/core/window.c | 74 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 78 insertions(+), 65 deletions(-)
---
diff --git a/src/core/core.c b/src/core/core.c
index ce68f0c..73c3ac0 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -115,71 +115,8 @@ meta_core_get (Display *xdisplay,
*((MetaFrameFlags*)answer) = meta_frame_get_flags (window->frame);
break;
case META_CORE_GET_FRAME_TYPE:
- {
- MetaFrameType base_type = META_FRAME_TYPE_LAST;
-
- switch (window->type)
- {
- case META_WINDOW_NORMAL:
- base_type = META_FRAME_TYPE_NORMAL;
- break;
-
- case META_WINDOW_DIALOG:
- base_type = META_FRAME_TYPE_DIALOG;
- break;
-
- case META_WINDOW_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:
- base_type = META_FRAME_TYPE_MENU;
- break;
-
- case META_WINDOW_UTILITY:
- base_type = META_FRAME_TYPE_UTILITY;
- break;
-
- case META_WINDOW_DESKTOP:
- case META_WINDOW_DOCK:
- case META_WINDOW_TOOLBAR:
- case META_WINDOW_SPLASHSCREEN:
- case META_WINDOW_DROPDOWN_MENU:
- case META_WINDOW_POPUP_MENU:
- case META_WINDOW_TOOLTIP:
- case META_WINDOW_NOTIFICATION:
- case META_WINDOW_COMBO:
- case META_WINDOW_DND:
- case META_WINDOW_OVERRIDE_OTHER:
- /* No frame */
- base_type = META_FRAME_TYPE_LAST;
- break;
-
- default:
- break;
- }
-
- if (base_type == META_FRAME_TYPE_LAST)
- {
- /* can't add border if undecorated */
- *((MetaFrameType*)answer) = META_FRAME_TYPE_LAST;
- }
- else if (window->border_only && base_type != META_FRAME_TYPE_ATTACHED)
- {
- /* override base frame type */
- *((MetaFrameType*)answer) = META_FRAME_TYPE_BORDER;
- }
- else
- {
- *((MetaFrameType*)answer) = base_type;
- }
-
- break;
- }
+ *((MetaFrameType*)answer) = meta_window_get_frame_type (window);
+ break;
case META_CORE_GET_MINI_ICON:
*((GdkPixbuf**)answer) = window->mini_icon;
break;
diff --git a/src/core/window-private.h b/src/core/window-private.h
index ad9867d..1dd6600 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -707,4 +707,6 @@ void meta_window_propagate_focus_appearance (MetaWindow *window,
gboolean meta_window_should_attach_to_parent (MetaWindow *window);
+MetaFrameType meta_window_get_frame_type (MetaWindow *window);
+
#endif
diff --git a/src/core/window.c b/src/core/window.c
index 700f6c1..c53be0b 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -8909,6 +8909,80 @@ meta_window_is_client_decorated (MetaWindow *window)
}
/**
+ * meta_window_get_frame_type:
+ * @window: a #MetaWindow
+ *
+ * Gets the type of window decorations that should be used for this window.
+ *
+ * Return value: the frame type
+ */
+MetaFrameType
+meta_window_get_frame_type (MetaWindow *window)
+{
+ MetaFrameType base_type = META_FRAME_TYPE_LAST;
+
+ switch (window->type)
+ {
+ case META_WINDOW_NORMAL:
+ base_type = META_FRAME_TYPE_NORMAL;
+ break;
+
+ case META_WINDOW_DIALOG:
+ base_type = META_FRAME_TYPE_DIALOG;
+ break;
+
+ case META_WINDOW_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:
+ base_type = META_FRAME_TYPE_MENU;
+ break;
+
+ case META_WINDOW_UTILITY:
+ base_type = META_FRAME_TYPE_UTILITY;
+ break;
+
+ case META_WINDOW_DESKTOP:
+ case META_WINDOW_DOCK:
+ case META_WINDOW_TOOLBAR:
+ case META_WINDOW_SPLASHSCREEN:
+ case META_WINDOW_DROPDOWN_MENU:
+ case META_WINDOW_POPUP_MENU:
+ case META_WINDOW_TOOLTIP:
+ case META_WINDOW_NOTIFICATION:
+ case META_WINDOW_COMBO:
+ case META_WINDOW_DND:
+ case META_WINDOW_OVERRIDE_OTHER:
+ /* No frame */
+ base_type = META_FRAME_TYPE_LAST;
+ break;
+
+ default:
+ break;
+ }
+
+ if (base_type == META_FRAME_TYPE_LAST)
+ {
+ /* can't add border if undecorated */
+ return META_FRAME_TYPE_LAST;
+ }
+ else if (window->border_only && base_type != META_FRAME_TYPE_ATTACHED)
+ {
+ /* override base frame type */
+ return META_FRAME_TYPE_BORDER;
+ }
+ else
+ {
+ return base_type;
+ }
+}
+
+/**
* meta_window_get_frame_bounds:
*
* Gets a region representing the outer bounds of the window's frame.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]