camera position fix, rework transportque locks again, camera drag tweaks, window...
authorGood Guy <good1.2guy@gmail.com>
Thu, 14 Feb 2019 00:00:13 +0000 (17:00 -0700)
committerGood Guy <good1.2guy@gmail.com>
Thu, 14 Feb 2019 00:00:13 +0000 (17:00 -0700)
cinelerra-5.1/cinelerra/cpanel.C
cinelerra-5.1/cinelerra/cwindow.C
cinelerra-5.1/cinelerra/cwindowgui.C
cinelerra-5.1/cinelerra/cwindowgui.h
cinelerra-5.1/cinelerra/cwindowtool.C
cinelerra-5.1/cinelerra/playbackengine.C
cinelerra-5.1/cinelerra/playbackengine.h
cinelerra-5.1/doc/shortcuts.html
cinelerra-5.1/guicast/bctrace.h
cinelerra-5.1/guicast/bcwindowbase.C

index 87e753c..da3fd82 100644 (file)
@@ -404,11 +404,7 @@ int CPanelZoom::handle_event()
                        track->automation->autos[aidx], 1);
        if( !z_auto ) return 1;
        z_auto->set_value(zoom);
-       gui->subwindow->update_tool();
-       mwindow->gui->lock_window("CPanelZoom::handle_event 1");
-       mwindow->gui->draw_overlays(1);
-       mwindow->gui->unlock_window();
-       mwindow->sync_parameters(CHANGE_PARAMS);
+       gui->subwindow->sync_parameters(CHANGE_PARAMS, 1, 1);
        return 1;
 }
 
index 7667690..1511867 100644 (file)
@@ -211,24 +211,24 @@ void CWindow::run()
 void CWindow::update(int dir, int overlays, int tool_window, int operation, int timebar)
 {
 
-       if(dir)
+       if( dir )
                refresh_frame(CHANGE_NONE, dir);
 
        gui->lock_window("CWindow::update 2");
 // Create tool window
-       if(operation)
+       if( operation )
                gui->set_operation(mwindow->edl->session->cwindow_operation);
 
 // Updated by video device.
-       if(overlays && !dir)
+       if( overlays && !dir )
                gui->canvas->draw_refresh();
 
 // Update tool parameters
 // Never updated by someone else
-       if(tool_window || dir)
+       if( tool_window || dir )
                gui->update_tool();
 
-       if(timebar)
+       if( timebar )
                gui->timebar->update(1);
 
        double zoom = !mwindow->edl->session->cwindow_scrollbars ?
index 2150e06..e88b9a3 100644 (file)
@@ -671,6 +671,22 @@ void CWindowGUI::keyboard_zoomout()
 //     }
 }
 
+void CWindowGUI::sync_parameters(int change_type, int tool, int overlay)
+{
+       if( tool ) update_tool();
+       if( change_type < 0 && !overlay ) return;
+       unlock_window();
+       if( change_type >= 0 ) {
+               mwindow->restart_brender();
+               mwindow->sync_parameters(CHANGE_PARAMS);
+       }
+       if( overlay ) {
+               mwindow->gui->lock_window("CWindow::camera_keyframe");
+               mwindow->gui->draw_overlays(1);
+               mwindow->gui->unlock_window();
+       }
+       lock_window("CWindowGUI::sync_parameters");
+}
 
 void CWindowGUI::drag_motion()
 {
@@ -741,7 +757,7 @@ int CWindowGUI::drag_stop()
                        mwindow->gui->update(1, NORMAL_DRAW, 1, 1, 0, 1, 0);
                        mwindow->undo->update_undo_after(_("insert assets"), LOAD_ALL);
                        mwindow->gui->unlock_window();
-                       mwindow->sync_parameters(CHANGE_ALL);
+                       sync_parameters(CHANGE_ALL);
                }
        }
 
