gamma yuva hist fix, theme change without exit
[goodguy/history.git] / cinelerra-5.0 / guicast / bcwindowbase.C
index 59963d6d4b5dd31ea511a6a287fa9b31ab4d4044..87403ec8f770159eebf06bd024b3f848a41ed1c8 100644 (file)
@@ -136,19 +136,9 @@ BC_WindowBase::~BC_WindowBase()
        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");
-                       lock_window("BC_WindowBase::~BC_WindowBase:XDestroyWindow");
-                       glXMakeContextCurrent(top_level->display, 0, 0, 0);
-                       XDestroyWindow(top_level->display, win);
-                       unlock_window();
-                       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);
@@ -461,8 +451,8 @@ int BC_WindowBase::create_window(BC_WindowBase *parent_window,
                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)
@@ -863,20 +853,25 @@ int BC_WindowBase::keysym_lookup(XEvent *event)
                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;
@@ -2257,6 +2252,7 @@ int BC_WindowBase::init_fonts()
 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) :
@@ -2274,7 +2270,7 @@ void BC_WindowBase::init_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");
@@ -2791,16 +2787,22 @@ int BC_WindowBase::get_single_text_width(int font, const char *text, int length)
 
 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)
@@ -4199,6 +4201,15 @@ void BC_WindowBase::translate_coordinates(Window src_w,
        }
 }
 
+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);
+}