improve resize flash operation, fixup xv grab/ungrab, fixup label updates
authorGood Guy <[email protected]>
Sun, 4 Sep 2016 19:52:36 +0000 (13:52 -0600)
committerGood Guy <[email protected]>
Sun, 4 Sep 2016 19:52:36 +0000 (13:52 -0600)
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/cinelerra/mwindowgui.C
cinelerra-5.1/cinelerra/theme.C
cinelerra-5.1/guicast/bcbitmap.C
cinelerra-5.1/guicast/bcbitmap.h
cinelerra-5.1/guicast/bcpopupmenu.C
cinelerra-5.1/guicast/bcsignals.C
cinelerra-5.1/guicast/bcwindowbase.C
cinelerra-5.1/guicast/bcwindowbase.h

index e1538172241e36d9460b1a5f6c161c0174a26b39..e300053dc427bdeee6da69e55792fe24ac424139 100644 (file)
@@ -2446,6 +2446,8 @@ int MWindow::toggle_label(int is_mwindow)
                cwindow->gui->unlock_window();
        }
 
+       awindow->gui->async_update_assets();
+
        undo->update_undo_after(_("label"), LOAD_TIMEBAR);
        return 0;
 }
index 157090efbeaa0fc95c49779ed2a1c8573e7090ef..4f602a5dd48dd92d8b19b688be3e04bc78df05e5 100644 (file)
@@ -408,6 +408,7 @@ int MWindowGUI::resize_event(int w, int h)
        mbuttons->resize_event();
        ffmpeg_toggle->reposition_window(menu_w(), menu_h()+2);
        statusbar->resize_event();
+       zoombar->resize_event();
 
        resource_thread->stop_draw(1);
 
@@ -527,17 +528,11 @@ int MWindowGUI::resize_event(int w, int h)
                                pane[BOTTOM_RIGHT_PANE]->y);
        }
 
-       resource_thread->start_draw();
-
        update_pane_dividers();
-       zoombar->resize_event();
        pane_button->reposition_window(w - mwindow->theme->get_image_set("pane")[0]->get_w(),
                mwindow->theme->mzoom_y + 1 - mwindow->theme->get_image_set("pane")[0]->get_h());
-//     get_scrollbars(0);
-//     canvas->resize_event();
-//printf("MWindowGUI::resize_event %d\n", __LINE__);
-// required to get new widgets to appear after a pane deletion
-       show_window();
+       resource_thread->start_draw();
+
        return 0;
 }
 
index ab684e7fe9c09e6700521bb4508a7aed39962419..6562a56c5be01016c1634d0dcc1a910620822c87 100644 (file)
@@ -286,7 +286,7 @@ void Theme::build_menus()
        frame_sizes.append(new BC_ListBoxItem("1024x768"));
        frame_sizes.append(new BC_ListBoxItem("1280x720"));
        frame_sizes.append(new BC_ListBoxItem("1280x1024"));
-       frame_sizes.append(new BC_ListBoxItem("1366x768"));
+       frame_sizes.append(new BC_ListBoxItem("1368x768"));
        frame_sizes.append(new BC_ListBoxItem("1408x1152"));
        frame_sizes.append(new BC_ListBoxItem("1600x1024"));
        frame_sizes.append(new BC_ListBoxItem("1600x1200"));