@@ -2542,11 +2558,7 @@ void CWindowCanvas::create_keyframe(int do_camera)
                y_keyframe->set_value(y_value);
                z_keyframe->set_value(z_value);
 
-               mwindow->sync_parameters(CHANGE_PARAMS);
-               gui->update_tool();
-               mwindow->gui->lock_window("CWindow::camera_keyframe");
-               mwindow->gui->draw_overlays(1);
-               mwindow->gui->unlock_window();
+               gui->sync_parameters(CHANGE_PARAMS, 1, 1);
        }
 }
 
@@ -2566,11 +2578,7 @@ void CWindowCanvas::reset_keyframe(int do_camera)
                y_keyframe->set_value(0);
                z_keyframe->set_value(1);
 
-               mwindow->sync_parameters(CHANGE_PARAMS);
-               gui->update_tool();
-               mwindow->gui->lock_window("CWindow::camera_keyframe");
-               mwindow->gui->draw_overlays(1);
-               mwindow->gui->unlock_window();
+               gui->sync_parameters(CHANGE_PARAMS, 1, 1);
        }
 }
 
@@ -2892,12 +2900,15 @@ void CWindowCanvas::draw_bezier(int do_camera)
        int64_t position = track->to_units(
                mwindow->edl->local_session->get_selectionstart(1),
                0);
-
-       track->automation->get_projector(&center_x,
-               &center_y,
-               &center_z,
-               position,
-               PLAY_FORWARD);
+       if( do_camera ) {
+               track->automation->get_camera(&center_x,
+                       &center_y, &center_z, position, PLAY_FORWARD);
+// follow image, not camera
+               center_x = -center_x;  center_y = -center_y;
+       }
+       else
+               track->automation->get_projector(&center_x,
+                       &center_y, &center_z, position, PLAY_FORWARD);
 
 //     center_x += track->track_w / 2;
 //     center_y += track->track_h / 2;
@@ -3086,6 +3097,7 @@ int CWindowCanvas::test_bezier(int button_press,
                                last_center_y = gui->affected_y->get_value();
                                float dx = cursor_x - gui->x_origin;
                                float dy = cursor_y - gui->y_origin;
+// follow image, not camera
                                if(gui->current_operation == CWINDOW_CAMERA ) {
                                        dx = -dx;  dy = -dy;
                                }
@@ -3117,7 +3129,7 @@ int CWindowCanvas::test_bezier(int button_press,
 
                if(gui->affected_track)
                {
-                       if(gui->current_operation == CWINDOW_CAMERA)
+                       if( do_camera )
                                mwindow->undo->update_undo_before(_("camera"), this);
                        else
                                mwindow->undo->update_undo_before(_("projector"), this);
@@ -3329,38 +3341,9 @@ int CWindowCanvas::cursor_motion_event()
                }
        }
 
+       int change_type = rerender ? CHANGE_PARAMS : -1;
+       gui->sync_parameters(change_type, redraw, redraw_canvas);
 
-// If the window is never unlocked before calling send_command the
-// display shouldn't get stuck on the old video frame although it will
-// flicker between the old video frame and the new video frame.
-
-       if(redraw)
-       {
-               draw_refresh();
-               gui->update_tool();
-       }
-
-       if(redraw_canvas)
-       {
-               gui->unlock_window();
-
-
-               mwindow->gui->lock_window("CWindowCanvas::cursor_motion_event 1");
-               mwindow->gui->draw_overlays(1);
-               mwindow->gui->unlock_window();
-
-               gui->lock_window("CWindowCanvas::cursor_motion_event 1");
-       }
-
-       if(rerender)
-       {
-               gui->unlock_window();
-               mwindow->restart_brender();
-               mwindow->sync_parameters(CHANGE_PARAMS);
-               mwindow->cwindow->refresh_frame(CHANGE_NONE);
-               if(!redraw) gui->update_tool();
-               gui->lock_window("CWindowCanvas::cursor_motion_event 2");
-       }
        return result;
 }
 
