Xnest: load fonts via xcb
FIXME: support xf86bigfont extension Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
2ed4c16b36
commit
43b225c28c
|
@ -28,6 +28,7 @@ is" without express or implied warranty.
|
||||||
#include "scrnintstr.h"
|
#include "scrnintstr.h"
|
||||||
|
|
||||||
#include "Xnest.h"
|
#include "Xnest.h"
|
||||||
|
#include "xnest-xcb.h"
|
||||||
|
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "XNFont.h"
|
#include "XNFont.h"
|
||||||
|
@ -65,12 +66,30 @@ xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont)
|
||||||
if (!name)
|
if (!name)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
void *priv = calloc(1, sizeof(xnestPrivFont));
|
xnestPrivFont* priv = calloc(1, sizeof(xnestPrivFont));
|
||||||
xfont2_font_set_private(pFont, xnestFontPrivateIndex, priv);
|
xfont2_font_set_private(pFont, xnestFontPrivateIndex, priv);
|
||||||
|
|
||||||
xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name);
|
priv->font_id = xcb_generate_id(xnestUpstreamInfo.conn);
|
||||||
|
xcb_open_font(xnestUpstreamInfo.conn, priv->font_id, strlen(name), name);
|
||||||
|
|
||||||
if (!xnestFontStruct(pFont))
|
xcb_generic_error_t *err = NULL;
|
||||||
|
priv->font_reply = xcb_query_font_reply(
|
||||||
|
xnestUpstreamInfo.conn,
|
||||||
|
xcb_query_font(xnestUpstreamInfo.conn, priv->font_id),
|
||||||
|
&err);
|
||||||
|
if (err) {
|
||||||
|
ErrorF("failed to query font \"%s\": %d", name, err->error_code);
|
||||||
|
free(err);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!priv->font_reply) {
|
||||||
|
ErrorF("failed to query font \"%s\": no reply", name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
priv->chars_len = xcb_query_font_char_infos_length(priv->font_reply);
|
||||||
|
priv->chars = xcb_query_font_char_infos(priv->font_reply);
|
||||||
|
|
||||||
|
if (!(xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -80,8 +99,9 @@ Bool
|
||||||
xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
|
xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
|
||||||
{
|
{
|
||||||
if (xnestFontPriv(pFont)) {
|
if (xnestFontPriv(pFont)) {
|
||||||
if (xnestFontStruct(pFont))
|
xcb_close_font(xnestUpstreamInfo.conn, xnestFontPriv(pFont)->font_id);
|
||||||
XFreeFont(xnestDisplay, xnestFontStruct(pFont));
|
if (xnestFontPriv(pFont)->font_struct)
|
||||||
|
XFreeFont(xnestDisplay, xnestFontPriv(pFont)->font_struct);
|
||||||
free(xnestFontPriv(pFont));
|
free(xnestFontPriv(pFont));
|
||||||
xfont2_font_set_private(pFont, xnestFontPrivateIndex, NULL);
|
xfont2_font_set_private(pFont, xnestFontPrivateIndex, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ xnestChangeGC(GCPtr pGC, unsigned long mask)
|
||||||
values.tile_stipple_origin_y = pGC->patOrg.y;
|
values.tile_stipple_origin_y = pGC->patOrg.y;
|
||||||
|
|
||||||
if (mask & GCFont)
|
if (mask & GCFont)
|
||||||
values.font = xnestFont(pGC->font);
|
values.font = xnestFontPriv(pGC->font)->font_id;
|
||||||
|
|
||||||
if (mask & GCSubwindowMode)
|
if (mask & GCSubwindowMode)
|
||||||
values.subwindow_mode = pGC->subWindowMode;
|
values.subwindow_mode = pGC->subWindowMode;
|
||||||
|
|
|
@ -17,9 +17,7 @@ is" without express or implied warranty.
|
||||||
|
|
||||||
#include <X11/Xdefs.h>
|
#include <X11/Xdefs.h>
|
||||||
|
|
||||||
typedef struct {
|
#include <xcb/xcb.h>
|
||||||
XFontStruct *font_struct;
|
|
||||||
} xnestPrivFont;
|
|
||||||
|
|
||||||
extern int xnestFontPrivateIndex;
|
extern int xnestFontPrivateIndex;
|
||||||
|
|
||||||
|
@ -28,8 +26,6 @@ extern int xnestFontPrivateIndex;
|
||||||
|
|
||||||
#define xnestFontStruct(pFont) (xnestFontPriv(pFont)->font_struct)
|
#define xnestFontStruct(pFont) (xnestFontPriv(pFont)->font_struct)
|
||||||
|
|
||||||
#define xnestFont(pFont) (xnestFontStruct(pFont)->fid)
|
|
||||||
|
|
||||||
Bool xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont);
|
Bool xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont);
|
||||||
Bool xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
|
Bool xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
|
#include "Xnest.h"
|
||||||
|
|
||||||
struct xnest_upstream_info {
|
struct xnest_upstream_info {
|
||||||
xcb_connection_t *conn;
|
xcb_connection_t *conn;
|
||||||
uint32_t screenId;
|
uint32_t screenId;
|
||||||
|
@ -62,4 +64,12 @@ uint32_t xnest_visual_map_to_upstream(VisualID visual);
|
||||||
uint32_t xnest_upstream_visual_to_cmap(uint32_t visual);
|
uint32_t xnest_upstream_visual_to_cmap(uint32_t visual);
|
||||||
uint32_t xnest_visual_to_upstream_cmap(uint32_t visual);
|
uint32_t xnest_visual_to_upstream_cmap(uint32_t visual);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
XFontStruct *font_struct;
|
||||||
|
xcb_query_font_reply_t *font_reply;
|
||||||
|
xcb_font_t font_id;
|
||||||
|
xcb_charinfo_t *chars;
|
||||||
|
uint16_t chars_len;
|
||||||
|
} xnestPrivFont;
|
||||||
|
|
||||||
#endif /* __XNEST__XCB_H */
|
#endif /* __XNEST__XCB_H */
|
||||||
|
|
Loading…
Reference in New Issue