sams folder icons, snap drag, sort folders, in/out ptr bug, interp bg fix, filebox...
[goodguy/history.git] / cinelerra-5.1 / guicast / bcwindowbase.C
index fae98cb186b9315572190fa6abd940e3d2f84a0b..ec7507683bf04eef3136f014b3e88f169b4564b1 100644 (file)
@@ -296,6 +296,7 @@ int BC_WindowBase::initialize()
        active_menubar = 0;
        active_popup_menu = 0;
        active_subwindow = 0;
+       cursor_entered = 0;
        pixmap = 0;
        bg_pixmap = 0;
        _7segment_pixmaps = 0;
@@ -530,24 +531,11 @@ int BC_WindowBase::create_window(BC_WindowBase *parent_window,
                        size_hints.x = this->x;
                        size_hints.y = this->y;
                }
-
-               char *txlist[2];
-               txlist[0] = this->title;
-               txlist[1] = 0;
-               XTextProperty titleprop;
-               if(options & WINDOW_UTF8)
-                       Xutf8TextListToTextProperty(display, txlist,  1,
-                               XUTF8StringStyle, &titleprop);
-               else
-                       XmbTextListToTextProperty(display, txlist, 1,
-                               XStdICCTextStyle, &titleprop);
-               XSetWMProperties(display, win, &titleprop, &titleprop,
-                       0, 0, &size_hints, 0, 0);
-               XFree(titleprop.value);
+               XSetWMProperties(display, win, 0, 0, 0, 0, &size_hints, 0, 0);
                get_atoms();
-
+               set_title(title);
 #ifndef SINGLE_THREAD
-               clipboard = new BC_Clipboard(display_name);
+               clipboard = new BC_Clipboard(this);
                clipboard->start_clipboard();
 #endif
 
@@ -1338,16 +1326,26 @@ locking_message = event->xclient.message_type;
                break;
 
        case LeaveNotify:
+               if( cursor_entered && event->xcrossing.window == win ) {
+                       cursor_entered = 0;
+               }
                event_win = event->xany.window;
                dispatch_cursor_leave();
                break;
 
        case EnterNotify:
+               if( !cursor_entered && event->xcrossing.window == win ) {
+                       if( !event->xcrossing.focus && get_resources()->grab_input_focus ) {
+                               XSetInputFocus(display, win, RevertToParent, CurrentTime);
+                       }
+                       cursor_entered = 1;
+               }
                event_win = event->xany.window;
                cursor_x = event->xcrossing.x;
                cursor_y = event->xcrossing.y;
                dispatch_cursor_enter();
                break;
+
        default:
                break;
        }
@@ -3696,6 +3694,38 @@ BC_Clipboard* BC_WindowBase::get_clipboard()
 #endif
 }
 
+Atom BC_WindowBase::to_clipboard(const char *data, long len, int clipboard_num)
+{
+       return get_clipboard()->to_clipboard(this, data, len, clipboard_num);
+}
+
+long BC_WindowBase::from_clipboard(char *data, long maxlen, int clipboard_num)
+{
+       return get_clipboard()->from_clipboard(data, maxlen, clipboard_num);
+}
+
+long BC_WindowBase::clipboard_len(int clipboard_num)
+{
+       return get_clipboard()->clipboard_len(clipboard_num);
+}
+
+int BC_WindowBase::do_selection_clear(Window win)
+{
+       top_level->event_win = win;
+       return dispatch_selection_clear();
+}
+
+int BC_WindowBase::dispatch_selection_clear()
+{
+       int result = 0;
+       for( int i=0; i<subwindows->total && !result; ++i )
+               result = subwindows->values[i]->dispatch_selection_clear();
+       if( !result )
+               result = selection_clear_event();
+       return result;
+}
+
+
 void BC_WindowBase::get_relative_cursor_xy(int &x, int &y, int lock_window)
 {
        int abs_x, abs_y, win_x, win_y;
@@ -4091,39 +4121,30 @@ void BC_WindowBase::put_title(const char *text)
        *cp = 0;
 }
 
-void BC_WindowBase::set_title(const char *text)
+void BC_WindowBase::set_title(const char *text, int utf8)
 {
+// utf8>0: wm + net_wm, utf8=0: wm only,  utf<0: net_wm only
        put_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);
-       XSetWMIconName(top_level->display, top_level->win, &titleprop);
-       XFree(titleprop.value);
-
-       flush();
-}
-
-void BC_WindowBase::set_utf8title(const char *text)
-{
-       XTextProperty titleprop;
-       char *txlist[2];
-
-       strcpy(this->title, text);
-       txlist[0] = this->title;
-       txlist[1] = 0;
-
-       Xutf8TextListToTextProperty(top_level->display, txlist,  1,
-               XUTF8StringStyle, &titleprop);
-       XSetWMName(top_level->display, top_level->win, &titleprop);
-       XSetWMIconName(top_level->display, top_level->win, &titleprop);
-       XFree(titleprop.value);
-
+       const unsigned char *wm_title = (const unsigned char *)title;
+       int title_len = strlen((const char *)title);
+       if( utf8 >= 0 ) {
+               Atom xa_wm_name = XA_WM_NAME;
+               Atom xa_icon_name = XA_WM_ICON_NAME;
+               Atom xa_string = XA_STRING;
+               XChangeProperty(display, win, xa_wm_name, xa_string, 8,
+                               PropModeReplace, wm_title, title_len);
+               XChangeProperty(display, win, xa_icon_name, xa_string, 8,
+                               PropModeReplace, wm_title, title_len);
+       }
+       if( utf8 != 0 ) {
+               Atom xa_net_wm_name = XInternAtom(display, "_NET_WM_NAME", True);
+               Atom xa_net_icon_name = XInternAtom(display, "_NET_WM_ICON_NAME", True);
+               Atom xa_utf8_string = XInternAtom(display, "UTF8_STRING", True);
+               XChangeProperty(display, win, xa_net_wm_name, xa_utf8_string, 8,
+                                       PropModeReplace, wm_title, title_len);
+               XChangeProperty(display, win, xa_net_icon_name, xa_utf8_string, 8,
+                                       PropModeReplace, wm_title, title_len);
+       }
        flush();
 }