index 231ce559a8039a7b652d1dbc459e6d7db5fdffdd..e8ce7622d34acba22777a51193a0c7b1a78ca0e9 100644 (file)
@@ -335,8 +335,6 @@ int BC_Bitmap::initialize(BC_WindowBase *parent_window,
        else
                this->avail_lock->reset();
        this->buffers = 0;
-       this->last_pixmap_used = 0;
-       this->last_pixmap = 0;
 
        this->active_bfr = 0;
        this->buffer_count = 0;
@@ -459,12 +457,7 @@ int BC_Bitmap::allocate_data()
 int BC_Bitmap::delete_data()
 {
 //printf("BC_Bitmap::delete_data 1\n");
-       if( last_pixmap_used && xv_portid >= 0 )
-               XvStopVideo(top_level->display, xv_portid, last_pixmap);
        update_buffers(0);
-       if( xv_portid >= 0 )
-               XvUngrabPort(top_level->display, xv_portid, CurrentTime);
-       last_pixmap_used = 0;
        active_bfr = 0;
        buffer_count = 0;
        max_buffer_count = 0;
@@ -593,8 +586,6 @@ int BC_Bitmap::write_drawable(Drawable &pixmap, GC &gc,
                avail.append(bfr);
        active_bfr = 0;
        avail_lock->unlock();
-       last_pixmap = pixmap;
-       last_pixmap_used = 1;
        if( !dont_wait && !shm_reply )
                XSync(top_level->display, False);
        return 0;
index 88d777b340536959e490da01162d35ea12c3d607..4dafc79740021ccd7d01a61d83e29911aee222ff 100644 (file)
@@ -185,11 +185,6 @@ class BC_Bitmap
        BC_WindowBase *top_level;
        BC_WindowBase *parent_window;
        int xv_portid;
-// For resetting XVideo
-       int last_pixmap_used;
-
-// Need last pixmap to stop XVideo
-       Drawable last_pixmap;
 
        static uint8_t bitswap[256];
        void transparency_bitswap(uint8_t *buf, int w, int h);
index bfcca0693939b42fa0497a4f315979740c025eb7..d6b4d15eec052d5344cabee197d262920284fca1 100644 (file)
@@ -312,8 +312,7 @@ int BC_PopupMenu::activate_menu()
                                w, h, 0, 1);
                }
                else
-// back off x,y just a bit so the menu doesnt deactivate without motion
-                       menu_popup->activate_menu(x-10, y-10, w, h, 0, 1);
+                       menu_popup->activate_menu(x+3, y+3, w, h, 0, 1);
                popup_down = 1;
                if(use_title) draw_title(1);
        }
index 3886cd64579e3663d1c339889c1066c5d8483dc0..793666cd1ca53262be65b034680817b939e05bce 100644 (file)
@@ -508,8 +508,8 @@ int BC_Signals::x_error_handler(Display *display, XErrorEvent *event)
 {
        char string[1024];
        XGetErrorText(event->display, event->error_code, string, 1024);
-       fprintf(stderr, "BC_Signals::x_error_handler: error_code=%d opcode=%d,%d %s\n",
-               event->error_code, event->request_code, event->minor_code, string);
+       fprintf(stderr, "BC_Signals::x_error_handler: error_code=%d opcode=%d,%d id=0x%jx %s\n",
+               event->error_code, event->request_code, event->minor_code, event->resourceid, string);
        return 0;
 }
 
index 96e71f39ee3bfe27e3f7a03e6a158540df13ccfd..06a8bf10ad40dbbcac5d679a25f75ce5e6efba19 100644 (file)
@@ -199,6 +199,8 @@ BC_WindowBase::~BC_WindowBase()
                        XFree(xinerama_info);
                xinerama_screens = 0;
                xinerama_info = 0;
+               if( xvideo_port_id >= 0 )
+                       XvUngrabPort(display, xvideo_port_id, CurrentTime);
 
                unlock_window();
 // Can't close display if another thread is waiting for events.
@@ -344,6 +346,7 @@ int BC_WindowBase::initialize()
        glx_win = 0;
 #endif
 
+       flash_enabled = 1;
        win = 0;
        return 0;
 }
@@ -1358,9 +1361,10 @@ int BC_WindowBase::dispatch_resize_event(int w, int h)
 // Can't store new w and h until the event is handles
 // because bcfilebox depends on the old w and h to
 // reposition widgets.
