On Thu, 14 Aug 2014 at 15:43:57 +0800, David Maciejak wrote:
> This patch is adding miniwindow apercu when the mouse
> is over the miniwindows.
> 
> I added this feature about one month ago and was successfully testing
> it since then.

> To enable it you have to run WPref, in Miscellaneous Ergonomic
> Preferences, check miniwindow apercus.
> Then, you will be able to see a screenshot of the app when the mouse
> is over the miniwindow (I also enclosed a screenshot to show you what
> it looks like).

The paragraph above should be in the patch commit too.

> +static void showApercu(WScreen *scr, int x, int y, int h, int w, char
> *title, Pixmap apercu)
> +{
> + int width;
> + int height;
> + Pixmap pixmap;
> + WMFont *font = scr->info_text_font;
> + int titleHeight = 0;
> + char *shortenTitle = title;
> +
> + if (scr->balloon->contents)
> + XFreePixmap(dpy, scr->balloon->contents);
> +
> + height = h;
> + width  = w;

You can save four lines by using height and width instead of
h and w in the function parameters, can't you? Ie, why have local
variables height and width?

> +
> + if (wPreferences.miniwin_title_balloon) {
> + shortenTitle = ShrinkString(font, title, width - APERCU_BORDER);
> + titleHeight = countLines(shortenTitle) * WMFontHeight(font) + 4;
> + height += titleHeight;
> + }
> +
> +
> + if (x < 0)
> + x = 0;
> + else if (x + width > scr->scr_width - 1)
> + x = scr->scr_width - width - APERCU_BORDER;
> +
> + if (y - height - 2 < 0) {
> + y += wPreferences.icon_size;
> + if (y < 0)
> + y = 0;
> + } else {
> + y -= height + 2;
> + }
> +
> + if (scr->window_title_texture[0])
> + XSetForeground(dpy, scr->draw_gc,
> scr->window_title_texture[0]->any.color.pixel);
> + else
> + XSetForeground(dpy, scr->draw_gc, scr->light_pixel);
> +
> + pixmap = XCreatePixmap(dpy, scr->root_win, width, height, scr->w_depth);
> + XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width, height);
> +
> + if (shortenTitle && wPreferences.miniwin_title_balloon) {
> + drawMultiLineString(scr->wmscreen, pixmap, scr->window_title_color[0], font,
> + APERCU_BORDER, APERCU_BORDER, shortenTitle, strlen(shortenTitle));
> + wfree(shortenTitle);
> + }
> +
> + XCopyArea(dpy, apercu, pixmap, scr->draw_gc,
> + 0, 0, (wPreferences.icon_size - 1 - APERCU_BORDER) * 2,
> + (wPreferences.icon_size - 1 - APERCU_BORDER) * 2,
> + APERCU_BORDER, APERCU_BORDER + titleHeight);
> +
> +#ifdef SHAPED_BALLOON
> + XShapeCombineMask(dpy, scr->balloon->window, ShapeBounding, 0, 0,
> None, ShapeSet);
> +#endif
> + XResizeWindow(dpy, scr->balloon->window, width, height);
> + XMoveWindow(dpy, scr->balloon->window, x, y);
> +
> + XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap);
> +
> + XClearWindow(dpy, scr->balloon->window);
> + XMapRaised(dpy, scr->balloon->window);
> +
> +
> + scr->balloon->contents = pixmap;
> +
> + scr->balloon->mapped = 1;
> +}
> +
>  static void showBalloon(WScreen * scr)
>  {
>   int x, y;
> @@ -389,7 +462,14 @@ static void showBalloon(WScreen * scr)
>   scr->balloon->prevType = 0;
>   return;
>   }
> - showText(scr, x, y, scr->balloon->h, w, scr->balloon->text);
> +
> + if (wPreferences.miniwin_apercu_balloon && scr->balloon->apercu != None)
> + /* used to display either the apercu alone or the apercu and the title */
> + showApercu(scr, x, y, (wPreferences.icon_size - 1) * 2,
> (wPreferences.icon_size - 1) * 2,
> + scr->balloon->text, scr->balloon->apercu);
> + else
> + if (wPreferences.miniwin_title_balloon)

and here you can fix the above line already (from your next patch)

> + showText(scr, x, y, scr->balloon->h, w, scr->balloon->text);
>  }


Can you please resend the patch?


-- 
To unsubscribe, send mail to [email protected].

Reply via email to