From: Good Guy Date: Wed, 23 Mar 2022 18:41:11 +0000 (-0600) Subject: Georgy Context Help fix for shuttle and enhanced user ContextManual.pl script X-Git-Tag: 2022-03~3 X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=d8393b13b37b8654f0039ec1dba9a71c02af9411;p=goodguy%2Fcinelerra.git Georgy Context Help fix for shuttle and enhanced user ContextManual.pl script --- diff --git a/cinelerra-5.1/cinelerra/shuttle.C b/cinelerra-5.1/cinelerra/shuttle.C index 4860a769..53b6527a 100644 --- a/cinelerra-5.1/cinelerra/shuttle.C +++ b/cinelerra-5.1/cinelerra/shuttle.C @@ -504,6 +504,8 @@ int Shuttle::send_keycode(unsigned key, unsigned msk, int press, int send) k->x = wx; k->y = wy; k->state = msk; +// also clear modifiers state if a key is to be released + if( !press ) k->state = 0; k->keycode = key; k->same_screen = 1; wdw->top_level->put_event((XEvent *) k); @@ -553,9 +555,9 @@ void Shuttle::key(unsigned short code, unsigned int value) fprintf(stderr, "key(%d, %d) out of range\n", code + EVENT_CODE_KEY1, value); return; } -// Show help if both Alt's pressed on keyboard together with a shuttle button - if( wdw && wdw->alt_down() ) { - if( value ) wdw->context_help_show("Shuttle key default arrangement"); +// Show help if Alt is pressed on the keyboard together with a shuttle button + if( wdw && wdw->alt_down() && value ) { + wdw->context_help_show("Shuttle key default arrangement"); return; } send_stroke_sequence(value ? KJS_KEY_DOWN : KJS_KEY_UP, code); diff --git a/cinelerra-5.1/doc/ContextManual.pl b/cinelerra-5.1/doc/ContextManual.pl index 925f80b6..f3e25cdb 100755 --- a/cinelerra-5.1/doc/ContextManual.pl +++ b/cinelerra-5.1/doc/ContextManual.pl @@ -12,10 +12,14 @@ # On empty keyphrase do nothing # The special keyphrase "TOC" shows Contents, "IDX" shows Index # The keyphrase starting with "FILE:" shows the file named after colon +# The special keyphrase "API" shows the numeric version of the script itself # Several important definitions -# Web browser executable +# ContextManual.pl script API version. Must not be changed ! +$cin_cm_api = 1; + +# Web browser executable, can be redefined on user's demand $cin_browser = $ENV{'CIN_BROWSER'}; # a likely default browser $cin_browser = 'firefox' if $cin_browser eq ''; @@ -24,6 +28,9 @@ $cin_browser = 'firefox' if $cin_browser eq ''; # a fake browser for debugging #$cin_browser = 'echo'; +# The following definitions depend on the HTML manual structure +# There is nothing to change below this line + # The node with the manual contents $contents_node = 'Contents.html'; @@ -76,11 +83,48 @@ $contents = $cin_man.'/'.$contents_node; $index = $cin_man.'/'.$index_node; #print "ContextManual: using contents $contents\n"; +# Cinelerra user's config directory +$cin_config = $ENV{'CIN_CONFIG'}; +$cin_config = $ENV{'HOME'}.'/.bcast5' + if $cin_config eq '' && $ENV{'HOME'} ne ''; +$cin_config = '.' if $cin_config eq ''; +$me_config = "$cin_config/ContextManual.pl"; +#print "ContextManual: user script=$me_config\n"; + # 1st argument is the requested key $help_key = $ARGV[0]; #print "ContextManual: request=$help_key\n"; # Do nothing if no key requested exit 0 if $help_key eq ''; + +# A special internal request: output own API version +if ($help_key eq 'API') +{ + print "$cin_cm_api\n"; + exit 0; +} + +# If a system (not user's) script instance is executed, and the API versions +# of both scripts do not match, then copy the system script to the user's one +# (making a backup copy of the latter). Then execute it with the same key. +if ($0 ne $me_config) +{ + $me_api = 0; + $me_api = `\"$me_config\" API` if -x $me_config; + if ($me_api != $cin_cm_api) + { + print "ContextManual: copying \"$0\" to \"$me_config\"\n"; + unlink "$me_config.bak" if -f "$me_config.bak"; + rename "$me_config", "$me_config.bak" if -f $me_config; + system "cp \"$0\" \"$me_config\""; + system "chmod +x \"$me_config\""; + } + exec "\"$me_config\" \"$help_key\"" if -x $me_config; +} + +# If a user's script instance is executed, do everything by myself +#print "ContextManual: executing \"$0\" \"$help_key\"\n"; + # Show contents on this special request if ($help_key eq 'TOC') { @@ -178,13 +222,13 @@ if ($node eq '') # If not found, grep manual for exact key instance if ($node eq '') { - $_ = `grep -l \"$help_key\" $cin_dat/doc/CinelerraGG_Manual/*.html`; + $_ = `grep -l \"$help_key\" \"$cin_dat\"/doc/CinelerraGG_Manual/*.html`; ($node) = split; } # If not found, grep manual for case insensitive key instance if ($node eq '') { - $_ = `grep -il \"$help_key\" $cin_dat/doc/CinelerraGG_Manual/*.html`; + $_ = `grep -il \"$help_key\" \"$cin_dat\"/doc/CinelerraGG_Manual/*.html`; ($node) = split; } diff --git a/cinelerra-5.1/guicast/bcwindowbase.C b/cinelerra-5.1/guicast/bcwindowbase.C index c57cd620..adaaa6e2 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.C +++ b/cinelerra-5.1/guicast/bcwindowbase.C @@ -1173,6 +1173,24 @@ if( debug && event->type != ClientMessage ) { //__LINE__, //keysym); +// force setting modifiers state if a modifier key pressed + switch( keysym ) { + case XK_Alt_L: + case XK_Alt_R: + alt_mask = 1; + break; + case XK_Shift_L: + case XK_Shift_R: + shift_mask = 1; + break; + case XK_Control_L: + case XK_Control_R: + ctrl_mask = 1; + break; + default: + break; + } + // block out control keys if(keysym > 0xffe0 && keysym < 0xffff) break; // block out Alt_GR key @@ -1309,8 +1327,26 @@ if( debug && event->type != ClientMessage ) { case KeyRelease: XLookupString((XKeyEvent*)event, keys_return, 1, &keysym, 0); + get_key_masks(event->xkey.state); +// force clearing modifiers state if a modifier key released + switch( keysym ) { + case XK_Alt_L: + case XK_Alt_R: + alt_mask = 0; + break; + case XK_Shift_L: + case XK_Shift_R: + shift_mask = 0; + break; + case XK_Control_L: + case XK_Control_R: + ctrl_mask = 0; + break; + default: + break; + } dispatch_keyrelease_event(); -// printf("BC_WindowBase::dispatch_event KeyRelease keysym=0x%x keystate=0x%lld\n", +// printf("BC_WindowBase::dispatch_event KeyRelease keysym=%#lx keystate=%04x\n", // keysym, event->xkey.state); break;