X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcwindowbase.C;h=9f3e2123c843c7e0f336ae1d4c53105b03b04a71;hp=e861238e388e177a041b093407513421cb1ea8c9;hb=b89feee3b26be17a08bf1598618d4d7709a73cb9;hpb=e854f4eeda320c2626780afdac9546f482de54b1 diff --git a/cinelerra-5.1/guicast/bcwindowbase.C b/cinelerra-5.1/guicast/bcwindowbase.C index e861238e..9f3e2123 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.C +++ b/cinelerra-5.1/guicast/bcwindowbase.C @@ -57,7 +57,9 @@ #include #include +#ifdef HAVE_XV #include +#endif #include #include #include @@ -205,9 +207,10 @@ BC_WindowBase::~BC_WindowBase() XFree(xinerama_info); xinerama_screens = 0; xinerama_info = 0; +#ifdef HAVE_XV if( xvideo_port_id >= 0 ) XvUngrabPort(display, xvideo_port_id, CurrentTime); - +#endif unlock_window(); // Must be last reference to display. // _XftDisplayInfo needs a lock. @@ -221,6 +224,7 @@ BC_WindowBase::~BC_WindowBase() } resize_history.remove_all_objects(); + delete grab_lock; #ifndef SINGLE_THREAD common_events.remove_all_objects(); @@ -343,6 +347,7 @@ int BC_WindowBase::initialize() event_condition = new Condition(0, "BC_WindowBase::event_condition"); init_lock = new Condition(0, "BC_WindowBase::init_lock"); #endif + grab_lock = new Mutex("BC_WindowBase::grab_lock"); cursor_timer = new Timer; event_thread = 0; @@ -869,8 +874,11 @@ int BC_WindowBase::keysym_lookup(XEvent *event) wkey_string_length = 0; if( input_context ) { + wchar_t wkey[4]; wkey_string_length = XwcLookupString(input_context, - (XKeyEvent*)event, wkey_string, 4, &keysym, 0); + (XKeyEvent*)event, wkey, 4, &keysym, 0); + for( int i=0; itype != ClientMessage ) { } if( active_grab ) { + grab_lock->lock("BC_WindowBase::dispatch_event 3"); unlock_window(); - active_grab->lock_window("BC_WindowBase::dispatch_event 3"); - result = active_grab->grab_event(event); - active_grab->unlock_window(); + result = 0; + if( active_grab ) { + active_grab->lock_window("BC_WindowBase::dispatch_event 3"); + result = active_grab->grab_event(event); + active_grab->unlock_window(); + } + grab_lock->unlock(); if( result ) return result; lock_window("BC_WindowBase::dispatch_event 4"); } @@ -1016,8 +1029,8 @@ if( debug && event->type != ClientMessage ) { //printf("BC_WindowBase::dispatch_event %d %d\n", __LINE__, button_number); event_win = event->xany.window; - if (button_number < 6) { - if(button_number < 4) + if( button_number < 6 ) { + if( button_number < 4 ) button_down = 1; button_pressed = event->xbutton.button; button_time1 = button_time2; @@ -1030,23 +1043,20 @@ if( debug && event->type != ClientMessage ) { drag_x2 = cursor_x + get_resources()->drag_radius; drag_y1 = cursor_y - get_resources()->drag_radius; drag_y2 = cursor_y + get_resources()->drag_radius; - - if((long)(button_time3 - button_time1) < resources->double_click * 2) - { - triple_click = 1; - button_time3 = button_time2 = button_time1 = 0; - } - if((long)(button_time3 - button_time2) < resources->double_click) - { - double_click = 1; -// button_time3 = button_time2 = button_time1 = 0; - } - else - { - triple_click = 0; - double_click = 0; + if( button_number < 4 ) { + if((long)(button_time3 - button_time1) < resources->double_click * 2) { + triple_click = 1; + button_time3 = button_time2 = button_time1 = 0; + } + if((long)(button_time3 - button_time2) < resources->double_click) { + double_click = 1; +// button_time3 = button_time2 = button_time1 = 0; + } + else { + triple_click = 0; + double_click = 0; + } } - dispatch_button_press(); } break; @@ -2421,7 +2431,7 @@ void BC_WindowBase::init_glyphs() "`abcdefghijklmnopqrstuvwxyz{|}~"); for( int font=SMALLFONT; font<=LARGEFONT; ++font ) { set_font(font); - draw_text(5,5, text, 0); + draw_text(5,5, text); } set_font(cur_font); XUngrabServer(display); @@ -2944,10 +2954,10 @@ int BC_WindowBase::get_text_width(int font, const char *text, int length) return w; } -int BC_WindowBase::get_text_width(int font, const wchar_t *text, int length) +int BC_WindowBase::get_text_width(int font, const wchr_t *text, int length) { int i, j, w = 0; - if( length < 0 ) length = wcslen(text); + if( length < 0 ) length = wstrlen(text); for( i=j=0; iuse_xvideo || // disabled !get_resources()->use_shm ) // Only local server is fast enough. return -1; @@ -3160,8 +3171,10 @@ int BC_WindowBase::grab_port_id(int color_model) } XvFreeAdaptorInfo(info); - return xvideo_port_id; +#else + return -1; +#endif } @@ -3409,17 +3422,36 @@ void BC_WindowBase::close(int return_value) int BC_WindowBase::grab(BC_WindowBase *window) { - if( window->active_grab && this != window->active_grab ) return 0; - window->active_grab = this; - this->grab_active = window; - return 1; + int ret = 0; + BC_WindowBase *grab_window = window->active_grab; + if( grab_window ) { + int locked = get_window_lock(); + if( locked ) unlock_window(); + grab_window->lock_window("BC_WindowBase::grab(BC_WindowBase"); + grab_window->handle_ungrab(); + grab_window->unlock_window(); + if( locked ) lock_window("BC_WindowBase::grab(BC_WindowBase"); + } + window->grab_lock->lock("BC_WindowBase::grab"); + if( !window->active_grab ) { + window->active_grab = this; + this->grab_active = window; + ret = 1; + } + window->grab_lock->unlock(); + return ret; } int BC_WindowBase::ungrab(BC_WindowBase *window) { - if( window->active_grab && this != window->active_grab ) return 0; - window->active_grab = 0; - this->grab_active = 0; - return 1; + int ret = 0; + window->grab_lock->lock("BC_WindowBase::ungrab"); + if( this == window->active_grab ) { + window->active_grab = 0; + this->grab_active = 0; + ret = 1; + } + window->grab_lock->unlock(); + return ret; } int BC_WindowBase::grab_event_count() { @@ -3901,9 +3933,9 @@ void BC_WindowBase::get_pop_cursor(int &px, int &py, int lock_window) get_abs_cursor(px, py, lock_window); if( px < xmargin ) px = xmargin; if( py < ymargin ) py = ymargin; - int wd = get_screen_w(lock_window,-1) - xmargin; + int wd = get_screen_x(lock_window,-1) + get_screen_w(lock_window,-1) - xmargin; if( px > wd ) px = wd; - int ht = get_screen_h(lock_window,-1) - ymargin; + int ht = get_screen_y(lock_window,-1) + get_screen_h(lock_window,-1) - ymargin; if( py > ht ) py = ht; } int BC_WindowBase::get_pop_cursor_x(int lock_window) @@ -4039,7 +4071,7 @@ int BC_WindowBase::ctrl_down() return top_level->ctrl_mask; } -wchar_t* BC_WindowBase::get_wkeystring(int *length) +wchr_t* BC_WindowBase::get_wkeystring(int *length) { if(length) *length = top_level->wkey_string_length; @@ -4351,6 +4383,10 @@ void BC_WindowBase::init_resources(float scale) int wx, wy, ww, wh; int cins = info.xinerama_big_screen(); if( !info.xinerama_geometry(cins, wx, wy, ww, wh) ) { + int sh = ww * 9 / 16; + int sw = wh * 16 / 9; + if( sw < ww ) ww = sw; + if( sh < wh ) wh = sh; if( (x_scale = ww/1920.) < 1 ) x_scale = 1; if( (y_scale = wh/1080.) < 1 ) y_scale = 1; } @@ -4638,9 +4674,9 @@ int BC_WindowBase::wait_viewable(int ms) XWindowAttributes xwa; do { XGetWindowAttributes(top_level->display, top_level->win, &xwa); - if( xwa.map_state == IsViewable ) return 1; + if( xwa.map_state == IsViewable ) return 0; usleep(10000); } while( timer.get_difference() < ms ); - return 0; + return 1; }