@@ -3426,31 +3409,9 @@ int CWindowCanvas::button_press_event()
                }
        }
 
-       if(redraw)
-       {
-               draw_refresh();
-               gui->unlock_window();
-
+       int change_type = rerender ? CHANGE_PARAMS : -1;
+       gui->sync_parameters(change_type, redraw, redraw_canvas);
 
-               mwindow->gui->lock_window("CWindowCanvas::button_press_event 1");
-               mwindow->gui->draw_overlays(1);
-               mwindow->gui->unlock_window();
-               gui->update_tool();
-
-               gui->lock_window("CWindowCanvas::button_press_event 1");
-       }
-
-// rerendering can also be caused by press event
-       if(rerender)
-       {
-               gui->unlock_window();
-
-               mwindow->restart_brender();
-               mwindow->sync_parameters(CHANGE_PARAMS);
-               mwindow->cwindow->refresh_frame(CHANGE_NONE);
-               if(!redraw) gui->update_tool();
-               gui->lock_window("CWindowCanvas::button_press_event 2");
-       }
        return result;
 }
 
index ff323cf..01ff0ce 100644 (file)
@@ -86,6 +86,7 @@ public:
        void keyboard_zoomout();
        void update_meters();
        void stop_transport(const char *lock_msg);
+       void sync_parameters(int change_type, int tool=0, int overlay=0);
 
        MWindow *mwindow;
        CWindow *cwindow;
index 5f7c416..e0e27e4 100644 (file)
@@ -807,15 +807,10 @@ void CWindowCameraGUI::create_objects()
 
 void CWindowCameraGUI::update_preview()
 {
-       mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
-       mwindow->restart_brender();
-       mwindow->gui->draw_overlays(1);
-       mwindow->sync_parameters(CHANGE_PARAMS);
-       mwindow->gui->unlock_window();
-       mwindow->cwindow->refresh_frame(CHANGE_NONE);
-       mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
-       mwindow->cwindow->gui->canvas->draw_refresh();
-       mwindow->cwindow->gui->unlock_window();
+       CWindowGUI *cgui = mwindow->cwindow->gui;
+       cgui->lock_window("CWindowCameraGUI::update_preview");
+       cgui->sync_parameters(CHANGE_PARAMS, 0, 1);
+       cgui->unlock_window();
 }
 
 
@@ -1210,15 +1205,10 @@ void CWindowProjectorGUI::create_objects()
 
 void CWindowProjectorGUI::update_preview()
 {
-       mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
-       mwindow->restart_brender();
-       mwindow->sync_parameters(CHANGE_PARAMS);
-       mwindow->gui->draw_overlays(1);
-       mwindow->gui->unlock_window();
-       mwindow->cwindow->refresh_frame(CHANGE_NONE);
-       mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
-       mwindow->cwindow->gui->canvas->draw_refresh();
-       mwindow->cwindow->gui->unlock_window();
+       CWindowGUI *cgui = mwindow->cwindow->gui;
+       cgui->lock_window("CWindowProjectorGUI::update_preview");
+       cgui->sync_parameters(CHANGE_PARAMS, 0, 1);
+       cgui->unlock_window();
 }
 
 void CWindowProjectorGUI::handle_event()
@@ -2203,15 +2193,10 @@ void CWindowMaskGUI::handle_event()
 
 void CWindowMaskGUI::update_preview()
 {
-       mwindow->gui->lock_window("CWindowMaskGUI::update_preview");
-       mwindow->restart_brender();
-       mwindow->sync_parameters(CHANGE_PARAMS);
-       mwindow->gui->draw_overlays(1);
-       mwindow->gui->unlock_window();
-       mwindow->cwindow->refresh_frame(CHANGE_NONE);
-       mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
-       mwindow->cwindow->gui->canvas->draw_refresh();
-       mwindow->cwindow->gui->unlock_window();
+       CWindowGUI *cgui = mwindow->cwindow->gui;
+       cgui->lock_window("CWindowMaskGUI::update_preview");
+       cgui->sync_parameters(CHANGE_PARAMS, 0, 1);
+       cgui->unlock_window();
 }
 
 