-       if(window_type == MAIN_WINDOW)
-       {
+       if( window_type == MAIN_WINDOW ) {
+               flash_enabled = 0;
                resize_events = 0;
+
                delete pixmap;
                pixmap = new BC_Pixmap(this, w, h);
 
@@ -1368,22 +1372,29 @@ int BC_WindowBase::dispatch_resize_event(int w, int h)
        }
 
 // Propagate to subwindows
-       for(int i = 0; i < subwindows->total; i++)
-       {
+       for(int i = 0; i < subwindows->total; i++) {
                subwindows->values[i]->dispatch_resize_event(w, h);
        }
 
 // Propagate to user
        resize_event(w, h);
 
-       if(window_type == MAIN_WINDOW)
-       {
+       if( window_type == MAIN_WINDOW ) {
                this->w = w;
                this->h = h;
+               dispatch_flash();
        }
        return 0;
 }
 
+int BC_WindowBase::dispatch_flash()
+{
+       flash_enabled = 1;
+       for(int i = 0; i < subwindows->total; i++)
+               subwindows->values[i]->dispatch_flash();
+       return flash();
+}
+
 int BC_WindowBase::dispatch_translation_event()
 {
        translation_events = 0;
@@ -2990,119 +3001,76 @@ void BC_WindowBase::init_wait()
 
 int BC_WindowBase::accel_available(int color_model, int lock_it)
 {
-       if(window_type != MAIN_WINDOW)
+       if( window_type != MAIN_WINDOW )
                return top_level->accel_available(color_model, lock_it);
+       if( lock_it )
+               lock_window("BC_WindowBase::accel_available");
 
-       int result = 0;
-
-       if(lock_it) lock_window("BC_WindowBase::accel_available");
-       switch(color_model)
-       {
-               case BC_YUV420P:
-                       result = grab_port_id(this, color_model);
-                       if(result >= 0)
-                       {
-                               xvideo_port_id = result;
-                               result = 1;
-                       }
-                       else
-                               result = 0;
-                       break;
-
-               case BC_YUV422P:
-                       result = 0;
-                       break;
+       switch(color_model) {
+       case BC_YUV420P:
+               grab_port_id(color_model);
+               break;
 
-               case BC_YUV422:
-//printf("BC_WindowBase::accel_available 1\n");
-                       result = grab_port_id(this, color_model);
-//printf("BC_WindowBase::accel_available 2 %d\n", result);
-                       if(result >= 0)
-                       {
-                               xvideo_port_id = result;
-                               result = 1;
-                       }
-                       else
-                               result = 0;
-//printf("BC_WindowBase::accel_available 3 %d\n", xvideo_port_id);
-                       break;
+       case BC_YUV422:
+               grab_port_id(color_model);
+               break;
 
-               default:
-                       result = 0;
-                       break;
+       default:
+               break;
        }
 
-       if(lock_it) unlock_window();
-//printf("BC_WindowBase::accel_available %d %d\n", color_model, result);
-       return result;
+       if( lock_it )
+               unlock_window();
+//printf("BC_WindowBase::accel_available %d %d\n", color_model, xvideo_port_id);
+       return xvideo_port_id >= 0 ? 1 : 0;
 }
 
 
-int BC_WindowBase::grab_port_id(BC_WindowBase *window, int color_model)
+int BC_WindowBase::grab_port_id(int color_model)
 {
-       int numFormats, i, j, k;
-       unsigned int ver, rev, numAdapt, reqBase, eventBase, errorBase;
-       XvAdaptorInfo *info;
-       XvImageFormatValues *formats;
-       int x_color_model;
-
-       if(!get_resources()->use_xvideo) return -1;
-
-// Translate from color_model to X color model
-       x_color_model = BC_CModels::bc_to_x(color_model);
-
-// Only local server is fast enough.
-       if(!resources.use_shm) return -1;
+       if( !get_resources()->use_xvideo ||     // disabled
+           !get_resources()->use_shm )         // Only local server is fast enough.
+               return -1;
+       if( xvideo_port_id >= 0 )
+               return xvideo_port_id;
 
-// XV extension is available
-       if(Success != XvQueryExtension(window->display, &ver, &rev,
-                                 &reqBase, &eventBase, &errorBase)) {
+       unsigned int ver, rev, reqBase, eventBase, errorBase;
+       if( Success != XvQueryExtension(display, // XV extension is available
+                   &ver, &rev, &reqBase, &eventBase, &errorBase) )
                return -1;
-       }
 
 // XV adaptors are available
-       XvQueryAdaptors(window->display,
-               DefaultRootWindow(window->display),
-               &numAdapt, &info);
-
-       if(!numAdapt) {
+       unsigned int numAdapt = 0;
+       XvAdaptorInfo *info = 0;
+       XvQueryAdaptors(display, DefaultRootWindow(display), &numAdapt, &info);
+       if( !numAdapt )
                return -1;
-       }
+
+// Translate from color_model to X color model
+       int x_color_model = BC_CModels::bc_to_x(color_model);
 
 // Get adaptor with desired color model
-       for(i = 0; i < (int)numAdapt && xvideo_port_id == -1; i++) {
-/* adaptor supports XvImages */
-               if(info[i].type & XvImageMask)
-               {
-               formats = XvListImageFormats(window->display,
-                                                       info[i].base_id,
-                                                       &numFormats);
-// for(j = 0; j < numFormats; j++)
-//     printf("%08x\n", formats[j].id);
-
-               int numPorts = info[i].num_ports;
-               for(j = 0; j < (int)numFormats && xvideo_port_id < 0; j++)
-               {
-/* this adaptor supports the desired format */
-                               if(formats[j].id == x_color_model)
-                               {
-/* Try to grab a port */
-                                       for(k = 0; k < numPorts; k++)
-                                       {
-/* Got a port */
-                                               if(Success == XvGrabPort(top_level->display,
-                                                       info[i].base_id + k,
-                                                       CurrentTime))
-                                               {
+       for( int i = 0; i < (int)numAdapt && xvideo_port_id == -1; i++) {
+               if( !(info[i].type & XvImageMask) || !info[i].num_ports ) continue;
+// adaptor supports XvImages
+               int numFormats = 0, numPorts = info[i].num_ports;
+               XvImageFormatValues *formats =
+                       XvListImageFormats(display, info[i].base_id, &numFormats);
+               if( !formats ) continue;
+
+               for( int j=0; j<numFormats && xvideo_port_id<0; ++j ) {
+                       if( formats[j].id != x_color_model ) continue;
+// this adaptor supports the desired format, grab a port
+                       for( int k=0; k<numPorts; ++k ) {
+                               if( Success == XvGrabPort(top_level->display,
+                                       info[i].base_id+k, CurrentTime) ) {
 //printf("BC_WindowBase::grab_port_id %llx\n", info[i].base_id);
-                                                       xvideo_port_id = info[i].base_id + k;
-                                                       break;
-                                               }
-                                       }
+                                       xvideo_port_id = info[i].base_id + k;
+                                       break;
                                }
                        }
-               if(formats) XFree(formats);
                }
+               XFree(formats);
        }
 
        XvFreeAdaptorInfo(info);
@@ -3190,6 +3158,7 @@ BC_WindowBase* BC_WindowBase::add_tool(BC_WindowBase *subwindow)
 
 int BC_WindowBase::flash(int x, int y, int w, int h, int flush)
 {
+       if( !top_level->flash_enabled ) return 0;
 //printf("BC_WindowBase::flash %d %d %d %d %d\n", __LINE__, w, h, this->w, this->h);
        set_opaque();
        XSetWindowBackgroundPixmap(top_level->display, win, pixmap->opaque_pixmap);
index a5cb7fcc2597b1eecf05988c18c49d96d722615f..6ac7782b25f185e87f5e11682b9c5348a7c2f362 100644 (file)
@@ -580,6 +580,7 @@ private:
 
 // Recursive event dispatchers
        int dispatch_resize_event(int w, int h);
+       int dispatch_flash();
        int dispatch_focus_in();
        int dispatch_focus_out();
        int dispatch_motion_event();
@@ -598,7 +599,7 @@ private:
        int dispatch_expose_event();
 
 // Get the port ID for a color model or return -1 for failure
-       int grab_port_id(BC_WindowBase *window, int color_model);
+       int grab_port_id(int color_model);
 
        int find_next_textbox(BC_WindowBase **first_textbox, BC_WindowBase **next_textbox, int &result);
        int find_prev_textbox(BC_WindowBase **last_textbox, BC_WindowBase **prev_textbox, int &result);
@@ -708,7 +709,7 @@ private:
 // If this subwindow has already shown a tooltip since the last EnterNotify
        int tooltip_done;
        int options;
-
+       int flash_enabled;
 
 
 // Font sets