X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;ds=sidebyside;f=cinelerra-5.1%2Fguicast%2Fbcwindowbase.C;h=366fbca601cee86b68ce6b42c3126714d78fc014;hb=77815ec03df6a03ed75433e8cf8ae1e83fb76d6e;hp=75e37fb472633a6db03eb7a0d88293d39021a137;hpb=21c2e6b36d6a96c2f662a89459d607b5a387f4eb;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/bcwindowbase.C b/cinelerra-5.1/guicast/bcwindowbase.C index 75e37fb4..366fbca6 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.C +++ b/cinelerra-5.1/guicast/bcwindowbase.C @@ -117,6 +117,7 @@ BC_WindowBase::~BC_WindowBase() #ifndef SINGLE_THREAD top_level->dequeue_events(win); #endif + if(top_level->active_grab == this) top_level->active_grab = 0; if(top_level->active_menubar == this) top_level->active_menubar = 0; if(top_level->active_popup_menu == this) top_level->active_popup_menu = 0; if(top_level->active_subwindow == this) top_level->active_subwindow = 0; @@ -284,6 +285,7 @@ int BC_WindowBase::initialize() event_win = 0; last_motion_win = 0; key_pressed = 0; + active_grab = 0; active_menubar = 0; active_popup_menu = 0; active_subwindow = 0; @@ -955,7 +957,10 @@ locking_message = event->xclient.message_type; // event_names[event->type] : "Unknown"); //} - + if( active_grab && active_grab->grab_event(event) ) { + unlock_window(); + return 0; + } switch(event->type) { @@ -2886,27 +2891,21 @@ int BC_WindowBase::get_text_width(int font, const char *text, int length) int BC_WindowBase::get_text_width(int font, const wchar_t *text, int length) { - int i, j, w = 0, line_w = 0; + int i, j, w = 0; + if( length < 0 ) length = wcslen(text); - if(length < 0) length = wcslen(text); - - for(i = 0, j = 0; i <= length; i++) - { - line_w = 0; - if(text[i] == '\n') - { - line_w = get_single_text_width(font, &text[j], i - j); - j = i + 1; + for( i=j=0; i j ) { + int lw = get_single_text_width(font, &text[j], i-j); + if( w < lw ) w = lw; } - else - if(text[i] == 0) - line_w = get_single_text_width(font, &text[j], length - j); - - if(line_w > w) w = line_w; + j = i + 1; + } + if( j < length ) { + int lw = get_single_text_width(font, &text[j], length-j); + if( w < lw ) w = lw; } - - if(i > length && w == 0) - w = get_single_text_width(font, text, length); return w; } @@ -3306,6 +3305,19 @@ void BC_WindowBase::close(int return_value) set_done(return_value); } +int BC_WindowBase::grab(BC_WindowBase *window) +{ + if( window->active_grab && this != window->active_grab ) return 0; + window->active_grab = this; + return 1; +} +int BC_WindowBase::ungrab(BC_WindowBase *window) +{ + if( window->active_grab && this != window->active_grab ) return 0; + window->active_grab = 0; + return 1; +} + int BC_WindowBase::get_w() { return w; @@ -3696,6 +3708,26 @@ int BC_WindowBase::get_abs_cursor_y(int lock_window) return abs_y; } +int BC_WindowBase::get_pop_cursor_x(int lock_window) +{ + int margin = 100; + int px = get_abs_cursor_x(lock_window); + if( px < margin ) px = margin; + int wd = get_screen_w(lock_window,-1) - margin; + if( px > wd ) px = wd; + return px; +} + +int BC_WindowBase::get_pop_cursor_y(int lock_window) +{ + int margin = 100; + int py = get_abs_cursor_y(lock_window); + if( py < margin ) py = margin; + int ht = get_screen_h(lock_window,-1) - margin; + if( py > ht ) py = ht; + return py; +} + int BC_WindowBase::match_window(Window win) { if (this->win == win) return 1;