index 39fdaa9..0dd9b37 100644 (file)
@@ -61,7 +61,6 @@ PlaybackEngine::PlaybackEngine(MWindow *mwindow, Canvas *output)
        stop_command->realtime = 1;
        sent_command = new TransportCommand();
        sent_command->command = -1;
-       sent_lock = new Mutex("PlaybackEngine::sent");
        tracking_lock = new Mutex("PlaybackEngine::tracking_lock");
        renderengine_lock = new Mutex("PlaybackEngine::renderengine_lock");
        tracking_done = new Condition(1, "PlaybackEngine::tracking_done");
@@ -92,7 +91,6 @@ PlaybackEngine::~PlaybackEngine()
        delete next_command;
        delete stop_command;
        delete sent_command;
-       delete sent_lock;
        delete input_lock;
        delete output_lock;
 }
@@ -367,26 +365,15 @@ void PlaybackEngine::run()
 // Wait for current command to finish
                output_lock->lock("PlaybackEngine::run");
                if( done ) break;
-
-// Read the new command
-               sent_lock->lock("PlaybackEngine::run");
-               int command = sent_command->command;
-               if( command >= 0 ) {
-                       this->command->copy_from(sent_command);
 //printf("sent command=%d\n", sent_command->command);
-                       sent_command->command = -1;
-                       if( sent_command->locked )
-                               input_lock->unlock();
-               }
-               sent_lock->unlock();
-               if( command < 0 ) continue;
+// Read the new command
+               command->copy_from(sent_command);
+               input_lock->unlock();
 
                interrupt_playback(0);
                wait_render_engine();
 
