delete pixmap;
#ifdef HAVE_GL
- if( get_resources()->get_synchronous() && top_level->options & GLX_WINDOW ) {
- if( !glx_win ) {
-// NVIDIA library threading problem, XCloseDisplay SEGVs without this
- sync_lock("BC_WindowBase::~BC_WindowBase:XDestroyWindow");
- glXMakeContextCurrent(top_level->display, 0, 0, 0);
- XDestroyWindow(top_level->display, win);
- sync_unlock();
- }
- else
- get_resources()->get_synchronous()->delete_window(this);
- }
+ if( get_resources()->get_synchronous() &&
+ (top_level->options & GLX_WINDOW) && glx_win != 0 )
+ get_resources()->get_synchronous()->delete_window(this);
else
#endif
XDestroyWindow(top_level->display, win);
if(window_type == MAIN_WINDOW)
{
XFreeGC(display, gc);
- XFreeFont(display, smallfont);
- XFreeFont(display, mediumfont);
- XFreeFont(display, largefont);
- XFreeFont(display, bigfont);
+ static XFontStruct *BC_WindowBase::*xfont[] = {
+ &BC_WindowBase::smallfont,
+ &BC_WindowBase::mediumfont,
+ &BC_WindowBase::largefont,
+ &BC_WindowBase::bigfont,
+ };
+ for( int i=sizeof(xfont)/sizeof(xfont[0]); --i>=0; )
+ XFreeFont(display, this->*xfont[i]);
// bug in X causes XRenderExtensionInfo to be damaged if this is done here
// left to be done in XCloseDisplay by Xlib.
#if defined(HAVE_XFT) && 0
- if(bigfont_xft)
- XftFontClose (display, (XftFont*)bigfont_xft);
- if(largefont_xft)
- XftFontClose (display, (XftFont*)largefont_xft);
- if(mediumfont_xft)
- XftFontClose (display, (XftFont*)mediumfont_xft);
- if(smallfont_xft)
- XftFontClose (display, (XftFont*)smallfont_xft);
+ static void *BC_WindowBase::*xft_font[] = {
+ &BC_WindowBase::smallfont_xft,
+ &BC_WindowBase::mediumfont_xft,
+ &BC_WindowBase::largefont_xft,
+ &BC_WindowBase::bigfont_xft,
+ &BC_WindowBase::bold_smallfont_xft,
+ &BC_WindowBase::bold_mediumfont_xft,
+ &BC_WindowBase::bold_largefont_xft,
+ };
+ for( int i=sizeof(xft_font)/sizeof(xft_font[0]); --i>=0; ) {
+ XftFont *xft = (XftFont *)(this->*xft_font[i]);
+ if( xft ) XftFontClose (display, xft);
+ }
#endif
finit_im();
init_colors();
// get the resources
if(resources.use_shm < 0) resources.initialize_display(this);
- x_correction = get_resources()->get_left_border();
- y_correction = get_resources()->get_top_border();
+ x_correction = BC_DisplayInfo::get_left_border();
+ y_correction = BC_DisplayInfo::get_top_border();
// clamp window placement
if(this->x + this->w + x_correction > root_w)
keys_return[0] = keysym;
return 0;
}
+ wkey_string_length = 0;
- wkey_string_length = XwcLookupString(input_context,
- (XKeyEvent*)event, wkey_string, 4, &keysym, 0);
+ if( input_context ) {
+ wkey_string_length = XwcLookupString(input_context,
+ (XKeyEvent*)event, wkey_string, 4, &keysym, 0);
//printf("keysym_lookup 1 %d %d %lx %x %x %x %x\n", wkey_string_length, keysym,
// wkey_string[0], wkey_string[1], wkey_string[2], wkey_string[3]);
- Status stat;
- int ret = Xutf8LookupString(input_context, (XKeyEvent*)event,
- keys_return, KEYPRESSLEN, &keysym, &stat);
+ Status stat;
+ int ret = Xutf8LookupString(input_context, (XKeyEvent*)event,
+ keys_return, KEYPRESSLEN, &keysym, &stat);
//printf("keysym_lookup 2 %d %d %lx %x %x\n", ret, stat, keysym, keys_return[0], keys_return[1]);
- if( stat == XLookupBoth ) return ret;
- if( stat == XLookupKeySym ) return 0;
-
- return XLookupString((XKeyEvent*)event, keys_return, KEYPRESSLEN, &keysym, 0);
+ if( stat == XLookupBoth ) return ret;
+ if( stat == XLookupKeySym ) return 0;
+ }
+ int ret = XLookupString((XKeyEvent*)event, keys_return, KEYPRESSLEN, &keysym, 0);
+ wkey_string_length = ret;
+ for( int i=0; i<ret; ++i ) wkey_string[i] = keys_return[i];
+ return ret;
}
pthread_t locking_task = -1;
void BC_WindowBase::init_xft()
{
#ifdef HAVE_XFT
+ if( !get_resources()->use_xft ) return;
if(!(smallfont_xft =
(resources.small_font_xft[0] == '-' ?
XftFontOpenXlfd(display, screen, resources.small_font_xft) :
if(!(largefont_xft =
(resources.large_font_xft[0] == '-' ?
XftFontOpenXlfd(display, screen, resources.large_font_xft) :
- XftFontOpenXlfd(display, screen, resources.large_font_xft))) )
+ XftFontOpenName(display, screen, resources.large_font_xft))) )
if(!(largefont_xft =
XftFontOpenXlfd(display, screen, resources.large_font_xft2)))
largefont_xft = XftFontOpenXlfd(display, screen, "fixed");
XftFontOpenXlfd(display, screen, resources.big_font_xft2)))
bigfont_xft = XftFontOpenXlfd(display, screen, "fixed");
+ if(!(bold_smallfont_xft =
+ (resources.small_b_font_xft[0] == '-' ?
+ XftFontOpenXlfd(display, screen, resources.small_b_font_xft) :
+ XftFontOpenName(display, screen, resources.small_b_font_xft))) )
+ bold_smallfont_xft = XftFontOpenXlfd(display, screen, "fixed");
+ if(!(bold_mediumfont_xft =
+ (resources.medium_b_font_xft[0] == '-' ?
+ XftFontOpenXlfd(display, screen, resources.medium_b_font_xft) :
+ XftFontOpenName(display, screen, resources.medium_b_font_xft))) )
+ bold_mediumfont_xft = XftFontOpenXlfd(display, screen, "fixed");
+ if(!(bold_largefont_xft =
+ (resources.large_b_font_xft[0] == '-' ?
+ XftFontOpenXlfd(display, screen, resources.large_b_font_xft) :
+ XftFontOpenName(display, screen, resources.large_b_font_xft))) )
+ bold_largefont_xft = XftFontOpenXlfd(display, screen, "fixed");
+
// Extension failed to locate fonts
- if( !smallfont_xft || !mediumfont_xft || !largefont_xft || !bigfont_xft) {
- printf("BC_WindowBase::init_fonts: no xft fonts found %s=%p %s=%p %s=%p %s=%p\n",
+ if( !smallfont_xft || !mediumfont_xft || !largefont_xft || !bigfont_xft ||
+ !bold_largefont_xft || !bold_mediumfont_xft || !bold_largefont_xft ) {
+ printf("BC_WindowBase::init_fonts: no xft fonts found:"
+ " %s=%p\n %s=%p\n %s=%p\n %s=%p\n %s=%p\n %s=%p\n %s=%p\n",
resources.small_font_xft, smallfont_xft,
resources.medium_font_xft, mediumfont_xft,
resources.large_font_xft, largefont_xft,
- resources.big_font_xft, bigfont_xft);
+ resources.big_font_xft, bigfont_xft,
+ resources.small_b_font_xft, bold_smallfont_xft,
+ resources.medium_b_font_xft, bold_mediumfont_xft,
+ resources.large_b_font_xft, bold_largefont_xft);
get_resources()->use_xft = 0;
exit(1);
}
int BC_WindowBase::get_single_text_width(int font, const wchar_t *text, int length)
{
-//#ifdef HAVE_XFT
- XGlyphInfo extents;
+#ifdef HAVE_XFT
+ if(get_resources()->use_xft && get_xft_struct(font)) {
+ XGlyphInfo extents;
- XftTextExtents32(top_level->display,
- get_xft_struct(font),
- (const FcChar32*)text,
- length,
- &extents);
- return extents.xOff;
-//#endif
+ XftTextExtents32(top_level->display, get_xft_struct(font),
+ (const FcChar32*)text, length, &extents);
+ return extents.xOff;
+ }
+#endif
+ if(!get_font_struct(font)) return 0;
+ XChar2b xtext[length], *xp = xtext;
+ for( int i=0; i<length; ++i,++xp ) {
+ xp->byte1 = (unsigned char) (text[i] >> 8);
+ xp->byte2 = (unsigned char) (text[i] & 0xff);
+ }
+ return XTextWidth16(get_font_struct(font), xtext, length);
}
int BC_WindowBase::get_text_width(int font, const char *text, int length)
}
}
+void BC_WindowBase::get_root_coordinates(int x, int y, int *abs_x, int *abs_y)
+{
+ translate_coordinates(win, top_level->rootwin, x, y, abs_x, abs_y);
+}
+
+void BC_WindowBase::get_win_coordinates(int abs_x, int abs_y, int *x, int *y)
+{
+ translate_coordinates(top_level->rootwin, win, abs_x, abs_y, x, y);
+}