987 focus to the previous focusView.." |
987 focus to the previous focusView.." |
988 |
988 |
989 |viewToGetFocus viewUnderMousePointer ms| |
989 |viewToGetFocus viewUnderMousePointer ms| |
990 |
990 |
991 windowGroup notNil ifTrue:[ |
991 windowGroup notNil ifTrue:[ |
992 "/ a hack for window managers, which do not honor the |
992 "/ a hack for window managers, which do not honor the |
993 "/ WMTransientFor attribute (i.e. XQuartz). |
993 "/ WMTransientFor attribute (i.e. XQuartz). |
994 "/ This flag would prevent a popup (dialog or notification) from being |
994 "/ This flag would prevent a popup (dialog or notification) from being |
995 "/ covered by its underlying regular view. But on MAC, it does not. |
995 "/ covered by its underlying regular view. But on MAC, it does not. |
996 "/ However, focus is coming in, when doing this, so we manually fix this |
996 "/ However, focus is coming in, when doing this, so we manually fix this |
997 "/ here. Should not hurt on other systems, where the view is already on top. |
997 "/ here. Should not hurt on other systems, where the view is already on top. |
998 "/ if it does, add some conditional check here (device WMTransientForBroken or similar) |
998 "/ if it does, add some conditional check here (device WMTransientForBroken or similar) |
999 "/ You can check for you WM to be correct, by disabling the line below, |
999 "/ You can check for you WM to be correct, by disabling the line below, |
1000 "/ then click on a smallLint-note icon, to see the smallLint info, |
1000 "/ then click on a smallLint-note icon, to see the smallLint info, |
1001 "/ then click on the underlying codeView, to raise it. |
1001 "/ then click on the underlying codeView, to raise it. |
1002 "/ if the smallLint view can be covered, your WM is broken. |
1002 "/ if the smallLint view can be covered, your WM is broken. |
1003 "/ cg: turns out to be a bad idea - it does help solve the above problem (on mac), |
1003 "/ cg: turns out to be a bad idea - it does help solve the above problem (on mac), |
1004 "/ but raises unwanted topViews (for example, if a modal dialog's popup menu closes) |
1004 "/ but raises unwanted topViews (for example, if a modal dialog's popup menu closes) |
1005 "/ windowGroup topViews first raise. |
1005 "/ windowGroup topViews first raise. |
1006 |
1006 |
1007 "/ I got the focus - tell the current focus-windowgroup |
1007 "/ I got the focus - tell the current focus-windowgroup |
1008 "/ that its focus is gone elsewhere ... |
1008 "/ that its focus is gone elsewhere ... |
1009 "/ 'focusIn ' print. windowGroup process name printCR. |
1009 "/ 'focusIn ' print. windowGroup process name printCR. |
1010 "/ 'focusView is ' print. windowGroup focusView printCR. |
1010 "/ 'focusView is ' print. windowGroup focusView printCR. |
1011 |
1011 |
1012 "/ although the foucs has usually already been taken (see focusOut), |
1012 "/ although the foucs has usually already been taken (see focusOut), |
1013 "/ there are situations where this does not happen; |
1013 "/ there are situations where this does not happen; |
1014 "/ I am not sure if that is a WM bug or an ST/X bug, but sometimes (with popups), |
1014 "/ I am not sure if that is a WM bug or an ST/X bug, but sometimes (with popups), |
1015 "/ I only get a focus in. Could be a race, when the loosing view is already destroyed, |
1015 "/ I only get a focus in. Could be a race, when the loosing view is already destroyed, |
1016 "/ at the time the focus event arrives. |
1016 "/ at the time the focus event arrives. |
1017 "/ Anyway: it should not matter to take it again... |
1017 "/ Anyway: it should not matter to take it again... |
1018 WindowGroup takeFocusFromDevice:device. |
1018 WindowGroup takeFocusFromDevice:device. |
1019 |
1019 device focusWindowGroup:windowGroup. |
1020 windowGroup isInModalLoop ifTrue:[ |
1020 |
1021 windowGroup allTopViewsDo:[:t | |
1021 windowGroup isInModalLoop ifTrue:[ |
1022 t ~~ self ifTrue:[ |
1022 windowGroup allTopViewsDo:[:t | |
1023 t focusIn. |
1023 t ~~ self ifTrue:[ |
1024 t raise. |
1024 t focusIn. |
1025 ^ self. |
1025 t raise. |
1026 ]. |
1026 ^ self. |
1027 ] |
1027 ]. |
1028 ]. |
1028 ] |
1029 |
1029 ]. |
1030 "/ Transcript show:self; show:' focus in '; showCR:windowGroup isInModalLoop. |
1030 |
1031 |
1031 "/ Transcript show:self; show:' focus in '; showCR:windowGroup isInModalLoop. |
1032 viewToGetFocus := windowGroup focusView. |
1032 |
1033 viewToGetFocus isNil ifTrue:[ |
1033 viewToGetFocus := windowGroup focusView. |
1034 UserPreferences current focusFollowsMouse ~~ false ifTrue:[ |
1034 viewToGetFocus isNil ifTrue:[ |
1035 viewUnderMousePointer := windowGroup pointerView. |
1035 UserPreferences current focusFollowsMouse ~~ false ifTrue:[ |
1036 "/ 'viewUnderMousePointer is ' print. viewUnderMousePointer printCR. |
1036 viewUnderMousePointer := windowGroup pointerView. |
1037 (viewUnderMousePointer notNil |
1037 "/ 'viewUnderMousePointer is ' print. viewUnderMousePointer printCR. |
1038 and:[viewUnderMousePointer isKeyboardConsumer |
1038 (viewUnderMousePointer notNil |
1039 and:[viewUnderMousePointer wantsFocusWithPointerEnter]]) ifTrue:[ |
1039 and:[viewUnderMousePointer isKeyboardConsumer |
1040 viewToGetFocus := viewUnderMousePointer. |
1040 and:[viewUnderMousePointer wantsFocusWithPointerEnter]]) ifTrue:[ |
1041 ] |
1041 viewToGetFocus := viewUnderMousePointer. |
1042 ]. |
1042 ] |
1043 ]. |
1043 ]. |
1044 viewToGetFocus isNil ifTrue:[ |
1044 ]. |
1045 windowGroup focusBackToPreviousFocusView. |
1045 viewToGetFocus isNil ifTrue:[ |
1046 windowGroup focusView isNil ifTrue:[ |
1046 windowGroup focusBackToPreviousFocusView. |
1047 self assignInitialKeyboardFocus. |
1047 windowGroup focusView isNil ifTrue:[ |
1048 ]. |
1048 self assignInitialKeyboardFocus. |
1049 ] ifFalse:[ |
1049 "/ windowGroup focusView isNil ifTrue:[ |
1050 "/ v requestFocus. - will be denied; but we must force it here |
1050 "/ 'No focusWindow' infoPrintCR. |
1051 "/ to force a change... |
1051 "/ ]. |
1052 windowGroup setFocusView:nil. |
1052 ]. |
1053 windowGroup focusView:viewToGetFocus byTab:nil. |
1053 ] ifFalse:[ |
1054 ]. |
1054 "/ v requestFocus. - will be denied; but we must force it here |
1055 |
1055 "/ to force a change... |
1056 "/ optionally bring the window to the front after some delay. |
1056 windowGroup setFocusView:nil. |
1057 "/ but not, if my windowGroup is in a modal or popup action |
1057 windowGroup focusView:viewToGetFocus byTab:nil. |
1058 (ms := UserPreferences current autoRaiseOnFocusInDelay) notNil ifTrue:[ |
1058 ]. |
1059 self scheduleAutoRaiseAfter:ms |
1059 |
1060 ]. |
1060 "/ optionally bring the window to the front after some delay. |
|
1061 "/ but not, if my windowGroup is in a modal or popup action |
|
1062 (ms := UserPreferences current autoRaiseOnFocusInDelay) notNil ifTrue:[ |
|
1063 self scheduleAutoRaiseAfter:ms |
|
1064 ]. |
1061 ]. |
1065 ]. |
1062 super focusIn |
1066 super focusIn |
1063 |
1067 |
1064 "Modified: / 20-01-2011 / 20:51:20 / cg" |
1068 "Modified: / 20-01-2011 / 20:51:20 / cg" |
|
1069 "Modified: / 19-06-2018 / 14:01:54 / Claus Gittinger" |
1065 ! |
1070 ! |
1066 |
1071 |
1067 focusOut |
1072 focusOut |
1068 "the top-view lost the keyboard focus (via the window manager). |
1073 "the top-view lost the keyboard focus (via the window manager). |
1069 I.e. the mouse was moved out of the topView area." |
1074 I.e. the mouse was moved out of the topView area." |