From 116fc5546f3ab87a6a2650aa7afa4aa5c842a9bd Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 9 Feb 2002 06:54:44 +0000 Subject: [PATCH] put in some kind of distinctive frame for UTILITY, though it's ugly. Also 2002-02-09 Havoc Pennington * src/themes/Atlanta/metacity-theme-1.xml: put in some kind of distinctive frame for UTILITY, though it's ugly. Also put in the borderless look for maximized windows. * src/stack.c (compute_layer): put splash screen in the splash layer * src/stack.h (enum): create a splash screen layer * src/place.c (meta_window_place): center splashscreen, and fix a typo in the centering code * src/window.c (recalc_window_features): disable most features on splash screens * src/screen.c (set_supported_hint): add UTILITY and SPLASHSCREEN hints * src/window.c: add UTILITY, SPLASHSCREEN implementation * src/window.h (enum): add UTILITY, SPLASHSCREEN types * src/theme-parser.c (parse_toplevel_element): parser support for has_title attribute * src/theme.c (meta_frame_layout_get_borders): handle a has_title field in the layout, for utility windows that don't display a title (would be better to be able to shrink the title text, but that's kind of tricky to implement :-/) --- ChangeLog | 32 +++++++++++ src/core.c | 5 ++ src/display.c | 6 +- src/display.h | 2 + src/place.c | 7 ++- src/screen.c | 4 +- src/session.c | 10 ++++ src/stack.c | 4 ++ src/stack.h | 3 +- src/theme-parser.c | 10 ++++ src/theme.c | 7 ++- src/theme.h | 3 + src/themes/Atlanta/metacity-theme-1.xml | 76 +++++++++++++++++++++---- src/window.c | 24 +++++--- src/window.h | 5 +- 15 files changed, 172 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index f03f18139..449bc1f07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2002-02-09 Havoc Pennington + + * src/themes/Atlanta/metacity-theme-1.xml: put in some kind of + distinctive frame for UTILITY, though it's ugly. Also put in the + borderless look for maximized windows. + + * src/stack.c (compute_layer): put splash screen in the splash + layer + + * src/stack.h (enum): create a splash screen layer + + * src/place.c (meta_window_place): center splashscreen, and fix a + typo in the centering code + + * src/window.c (recalc_window_features): disable most features on + splash screens + + * src/screen.c (set_supported_hint): add UTILITY and SPLASHSCREEN + hints + + * src/window.c: add UTILITY, SPLASHSCREEN implementation + + * src/window.h (enum): add UTILITY, SPLASHSCREEN types + + * src/theme-parser.c (parse_toplevel_element): parser support + for has_title attribute + + * src/theme.c (meta_frame_layout_get_borders): handle a has_title + field in the layout, for utility windows that don't display a + title (would be better to be able to shrink the title text, + but that's kind of tricky to implement :-/) + 2002-02-08 Havoc Pennington * src/screen.c (set_supported_hint): add _NET_WM_STATE_HIDDEN diff --git a/src/core.c b/src/core.c index c490d88ce..631f46cdb 100644 --- a/src/core.c +++ b/src/core.c @@ -91,9 +91,14 @@ meta_core_get_frame_type (Display *xdisplay, return META_FRAME_TYPE_MENU; break; + case META_WINDOW_UTILITY: + return META_FRAME_TYPE_UTILITY; + break; + case META_WINDOW_DESKTOP: case META_WINDOW_DOCK: case META_WINDOW_TOOLBAR: + case META_WINDOW_SPLASHSCREEN: /* No frame */ return META_FRAME_TYPE_LAST; break; diff --git a/src/display.c b/src/display.c index 5b969e55c..afda00afa 100644 --- a/src/display.c +++ b/src/display.c @@ -144,7 +144,9 @@ meta_display_open (const char *name) "_WIN_HINTS", "_METACITY_RELOAD_THEME_MESSAGE", "_METACITY_SET_KEYBINDINGS_MESSAGE", - "_NET_WM_STATE_HIDDEN" + "_NET_WM_STATE_HIDDEN", + "_NET_WM_WINDOW_TYPE_UTILITY", + "_NET_WM_WINDOW_TYPE_SPLASHSCREEN" }; Atom atoms[G_N_ELEMENTS(atom_names)]; @@ -243,6 +245,8 @@ meta_display_open (const char *name) display->atom_metacity_reload_theme_message = atoms[47]; display->atom_metacity_set_keybindings_message = atoms[48]; display->atom_net_wm_state_hidden = atoms[49]; + display->atom_net_wm_window_type_utility = atoms[50]; + display->atom_net_wm_window_type_splashscreen = atoms[51]; /* Offscreen unmapped window used for _NET_SUPPORTING_WM_CHECK, * created in screen_new diff --git a/src/display.h b/src/display.h index 746a423c0..71aa1d906 100644 --- a/src/display.h +++ b/src/display.h @@ -109,6 +109,8 @@ struct _MetaDisplay Atom atom_metacity_reload_theme_message; Atom atom_metacity_set_keybindings_message; Atom atom_net_wm_state_hidden; + Atom atom_net_wm_window_type_utility; + Atom atom_net_wm_window_type_splashscreen; /* This is the actual window from focus events, * not the one we last set diff --git a/src/place.c b/src/place.c index 941951550..ae255f730 100644 --- a/src/place.c +++ b/src/place.c @@ -253,7 +253,8 @@ meta_window_place (MetaWindow *window, } if (window->type == META_WINDOW_DIALOG || - window->type == META_WINDOW_MODAL_DIALOG) + window->type == META_WINDOW_MODAL_DIALOG || + window->type == META_WINDOW_SPLASHSCREEN) { /* Center on screen */ int w, h; @@ -263,14 +264,14 @@ meta_window_place (MetaWindow *window, h = window->screen->height; x = (w - window->rect.width) / 2; - y = (y - window->rect.height) / 2; + y = (h - window->rect.height) / 2; meta_topic (META_DEBUG_PLACEMENT, "Centered window %s on screen\n", window->desc); goto done; } - + /* Find windows that matter (not minimized, on same workspace * as placed window, may be shaded - if shaded we pretend it isn't * for placement purposes) diff --git a/src/screen.c b/src/screen.c index eb607ada9..b75ccab27 100644 --- a/src/screen.c +++ b/src/screen.c @@ -78,7 +78,7 @@ set_wm_check_hint (MetaScreen *screen) static int set_supported_hint (MetaScreen *screen) { -#define N_SUPPORTED 24 +#define N_SUPPORTED 26 #define N_WIN_SUPPORTED 1 Atom atoms[N_SUPPORTED]; @@ -106,6 +106,8 @@ set_supported_hint (MetaScreen *screen) atoms[21] = screen->display->atom_net_wm_icon; atoms[22] = screen->display->atom_net_wm_moveresize; atoms[23] = screen->display->atom_net_wm_state_hidden; + atoms[24] = screen->display->atom_net_wm_window_type_utility; + atoms[25] = screen->display->atom_net_wm_window_type_splashscreen; XChangeProperty (screen->display->xdisplay, screen->xroot, screen->display->atom_net_supported, diff --git a/src/session.c b/src/session.c index 8a61fe952..66fa2aa9a 100644 --- a/src/session.c +++ b/src/session.c @@ -588,6 +588,12 @@ window_type_to_string (MetaWindowType type) case META_WINDOW_MENU: return "menu"; break; + case META_WINDOW_SPLASHSCREEN: + return "splashscreen"; + break; + case META_WINDOW_UTILITY: + return "utility"; + break; } return ""; @@ -610,6 +616,10 @@ window_type_from_string (const char *str) return META_WINDOW_TOOLBAR; else if (strcmp (str, "menu") == 0) return META_WINDOW_MENU; + else if (strcmp (str, "utility") == 0) + return META_WINDOW_UTILITY; + else if (strcmp (str, "splashscreen") == 0) + return META_WINDOW_SPLASHSCREEN; else return META_WINDOW_NORMAL; } diff --git a/src/stack.c b/src/stack.c index cf70f12bf..37834aec0 100644 --- a/src/stack.c +++ b/src/stack.c @@ -269,6 +269,10 @@ compute_layer (MetaWindow *window) /* still experimenting here */ window->layer = META_LAYER_NORMAL; break; + + case META_WINDOW_SPLASHSCREEN: + window->layer = META_LAYER_SPLASH; + break; default: window->layer = META_LAYER_NORMAL; diff --git a/src/stack.h b/src/stack.h index 505c63b77..2e61fc0c7 100644 --- a/src/stack.h +++ b/src/stack.h @@ -38,7 +38,8 @@ typedef enum META_LAYER_TOP = 3, META_LAYER_DOCK = 4, META_LAYER_FULLSCREEN = 5, - META_LAYER_LAST = 6 + META_LAYER_SPLASH = 6, + META_LAYER_LAST = 7 } MetaStackLayer; struct _MetaStack diff --git a/src/theme-parser.c b/src/theme-parser.c index c1805f475..331b565d1 100644 --- a/src/theme-parser.c +++ b/src/theme-parser.c @@ -656,11 +656,14 @@ parse_toplevel_element (GMarkupParseContext *context, { const char *name = NULL; const char *parent = NULL; + const char *has_title = NULL; + gboolean has_title_val; MetaFrameLayout *parent_layout; if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "name", &name, "parent", &parent, + "has_title", &has_title, NULL)) return; @@ -672,6 +675,10 @@ parse_toplevel_element (GMarkupParseContext *context, return; } + has_title_val = TRUE; + if (has_title && !parse_boolean (has_title, &has_title_val, context, error)) + return; + if (meta_theme_lookup_layout (info->theme, name)) { set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, @@ -700,6 +707,9 @@ parse_toplevel_element (GMarkupParseContext *context, else info->layout = meta_frame_layout_new (); + if (has_title) /* only if explicit, otherwise inherit */ + info->layout->has_title = has_title_val; + meta_theme_insert_layout (info->theme, name, info->layout); push_state (info, STATE_FRAME_GEOMETRY); diff --git a/src/theme.c b/src/theme.c index ba9c64284..95bf0abb6 100644 --- a/src/theme.c +++ b/src/theme.c @@ -333,6 +333,8 @@ meta_frame_layout_new (void) layout->button_width = -1; layout->button_height = -1; + layout->has_title = TRUE; + init_border (&layout->button_border); return layout; @@ -468,12 +470,15 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout, int *right_width) { int buttons_height, title_height; - + g_return_if_fail (top_height != NULL); g_return_if_fail (bottom_height != NULL); g_return_if_fail (left_width != NULL); g_return_if_fail (right_width != NULL); + if (!layout->has_title) + text_height = 0; + buttons_height = layout->button_height + layout->button_border.top + layout->button_border.bottom; title_height = text_height + diff --git a/src/theme.h b/src/theme.h index 5e8061921..8f9936f29 100644 --- a/src/theme.h +++ b/src/theme.h @@ -78,6 +78,9 @@ struct _MetaFrameLayout /* Space around buttons */ GtkBorder button_border; + + /* Whether title text will be displayed */ + guint has_title : 1; }; diff --git a/src/themes/Atlanta/metacity-theme-1.xml b/src/themes/Atlanta/metacity-theme-1.xml index dd7673259..8913a6f35 100644 --- a/src/themes/Atlanta/metacity-theme-1.xml +++ b/src/themes/Atlanta/metacity-theme-1.xml @@ -23,11 +23,24 @@ - - - - - + + + + + + + + + + + + + + + + + + @@ -136,19 +149,30 @@ x1="1" y1="height-2" x2="width-2" y2="height-2"/> - - + + + + + + + + + + + + + @@ -175,14 +199,25 @@ + + + + + + + + + + + @@ -203,16 +238,25 @@ - + +