akirad fixups for splash, folders, icons
[goodguy/history.git] / cinelerra-5.0 / guicast / bcwindowbase.C
index 13eb4cd1d91fd8c8b4cf0d8829db66ee4d766d7d..5f0eb5fd329446375da521cdaa4af70f05de09cf 100644 (file)
@@ -33,7 +33,6 @@
 #include "bcsubwindow.h"
 #include "bcsynchronous.h"
 #include "bctimer.h"
-#include "bcwidgetgrid.h"
 #include "bcwindowbase.h"
 #include "bcwindowevents.h"
 #include "bccmodels.h"
@@ -134,29 +133,12 @@ BC_WindowBase::~BC_WindowBase()
                delete subwindows;
        }
 
-       if(widgetgrids) {
-               while (widgetgrids->total) {
-                       delete widgetgrids->last();
-                       widgetgrids->remove();
-               }
-               delete widgetgrids;
-       }
-
-
        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);
@@ -183,7 +165,9 @@ BC_WindowBase::~BC_WindowBase()
                XFreeFont(display, largefont);
                XFreeFont(display, bigfont);
 
-#ifdef HAVE_XFT
+// 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)
@@ -210,8 +194,8 @@ BC_WindowBase::~BC_WindowBase()
 #ifndef SINGLE_THREAD
 #ifdef HAVE_GL
                if( (options & GLX_DISPLAY) != 0 && get_resources()->get_synchronous() ) {
-                       printf("BC_WindowBase::~BC_WindowBase window deleted but opengl deletion is not\n"
-                               "implemented for BC_Pixmap.\n");
+                       printf(_("BC_WindowBase::~BC_WindowBase window deleted but opengl deletion is not\n"
+                               "implemented for BC_Pixmap.\n"));
                        get_resources()->get_synchronous()->delete_display(this);
                }
                else
@@ -264,7 +248,6 @@ int BC_WindowBase::initialize()
        top_level = 0;
        parent_window = 0;
        subwindows = 0;
-       widgetgrids = 0;
        xinerama_info = 0;
        xinerama_screens = 0;
        xvideo_port_id = -1;
@@ -417,11 +400,10 @@ int BC_WindowBase::create_window(BC_WindowBase *parent_window,
        else
                this->display_name[0] = 0;
 
-       strcpy(this->title, _(title));
+       put_title(_(title));
        if(bg_pixmap) shared_bg_pixmap = 1;
 
        subwindows = new BC_SubWindowList;
-       widgetgrids = new BC_WidgetGridList;
 
        if(window_type == MAIN_WINDOW)
        {
@@ -469,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)
@@ -667,7 +649,7 @@ Display* BC_WindowBase::init_display(const char *display_name)
                printf("BC_WindowBase::init_display: cannot connect to X server %s\n",
                        display_name);
                if(getenv("DISPLAY") == NULL) {
-                       printf("'DISPLAY' environment variable not set.\n");
+                       printf(_("'DISPLAY' environment variable not set.\n"));
                        exit(1);
                }
                else {
@@ -2282,7 +2264,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");
@@ -3154,13 +3136,6 @@ BC_WindowBase* BC_WindowBase::add_tool(BC_WindowBase *subwindow)
        return add_subwindow(subwindow);
 }
 
-BC_WidgetGrid* BC_WindowBase::add_widgetgrid(BC_WidgetGrid *widgetgrid)
-{
-       widgetgrids->append(widgetgrid);
-       return widgetgrid;
-}
-
-
 int BC_WindowBase::flash(int x, int y, int w, int h, int flush)
 {
 //printf("BC_WindowBase::flash %d %d %d %d %d\n", __LINE__, w, h, this->w, this->h);
@@ -3894,11 +3869,6 @@ int BC_WindowBase::resize_event(int w, int h)
        return 0;
 }
 
-int BC_WindowBase::reposition_widget(int x, int y, int w, int h)
-{
-       return reposition_window(x, y, w, h);
-}
-
 int BC_WindowBase::reposition_window(int x, int y)
 {
        reposition_window(x, y, -1, -1);
@@ -4016,15 +3986,30 @@ void BC_WindowBase::set_background(VFrame *bitmap)
        draw_background(0, 0, w, h);
 }
 
+void BC_WindowBase::put_title(const char *text)
+{
+       if( BC_Resources::locale_utf8 ) {
+               char *bp=this->title, *ep = bp+sizeof(this->title)-1;
+               for( const char *cp=text; *cp!=0 && bp<ep; ) {
+                       if( *cp < 0 ) { do { *bp++ = *cp++; } while( *cp < 0 );  continue; }
+                       if( *cp < ' ' ) { *bp++ = ' ';  ++cp;  continue; }
+                       *bp++ = *cp++;
+               }
+               *bp = 0;
+       }
+       else
+               strcpy(this->title, text);
+}
+
 void BC_WindowBase::set_title(const char *text)
 {
-       XTextProperty titleprop;
-       char *txlist[2];
+       put_title(_(text));
 
-       strcpy(this->title, _(text));
+       char *txlist[2];
        txlist[0] = this->title;
        txlist[1] = 0;
 
+       XTextProperty titleprop;
        XmbTextListToTextProperty(top_level->display, txlist, 1,
                XStdICCTextStyle, &titleprop);
        XSetWMName(top_level->display, top_level->win, &titleprop);
@@ -4204,6 +4189,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);
+}