-//printf("PlaybackEngine::run 1 %d\n", command->command);
-
-               switch( command ) {
+               switch( command->command ) {
 // Parameter change only
                case COMMAND_NONE:
                        perform_change();
@@ -448,11 +435,9 @@ void PlaybackEngine::send_command(int command, EDL *edl, int wait_tracking, int
        int do_stop = 0, do_resume = 0;
        int curr_command = this->command->command;
        int curr_single_frame = TransportCommand::single_frame(curr_command);
-       int curr_direction = TransportCommand::get_direction(curr_command);
        int curr_audio = this->command->toggle_audio ?
                !curr_single_frame : curr_single_frame;
        int single_frame = TransportCommand::single_frame(command);
-       int direction = TransportCommand::get_direction(command);
        int next_audio = next_command->toggle_audio ? !single_frame : single_frame;
 
 // Dispatch command
@@ -476,7 +461,7 @@ void PlaybackEngine::send_command(int command, EDL *edl, int wait_tracking, int
 // Resume or change direction
                switch( curr_command ) {
                default:
-                       transport_stop(curr_direction != direction ? 1 : 0);
+                       transport_stop(0);
                        do_resume = 1;
 // fall through
                case STOP:
@@ -510,12 +495,7 @@ int PlaybackEngine::transport_stop(int wait_tracking)
 {
        interrupt_playback(0);
        input_lock->lock("PlaybackEngine::transport_stop");
-       sent_lock->lock("PlaybackEngine::transport_stop");
        sent_command->copy_from(stop_command);
-       sent_command->locked = wait_tracking ? 1 : 0;
-               if( !sent_command->locked )
-               input_lock->unlock();
-       sent_lock->unlock();
        output_lock->unlock();
        if( wait_tracking ) {
                tracking_done->lock("PlaybackEngine::transport_stop");
@@ -546,17 +526,12 @@ int PlaybackEngine::transport_command(int command, int change_type, EDL *new_edl
                                preferences->forward_render_displacement);
        }
 
+       interrupt_playback(0);
        input_lock->lock("PlaybackEngine::transport_command");
-       next_command->locked =
-               next_command->change_type == CHANGE_NONE ||
-               next_command->change_type == CHANGE_PARAMS ? 0 : 1;
-       sent_lock->lock("PlaybackEngine::transport_command");
        sent_command->copy_from(next_command);
-       if( !sent_command->locked )
-               input_lock->unlock();
        next_command->reset();
-       sent_lock->unlock();
        output_lock->unlock();
+
 //static const char *types[] = { "NONE",
 // "FRAME_FWD", "NORMAL_FWD", "FAST_FWD", "FRAME_REV", "NORMAL_REV", "FAST_REV",
 // "STOP",  "PAUSE", "SLOW_FWD", "SLOW_REV", "REWIND", "GOTO_END", "CURRENT_FRAME",
index 85fc00a..2963252 100644 (file)
@@ -115,7 +115,6 @@ public:
                        EDL *new_edl=0, int use_inout=0);
 
        Condition *input_lock, *output_lock;
-       Mutex *sent_lock;
 // active command, stop command
        TransportCommand *command, *stop_command;
 // next command under construction, last sent command
index 73f7eba..b0e0ce9 100644 (file)
                <td align="left"><font face="Liberation Serif" size=4>'Shift'</font></td>
                <td align="left"><font face="Liberation Serif" size=4>Toggle on/off all XYZ of projector</font></td>
        </tr>
+       <tr>
+               <td height="26" align="left"><font face="Liberation Serif" size=4><br></font></td>
+               <td align="left"><font face="Liberation Serif" size=4>F11</font></td>
+               <td align="left"><font face="Liberation Serif" size=4>'Shift'</font></td>
+               <td align="left"><font face="Liberation Serif" size=4>Create identity camera keyframe</font></td>
+       </tr>
+       <tr>
+               <td height="26" align="left"><font face="Liberation Serif" size=4><br></font></td>
+               <td align="left"><font face="Liberation Serif" size=4>F12</font></td>
+               <td align="left"><font face="Liberation Serif" size=4>'Shift'</font></td>
+               <td align="left"><font face="Liberation Serif" size=4>Create identity projector keyframe</font></td>
+       </tr>
        <tr>
                <td height="26" align="left"><font face="Liberation Serif" size=4><br></font></td>
                <td align="left"><font face="Liberation Serif" size=4>F1</font></td>
index 51dafd7..2c2046b 100644 (file)
@@ -13,6 +13,7 @@
 void booby();
 #else
 #define BT
+#define booby(s) do {} while(0)
 #endif
 
 class BC_Trace
index 3db866f..f9e49e2 100644 (file)
@@ -648,18 +648,16 @@ Display* BC_WindowBase::init_display(const char *display_name)
 
        if(display_name && display_name[0] == 0) display_name = NULL;
        if((display = XOpenDisplay(display_name)) == NULL) {
-               printf("BC_WindowBase::init_display: cannot connect to X server %s\n",
+               printf("BC_WindowBase::init_display: cannot connect to X server %s\n",
                        display_name);
-               if(getenv("DISPLAY") == NULL) {
+               if(getenv("DISPLAY") == NULL) {
                        printf(_("'DISPLAY' environment variable not set.\n"));
-                       exit(1);
+                       exit(1);
                }
-               else {
 // Try again with default display.
-                       if((display = XOpenDisplay(0)) == NULL) {
-                               printf("BC_WindowBase::init_display: cannot connect to default X server.\n");
-                               exit(1);
-                       }
+               if((display = XOpenDisplay(0)) == NULL) {
+                       printf("BC_WindowBase::init_display: cannot connect to default X server.\n");
+                       exit(1);
                }
        }
 
@@ -873,7 +871,7 @@ int BC_WindowBase::keysym_lookup(XEvent *event)
 //  wkey_string[0], wkey_string[1], wkey_string[2], wkey_string[3]);
 
                Status stat;
-               int ret = Xutf8LookupString(input_context, (XKeyEvent*)event,
+               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;
@@ -1031,8 +1029,7 @@ locking_message = event->xclient.message_type;
 
 //printf("BC_WindowBase::dispatch_event %d %d\n", __LINE__, button_number);
                event_win = event->xany.window;
-               if (button_number < 6)
-               {
+               if (button_number < 6) {
                        if(button_number < 4)
                                button_down = 1;
                        button_pressed = event->xbutton.button;
@@ -2112,13 +2109,11 @@ int BC_WindowBase::init_colors()
        switch(color_model)
        {
                case BC_RGB8:
-                       if(private_color)
-                       {
-                               cmap = XCreateColormap(display, rootwin, vis, AllocNone);
+                       if(private_color) {
+                               cmap = XCreateColormap(display, rootwin, vis, AllocNone);
                                create_private_colors();
                        }
-                       else
-                       {
+                       else {
                                cmap = DefaultColormap(display, screen);
                                create_shared_colors();
                        }
@@ -3319,13 +3314,10 @@ int BC_WindowBase::unlock_window()
        if(top_level)
        {
                UNSET_LOCK(this);
-
-//             if(!top_level->window_lock)
-//             {
-//                     printf("BC_WindowBase::unlock_window %d %s already unlocked\n",
-//                             __LINE__,
-//                             title);
-//             }
+               if( !top_level->window_lock ) {
+                       printf("BC_WindowBase::unlock_window %s not locked\n", title);
+                       booby();
+               }
                if( top_level->window_lock > 0 )
                        if( --top_level->window_lock == 0 )
                                top_level->display_lock_owner = 0;
@@ -3427,7 +3419,7 @@ void BC_WindowBase::grab_cursor()
 }
 void BC_WindowBase::ungrab_cursor()
 {
-       XUngrabPointer(top_level->display, CurrentTime);
+       XUngrabPointer(top_level->display, CurrentTime);
 }
 
 // for get_root_w/h
@@ -4412,81 +4404,65 @@ void BC_WindowBase::get_win_coordinates(int abs_x, int abs_y, int *x, int *y)
 #ifdef HAVE_LIBXXF86VM
 void BC_WindowBase::closest_vm(int *vm, int *width, int *height)
 {
-   int foo,bar;
-   *vm = 0;
-   if(XF86VidModeQueryExtension(top_level->display,&foo,&bar)) {
-          int vm_count,i;
-          XF86VidModeModeInfo **vm_modelines;
-          XF86VidModeGetAllModeLines(top_level->display,XDefaultScreen(top_level->display),&vm_count,&vm_modelines);
-          for (i = 0; i < vm_count; i++) {
-                  if (vm_modelines[i]->hdisplay < vm_modelines[*vm]->hdisplay && vm_modelines[i]->hdisplay >= *width)
-                          *vm = i;
-          }
-          display = top_level->display;
-          if (vm_modelines[*vm]->hdisplay == *width)
-                  *vm = -1;
-          else
-          {
-                  *width = vm_modelines[*vm]->hdisplay;
-                  *height = vm_modelines[*vm]->vdisplay;
-          }
-   }
+       int foo,bar;
+       *vm = 0;
+       if(XF86VidModeQueryExtension(top_level->display,&foo,&bar)) {
+               int vm_count,i;
+               XF86VidModeModeInfo **vm_modelines;
+               XF86VidModeGetAllModeLines(top_level->display,
+                       XDefaultScreen(top_level->display), &vm_count,&vm_modelines);
+               for( i = 0; i < vm_count; i++ ) {
+                       if( vm_modelines[i]->hdisplay < vm_modelines[*vm]->hdisplay &&
+                           vm_modelines[i]->hdisplay >= *width )
+                               *vm = i;
+               }
+               display = top_level->display;
+               if( vm_modelines[*vm]->hdisplay == *width )
+                       *vm = -1;
+               else {
+                       *width = vm_modelines[*vm]->hdisplay;
+                       *height = vm_modelines[*vm]->vdisplay;
+               }
+       }
 }
 
 void BC_WindowBase::scale_vm(int vm)
 {
-   int foo,bar,dotclock;
-   if(XF86VidModeQueryExtension(top_level->display,&foo,&bar))
-   {
-          int vm_count;
-          XF86VidModeModeInfo **vm_modelines;
-          XF86VidModeModeLine vml;
-          XF86VidModeGetAllModeLines(top_level->display,XDefaultScreen(top_level->display),&vm_count,&vm_modelines);
-          XF86VidModeGetModeLine(top_level->display,XDefaultScreen(top_level->display),&dotclock,&vml);
-          orig_modeline.dotclock = dotclock;
-          orig_modeline.hdisplay = vml.hdisplay;
-          orig_modeline.hsyncstart = vml.hsyncstart;
-          orig_modeline.hsyncend = vml.hsyncend;
-          orig_modeline.htotal = vml.htotal;
-          orig_modeline.vdisplay = vml.vdisplay;
-          orig_modeline.vsyncstart = vml.vsyncstart;
-          orig_modeline.vsyncend = vml.vsyncend;
-          orig_modeline.vtotal = vml.vtotal;
-          orig_modeline.flags = vml.flags;
-          orig_modeline.privsize = vml.privsize;
-          // orig_modeline.private = vml.private;
-          XF86VidModeSwitchToMode(top_level->display,XDefaultScreen(top_level->display),vm_modelines[vm]);
-          XF86VidModeSetViewPort(top_level->display,XDefaultScreen(top_level->display),0,0);
-          XFlush(top_level->display);
-   }
+       int foo,bar,dotclock;
+       if( XF86VidModeQueryExtension(top_level->display,&foo,&bar) ) {
+               int vm_count;
+               XF86VidModeModeInfo **vm_modelines;
+               XF86VidModeModeLine vml;
+               XF86VidModeGetAllModeLines(top_level->display,
+                       XDefaultScreen(top_level->display), &vm_count,&vm_modelines);
+               XF86VidModeGetModeLine(top_level->display,
+                       XDefaultScreen(top_level->display), &dotclock,&vml);
+               orig_modeline.dotclock = dotclock;
+               orig_modeline.hdisplay = vml.hdisplay;
+               orig_modeline.hsyncstart = vml.hsyncstart;
+               orig_modeline.hsyncend = vml.hsyncend;
+               orig_modeline.htotal = vml.htotal;
+               orig_modeline.vdisplay = vml.vdisplay;
+               orig_modeline.vsyncstart = vml.vsyncstart;
+               orig_modeline.vsyncend = vml.vsyncend;
+               orig_modeline.vtotal = vml.vtotal;
+               orig_modeline.flags = vml.flags;
+               orig_modeline.privsize = vml.privsize;
+               // orig_modeline.private = vml.private;
+               XF86VidModeSwitchToMode(top_level->display,XDefaultScreen(top_level->display),vm_modelines[vm]);
+               XF86VidModeSetViewPort(top_level->display,XDefaultScreen(top_level->display),0,0);
+               XFlush(top_level->display);
+       }
 }
 
 void BC_WindowBase::restore_vm()
 {
-   XF86VidModeSwitchToMode(top_level->display,XDefaultScreen(top_level->display),&orig_modeline);
-   XFlush(top_level->display);
+       XF86VidModeSwitchToMode(top_level->display,XDefaultScreen(top_level->display),&orig_modeline);
+       XFlush(top_level->display);
 }
-
-
 #endif
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 #ifndef SINGLE_THREAD
 int BC_WindowBase::get_event_count()
 {