From 2218b79143446af904fe1c0007d3458f59e4e995 Mon Sep 17 00:00:00 2001 From: Rob Adams Date: Sat, 8 Nov 2003 04:43:18 +0000 Subject: [PATCH] Try harder to find a theme in the event that the theme in the preference 2003-11-07 Rob Adams * src/main.c (main): Try harder to find a theme in the event that the theme in the preference cannot be found. Patch from Marcin Krzyzanowski. See #125815. * src/place.c (meta_window_place): use "visual" centering for dialog placement and clip new dialogs to an xinerama workspace. Fix for #118336. --- ChangeLog | 10 ++++++++++ src/main.c | 32 +++++++++++++++++++++++++------- src/place.c | 19 ++++++++++++++----- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index e2e83cc55..ce65d7bf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-11-07 Rob Adams + + * src/main.c (main): Try harder to find a theme in the event that + the theme in the preference cannot be found. Patch from Marcin + Krzyzanowski. See #125815. + + * src/place.c (meta_window_place): use "visual" centering for + dialog placement and clip new dialogs to an xinerama workspace. + Fix for #118336. + 2003-10-30 Havoc Pennington * src/menu.c (meta_window_menu_new): patch to avoid creating diff --git a/src/main.c b/src/main.c index d385a929b..4b3f26ed8 100644 --- a/src/main.c +++ b/src/main.c @@ -421,18 +421,36 @@ main (int argc, char **argv) meta_ui_set_current_theme (meta_prefs_get_theme (), FALSE); - /* Try some panic stuff, this is lame but we really - * don't want users to lose their WM :-/ + /* Try to find some theme that'll work if the theme preference + * doesn't exist. First try Simple (the default theme) then just + * try anything in the themes directory. */ if (!meta_ui_have_a_theme ()) meta_ui_set_current_theme ("Simple", FALSE); if (!meta_ui_have_a_theme ()) - meta_ui_set_current_theme ("Atlanta", FALSE); - - if (!meta_ui_have_a_theme ()) - meta_ui_set_current_theme ("Crux", FALSE); - + { + gchar *dir_entry = NULL; + GError *err = NULL; + GDir *themes_dir = NULL; + + if (!(themes_dir = g_dir_open (METACITY_DATADIR"/themes", 0, &err))) + { + meta_fatal (_("Failed to scan themes directory : %s\n"), err->message); + g_error_free (err); + } + else + { + while (((dir_entry = g_dir_read_name (themes_dir)) != NULL) && + (!meta_ui_have_a_theme ())) + { + meta_ui_set_current_theme (dir_entry, FALSE); + } + + g_dir_close (themes_dir); + } + } + if (!meta_ui_have_a_theme ()) meta_fatal (_("Could not find a theme! Be sure %s exists and contains the usual themes."), METACITY_DATADIR"/themes"); diff --git a/src/place.c b/src/place.c index df4800160..5911ddb78 100644 --- a/src/place.c +++ b/src/place.c @@ -668,6 +668,7 @@ meta_window_place (MetaWindow *window, if (parent) { int w; + MetaRectangle area; meta_window_get_position (parent, &x, &y); w = parent->rect.width; @@ -677,17 +678,25 @@ meta_window_place (MetaWindow *window, /* center of child over center of parent */ x -= window->rect.width / 2; - /* put child down 1/5 or so from the top of parent, unless - * it makes us have more of parent showing above child than - * below + /* "visually" center window over parent, leaving twice as + * much space below as on top. */ - if (window->rect.height <= (parent->rect.height - (parent->rect.height / 5) * 2)) - y += parent->rect.height / 5; + y += (parent->rect.height - window->rect.height)/3; /* put top of child's frame, not top of child's client */ if (fgeom) y += fgeom->top_height; + /* clip to xinerama of parent*/ + meta_window_get_work_area_current_xinerama (parent, &area); + + if (x + window->rect.width > area.x + area.width) + x = area.x + area.width - window->rect.width; + if (y + window->rect.height > area.y + area.height) + y = area.y + area.height - window->rect.height; + if (x < area.x) x = area.x; + if (y < area.y) y = area.y; + meta_topic (META_DEBUG_PLACEMENT, "Centered window %s over transient parent\n", window->desc);