From 1a27b34160aa15ba7431162d72af499987bf96cd Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 14 Sep 2009 12:59:10 +0100 Subject: [PATCH] Constrain switching workspace name to one head. When switching workspaces, force the name to be shown entirely within one head of a Xinerama display. Previously the name would span heads if set to TOP, CENTER or BOTTOM alignment, and was hence hard to read when the display comprised an even number of heads. --- src/workspace.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/workspace.c b/src/workspace.c index 2114ff4a..277f746d 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -262,6 +262,11 @@ static void showWorkspaceName(WScreen * scr, int workspace) char *name = scr->workspaces[workspace]->name; int len = strlen(name); int x, y; +#ifdef XINERAMA + int head; + WMRect rect; + int xx, yy; +#endif if (wPreferences.workspace_name_display_position == WD_NONE || scr->workspace_count < 2) { return; @@ -286,13 +291,34 @@ static void showWorkspaceName(WScreen * scr, int workspace) w = WMWidthOfString(scr->workspace_name_font, name, len); h = WMFontHeight(scr->workspace_name_font); +#ifdef XINERAMA + head = wGetHeadForPointerLocation(scr); + rect = wGetRectForHead(scr, head); + if (scr->xine_info.count) { + xx = rect.pos.x + (scr->xine_info.screens[head].size.width - (w+4))/2; + yy = rect.pos.y + (scr->xine_info.screens[head].size.height - (h+4))/2; + } + else { + xx = (scr->scr_width - (w+4))/2; + yy = (scr->scr_height - (h+4))/2; + } +#endif + switch (wPreferences.workspace_name_display_position) { case WD_TOP: +#ifdef XINERAMA + px = xx; +#else px = (scr->scr_width - (w + 4)) / 2; +#endif py = 0; break; case WD_BOTTOM: +#ifdef XINERAMA + px = xx; +#else px = (scr->scr_width - (w + 4)) / 2; +#endif py = scr->scr_height - (h + 4); break; case WD_TOPLEFT: @@ -313,8 +339,13 @@ static void showWorkspaceName(WScreen * scr, int workspace) break; case WD_CENTER: default: +#ifdef XINERAMA + px = xx; + py = yy; +#else px = (scr->scr_width - (w + 4)) / 2; py = (scr->scr_height - (h + 4)) / 2; +#endif break; } XResizeWindow(dpy, scr->workspace_name, w + 4, h + 4);