- configure menuwin with the screen, then create the xft drawable using
the menu window since that's the only place on which we draw - elminate the need to change the drawable on every font draw
This commit is contained in:
parent
85d547bcc5
commit
bd38e60d03
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD: calmwm.h,v 1.205 2013/05/19 23:38:21 okan Exp $
|
||||
* $OpenBSD: calmwm.h,v 1.206 2013/05/20 20:21:04 okan Exp $
|
||||
*/
|
||||
|
||||
#ifndef _CALMWM_H_
|
||||
@ -426,7 +426,6 @@ struct menu *menu_filter(struct screen_ctx *, struct menu_q *,
|
||||
char *, char *, int,
|
||||
void (*)(struct menu_q *, struct menu_q *, char *),
|
||||
void (*)(struct menu *, int));
|
||||
void menu_init(struct screen_ctx *);
|
||||
void menuq_clear(struct menu_q *);
|
||||
|
||||
int parse_config(const char *, struct conf *);
|
||||
@ -463,7 +462,7 @@ void xu_ptr_ungrab(void);
|
||||
void xu_sendmsg(Window, Atom, long);
|
||||
void xu_set_wm_state(Window win, int);
|
||||
void xu_xft_draw(struct screen_ctx *, const char *,
|
||||
Drawable, int, int, int);
|
||||
int, int, int);
|
||||
int xu_xft_width(XftFont *, const char *, int);
|
||||
void xu_xorcolor(XftColor, XftColor, XftColor *);
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD: conf.c,v 1.128 2013/05/19 23:16:29 okan Exp $
|
||||
* $OpenBSD: conf.c,v 1.129 2013/05/20 20:21:04 okan Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -103,11 +103,6 @@ conf_screen(struct screen_ctx *sc)
|
||||
|
||||
sc->gap = Conf.gap;
|
||||
|
||||
sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin,
|
||||
sc->visual, sc->colormap);
|
||||
if (sc->xftdraw == NULL)
|
||||
errx(1, "XftDrawCreate");
|
||||
|
||||
sc->xftfont = XftFontOpenName(X_Dpy, sc->which, Conf.font);
|
||||
if (sc->xftfont == NULL)
|
||||
errx(1, "XftFontOpenName");
|
||||
@ -134,6 +129,16 @@ conf_screen(struct screen_ctx *sc)
|
||||
if (!XftColorAllocValue(X_Dpy, sc->visual, sc->colormap,
|
||||
&xc.color, &sc->xftcolor[CWM_COLOR_MENU_FONT_SEL]))
|
||||
warnx("XftColorAllocValue: '%s'", Conf.color[i]);
|
||||
|
||||
sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1,
|
||||
Conf.bwidth,
|
||||
sc->xftcolor[CWM_COLOR_MENU_FG].pixel,
|
||||
sc->xftcolor[CWM_COLOR_MENU_BG].pixel);
|
||||
|
||||
sc->xftdraw = XftDrawCreate(X_Dpy, sc->menuwin,
|
||||
sc->visual, sc->colormap);
|
||||
if (sc->xftdraw == NULL)
|
||||
errx(1, "XftDrawCreate");
|
||||
}
|
||||
|
||||
static struct {
|
||||
|
@ -16,7 +16,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD: menu.c,v 1.63 2013/05/20 20:04:36 okan Exp $
|
||||
* $OpenBSD: menu.c,v 1.64 2013/05/20 20:21:04 okan Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -76,15 +76,6 @@ static int menu_calc_entry(struct menu_ctx *, int, int);
|
||||
static struct menu *menu_complete_path(struct menu_ctx *);
|
||||
static int menu_keycode(XKeyEvent *, enum ctltype *, char *);
|
||||
|
||||
void
|
||||
menu_init(struct screen_ctx *sc)
|
||||
{
|
||||
sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1,
|
||||
Conf.bwidth,
|
||||
sc->xftcolor[CWM_COLOR_MENU_FG].pixel,
|
||||
sc->xftcolor[CWM_COLOR_MENU_BG].pixel);
|
||||
}
|
||||
|
||||
struct menu *
|
||||
menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
||||
char *initial, int flags,
|
||||
@ -417,7 +408,7 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
|
||||
mc->width, mc->height);
|
||||
|
||||
if (mc->hasprompt) {
|
||||
xu_xft_draw(sc, mc->dispstr, sc->menuwin, CWM_COLOR_MENU_FONT,
|
||||
xu_xft_draw(sc, mc->dispstr, CWM_COLOR_MENU_FONT,
|
||||
0, sc->xftfont->ascent);
|
||||
n = 1;
|
||||
} else
|
||||
@ -432,7 +423,7 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
|
||||
if (mc->y + y > xine.h)
|
||||
break;
|
||||
|
||||
xu_xft_draw(sc, text, sc->menuwin, CWM_COLOR_MENU_FONT, 0, y);
|
||||
xu_xft_draw(sc, text, CWM_COLOR_MENU_FONT, 0, y);
|
||||
n++;
|
||||
}
|
||||
if (mc->hasprompt && n > 1 && (mc->searchstr[0] != '\0')) {
|
||||
@ -465,7 +456,7 @@ menu_draw_entry(struct menu_ctx *mc, struct menu_q *resultq,
|
||||
(sc->xftfont->height + 1) * entry, mc->width,
|
||||
(sc->xftfont->height + 1) + sc->xftfont->descent);
|
||||
color = active ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT;
|
||||
xu_xft_draw(sc, text, sc->menuwin, color,
|
||||
xu_xft_draw(sc, text, color,
|
||||
0, (sc->xftfont->height + 1) * entry + sc->xftfont->ascent + 1);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD: mousefunc.c,v 1.51 2013/05/19 23:38:21 okan Exp $
|
||||
* $OpenBSD: mousefunc.c,v 1.52 2013/05/20 20:21:04 okan Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -63,7 +63,7 @@ mousefunc_sweep_draw(struct client_ctx *cc)
|
||||
XMapWindow(X_Dpy, sc->menuwin);
|
||||
XClearWindow(X_Dpy, sc->menuwin);
|
||||
|
||||
xu_xft_draw(sc, asize, sc->menuwin, CWM_COLOR_MENU_FONT,
|
||||
xu_xft_draw(sc, asize, CWM_COLOR_MENU_FONT,
|
||||
0, sc->xftfont->ascent + 1);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD: screen.c,v 1.50 2013/05/11 22:01:07 okan Exp $
|
||||
* $OpenBSD: screen.c,v 1.51 2013/05/20 20:21:04 okan Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -56,7 +56,6 @@ screen_init(int which)
|
||||
TAILQ_INIT(&sc->mruq);
|
||||
|
||||
group_init(sc);
|
||||
menu_init(sc);
|
||||
|
||||
rootattr.cursor = Cursor_normal;
|
||||
rootattr.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|
|
||||
|
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD: xutil.c,v 1.63 2013/05/19 23:38:21 okan Exp $
|
||||
* $OpenBSD: xutil.c,v 1.64 2013/05/20 20:21:04 okan Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -442,10 +442,8 @@ xu_xft_width(XftFont *xftfont, const char *text, int len)
|
||||
}
|
||||
|
||||
void
|
||||
xu_xft_draw(struct screen_ctx *sc, const char *text,
|
||||
Drawable d, int color, int x, int y)
|
||||
xu_xft_draw(struct screen_ctx *sc, const char *text, int color, int x, int y)
|
||||
{
|
||||
XftDrawChange(sc->xftdraw, d);
|
||||
XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor[color], sc->xftfont,
|
||||
x, y, (const FcChar8*)text, strlen(text));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user