From c6a6d1b1dca800ce64e5820df864e2ef5e213e29 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Mon, 8 Nov 2021 16:27:07 +0100 Subject: [PATCH] Motion and Enter events regain focus even it toolbar is displayed and user pressed "Tab" to focus a button; toolbar button focus ordering matches display ordering --- src/callback.c | 48 +++++++++++++----------------------------------- src/xschem.tcl | 41 +++++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 55 deletions(-) diff --git a/src/callback.c b/src/callback.c index d0e6be70..6e5c2eb2 100644 --- a/src/callback.c +++ b/src/callback.c @@ -144,49 +144,27 @@ int callback(int event, int mx, int my, KeySym key, char str[PATH_MAX + 100]; /* overflow safe 20161122 */ struct stat buf; unsigned short sel; - static int capslock = 0; - static int numlock = 0; #ifndef __unix__ short cstate = GetKeyState(VK_CAPITAL); short nstate = GetKeyState(VK_NUMLOCK); - if (capslock==0 && (cstate&0x0001)) { + + if(cstate & 0x0001) { /* caps lock */ tcleval(".statusbar.8 configure -state active -text {CAPS LOCK SET! }"); - capslock = 1; + } else if (nstate & 0x0001) { /* num lock */ + tcleval(".statusbar.8 configure -state active -text {NUM LOCK SET! }"); + } else { /* normal state */ + tcleval(".statusbar.8 configure -state normal -text {}"); } - if (capslock==1 && !(cstate&0x0001)) { - if (numlock) tcleval(".statusbar.8 configure -state active -text {NUM LOCK SET! }"); - else tcleval(".statusbar.8 configure -state normal -text {}"); - capslock = 0; - } - if(numlock==0 && (nstate&0x0001)) { - tcleval(".statusbar.8 configure -state active -text {NUM LOCK SET! }"); - numlock = 1; - } - if (numlock==1 && !(nstate&0x0001)) { - if(capslock) tcleval(".statusbar.8 configure -state active -text {CAPS LOCK SET! }"); - else tcleval(".statusbar.8 configure -state normal -text {}"); - numlock = 0; - } #else XKeyboardState kbdstate; XGetKeyboardControl(display, &kbdstate); - if(capslock == 0 && (kbdstate.led_mask & 1)) { - tcleval(".statusbar.8 configure -state active -text {CAPS LOCK SET! }"); - capslock = 1; - } - if(capslock == 1 && !(kbdstate.led_mask & 1)) { - if(numlock) tcleval(".statusbar.8 configure -state active -text {NUM LOCK SET! }"); - else tcleval(".statusbar.8 configure -state normal -text {}"); - capslock = 0; - } - if(numlock == 0 && (kbdstate.led_mask & 2)) { - tcleval(".statusbar.8 configure -state active -text {NUM LOCK SET! }"); - numlock = 1; - } - if(numlock == 1 && !(kbdstate.led_mask & 2)) { - if(capslock) tcleval(".statusbar.8 configure -state active -text {CAPS LOCK SET! }"); - else tcleval(".statusbar.8 configure -state normal -text {}"); - numlock = 0; + + if(kbdstate.led_mask & 1) { /* caps lock */ + tcleval(".statusbar.8 configure -state active -text {CAPS LOCK SET! }"); + } else if(kbdstate.led_mask & 2) { /* num lock */ + tcleval(".statusbar.8 configure -state active -text {NUM LOCK SET! }"); + } else { /* normal state */ + tcleval(".statusbar.8 configure -state normal -text {}"); } #endif state &=~Mod2Mask; /* 20170511 filter out NumLock status */ diff --git a/src/xschem.tcl b/src/xschem.tcl index b2f9cf42..73a8b221 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -3288,27 +3288,27 @@ proc setup_toolbar {} { FileOpen FileSave FileReload - "---" + --- EditUndo EditRedo EditCut EditCopy EditPaste EditDelete - "---" + --- EditDuplicate EditMove - "---" + --- EditPushSch EditPushSym EditPop - "---" + --- ViewRedraw ViewZoomIn ViewZoomOut ViewZoomBox ViewToggleColors - "---" + --- ToolInsertSymbol ToolInsertText ToolInsertWire @@ -3317,9 +3317,9 @@ proc setup_toolbar {} { ToolInsertPolygon ToolInsertArc ToolInsertCircle - "---" + --- ToolSearch - "---" + --- ToolJoinTrim ToolBreak } @@ -3493,8 +3493,9 @@ global env has_x xschem callback %T %x %y %N 0 0 %s } bind $window_path {xschem callback %T %x %y %N 0 0 %s} ;# 20161118 - bind $window_path {xschem callback %T %x %y 0 0 0 %s} - bind $window_path "xschem new_schematic switch $window_path {} + bind $window_path "focus $window_path; xschem callback %T %x %y 0 0 0 %s" + bind $window_path "focus $window_path + xschem new_schematic switch $window_path {} xschem callback %T %x %y 0 0 0 0" bind $window_path {} bind $window_path { @@ -4107,10 +4108,10 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] toolbar_create EditUndo "xschem undo; xschem redraw" "Undo" .menubar.edit.menu add command -label "Redo" -command "xschem redo; xschem redraw" -accelerator {Shift+U} toolbar_create EditRedo "xschem redo; xschem redraw" "Redo" + toolbar_create EditCut "xschem cut" "Cut" .menubar.edit.menu add command -label "Copy" -command "xschem copy" -accelerator Ctrl+C toolbar_create EditCopy "xschem copy" "Copy" .menubar.edit.menu add command -label "Cut" -command "xschem cut" -accelerator Ctrl+X - toolbar_create EditCut "xschem cut" "Cut" .menubar.edit.menu add command -label "Paste" -command "xschem paste" -accelerator Ctrl+V toolbar_create EditPaste "xschem paste" "Paste" .menubar.edit.menu add command -label "Delete" -command "xschem delete" -accelerator Del @@ -4154,16 +4155,6 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] -command { xschem netlist } - toolbar_create Waves { waves } "View results" - toolbar_create Simulate { - if { ![info exists simulate_oldbg] } { - set simulate_oldbg [.menubar.simulate cget -bg] - .menubar.simulate configure -bg red - simulate {.menubar.simulate configure -bg $::simulate_oldbg; unset ::simulate_oldbg} - } - } "Run simulation" - toolbar_create Netlist { xschem netlist } "Create netlist" - # create .menubar.layers.menu create_layers_menu .menubar.zoom.menu add checkbutton -label "Show ERC Info window" -variable show_infowindow \ @@ -4387,6 +4378,16 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] .menubar.simulation.menu add checkbutton -label "Use 'spiceprefix' attribute" -variable spiceprefix \ -command {xschem set spiceprefix $spiceprefix; xschem save; xschem reload} + toolbar_create Netlist { xschem netlist } "Create netlist" + toolbar_create Simulate { + if { ![info exists simulate_oldbg] } { + set simulate_oldbg [.menubar.simulate cget -bg] + .menubar.simulate configure -bg red + simulate {.menubar.simulate configure -bg $::simulate_oldbg; unset ::simulate_oldbg} + } + } "Run simulation" + toolbar_create Waves { waves } "View results" + pack .menubar.file -side left pack .menubar.edit -side left pack .menubar.option -side left