clipboard rework, C41/titler fixes, displayinfo tweak
[goodguy/history.git] / cinelerra-5.1 / guicast / bcdisplay.C
index 4525857f53a30b59a9bf88acc9e0fe8759eae67c..39a2b908b084d3023fb4f7dd18e0a19d128ec0b0 100644 (file)
@@ -2,21 +2,21 @@
 /*
  * CINELERRA
  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- * 
+ *
  */
 
 #include "bcclipboard.h"
@@ -27,6 +27,7 @@
 #include "bcwindowbase.h"
 #include "bcwindowevents.h"
 #include "condition.h"
+#include "language.h"
 #include "mutex.h"
 
 #include <pthread.h>
@@ -52,7 +53,7 @@ BC_Display::BC_Display(const char *display_name)
        if(display_name && display_name[0] == 0) display_name = NULL;
        if((display = XOpenDisplay(display_name)) == NULL)
        {
-               printf("BC_Display::BC_Display: cannot connect to X server %s\n", 
+               printf("BC_Display::BC_Display: cannot connect to X server %s\n",
                        display_name);
                if(getenv("DISPLAY") == NULL)
        {
@@ -79,7 +80,7 @@ BC_Display::BC_Display(const char *display_name)
 
 // Start event handling
        event_thread = new BC_WindowEvents(this);
-       event_thread->start();  
+       event_thread->start();
 
 
        event_lock = new Mutex("BC_Display::event_lock", 1);
@@ -113,12 +114,9 @@ int BC_Display::is_first(BC_WindowBase *window)
 
 void BC_Display::dump_windows()
 {
-       for(int i = 0; i < windows.size(); i++)
-       {
-               printf("BC_Display::dump_windows %d window=%p window->win=%p\n", 
-                       i, 
-                       windows.get(i),
-                       windows.get(i)->win);
+       for(int i = 0; i < windows.size(); i++) {
+               printf("BC_Display::dump_windows %d window=%p window->win=0x%08jx\n",
+                       i, windows.get(i), windows.get(i)->win);
        }
 }
 
@@ -127,7 +125,7 @@ void BC_Display::new_window(BC_WindowBase *window)
 //printf("BC_Display::new_window %d\n", __LINE__);
        if(!clipboard)
        {
-               clipboard = new BC_Clipboard("");
+               clipboard = new BC_Clipboard(window);
                clipboard->start_clipboard();
        }
 
@@ -197,13 +195,13 @@ if(debug) printf("BC_Display::loop %d\n", __LINE__);
                        for(int i = 0; i < windows.size(); i++)
                        {
                                BC_WindowBase *window = windows.get(i);
-if(debug) printf("BC_Display::loop %d %d %d %d\n", 
-__LINE__, 
-window->resize_events, 
-window->motion_events, 
+if(debug) printf("BC_Display::loop %d %d %d %d\n",
+__LINE__,
+window->resize_events,
+window->motion_events,
 window->translation_events);
                                if(window->resize_events)
-                                       window->dispatch_resize_event(window->last_resize_w, 
+                                       window->dispatch_resize_event(window->last_resize_w,
                                                window->last_resize_h);
                                if(window->motion_events)
                                        window->dispatch_motion_event();
@@ -226,8 +224,8 @@ void BC_Display::handle_event()
 {
 const int debug = 0;
        XEvent *event = get_event();
-if(debug)  printf("BC_Display::handle_event %d type=%d\n", 
-__LINE__, 
+if(debug)  printf("BC_Display::handle_event %d type=%d\n",
+__LINE__,
 event->type);
 
        lock_display("BC_Display::handle_event");
@@ -246,7 +244,7 @@ if(debug) printf("BC_Display::handle_event %d\n", __LINE__);
 if(debug) printf("BC_Display::handle_event %d\n", __LINE__);
        unlock_display();
 if(debug) printf("BC_Display::handle_event %d\n", __LINE__);
-       
+
        delete event;
 if(debug) printf("BC_Display::handle_event %d\n", __LINE__);
 }
@@ -334,7 +332,7 @@ void BC_Display::unset_repeat(BC_WindowBase *window, int64_t duration)
        }
 }
 
-int BC_Display::unset_all_repeaters(BC_WindowBase *window)
+void BC_Display::unset_all_repeaters(BC_WindowBase *window)
 {
        for(int i = 0; i < repeaters.total; i++)
        {
@@ -344,7 +342,7 @@ int BC_Display::unset_all_repeaters(BC_WindowBase *window)
 
 void BC_Display::arm_repeat(int64_t duration)
 {
-       XEvent *event = new XEvent;
+       XEvent *event = BC_WindowBase::new_xevent();
        XClientMessageEvent *ptr = (XClientMessageEvent*)event;
        event->xany.window = 0;
        ptr->type = ClientMessage;
@@ -358,7 +356,7 @@ void BC_Display::arm_repeat(int64_t duration)
 
 void BC_Display::arm_completion(BC_WindowBase *window)
 {
-       XEvent *event = new XEvent;
+       XEvent *event = BC_WindowBase::new_xevent();
        XClientMessageEvent *ptr = (XClientMessageEvent*)event;
        event->xany.window = window->win;
        event->type = ClientMessage;
@@ -383,7 +381,7 @@ void BC_Display::unlock_repeaters(int64_t duration)
 void BC_Display::lock_display(const char *location)
 {
        pthread_mutex_lock(&BC_Display::display_lock);
-       int result = ++BC_Display::display_global->window_locked;
+       ++BC_Display::display_global->window_locked;
        pthread_mutex_unlock(&BC_Display::display_lock);
 
 //printf("BC_Display::lock_display %d %s result=%d\n", __LINE__, location, result);
@@ -393,13 +391,13 @@ void BC_Display::lock_display(const char *location)
 void BC_Display::unlock_display()
 {
        pthread_mutex_lock(&BC_Display::display_lock);
-       int result = --BC_Display::display_global->window_locked;
+       --BC_Display::display_global->window_locked;
 //     if(BC_Display::display_global->window_locked < 0)
 //             BC_Display::display_global->window_locked = 0;
        pthread_mutex_unlock(&BC_Display::display_lock);
 
 //printf("BC_Display::unlock_display %d result=%d\n", __LINE__, result);
-       /* if(result == 1) */ XUnlockDisplay(BC_Display::display_global->display);
+       XUnlockDisplay(BC_Display::display_global->display);
 }