[Cuis-dev] Update: Alt+Return as a full screen toggle shortcut

Mauro Rizzi mrizzi at fi.uba.ar
Mon Dec 21 06:43:52 PST 2020


Hello Luciano,

I think global shortcuts should be handled first, like it is now; if you
> give the opportunity to morphs to handle it first I wouldn’t be able to
> override some of the shortcuts I’m using and I would have to change even
> more code all over the place to make my shortcuts work.
>

I agree with you, and this is one of the concerns I denoted with Ken's
proposed solution. However this wouldn't be an issue with the method I
first proposed since the global shortcuts are always checked first, as long
as the morph doesn't tell you to not check it.

You could also have not overridable shortcuts by just placing them outside
the closure of the shouldOverride ifFalse call.

This means that if you have a shortcut that collides with a global one in
your code you can either disable all global shortcuts when your morph has
keyboard focus by implementing a should override method that returns true
or, if you only want to intercept a single one, you can check in that
method if the keyboard event is for that specific one and return true or
false accordingly.

This solution where we ask the morph whether it wants to override the
keyboard input or not is not intended as a final well modeled solution but
rather a stopgap measure to allow morphs to easily override global keyboard
events without having to refactor half the system.

However I'm not sure how we would be able to handle global shortcuts first
while giving morphs the opportunity to override them, without first asking
them what they want to do.

Also, if the handling is done in the event classes then nothing was solved.
> I agree with Juan that we have the option to handle global shortcuts either
> in the hand or in the world. Both options make it easy to change the
> behaviour, either by introducing a new hand or a new world.
>

I do agree that the global shortcuts should be handled by the world. That
is, the keyboard event sentTo method should invoke a world method that
checks if itself is a global shortcut (if the morph didn't ask to override
it first). This would basically be done by replacing the code inside the
shouldOverride if False with this new world method call.

never needed the full screen thing in Cuis because my X11 window manager
> (dwm) does that. In fact, I patched it to do this the way I like it with
> win-esc and it works with any window (not only Cuis). I guess some window
> managers don’t have a shortcut for full screen? Or are not configurable
> with the shortcut you prefer and not easy to patch?
>

I'm pretty sure this full screen fix came up because this doesn't hold true
for the windows version. Sadly not everyone can run a Unix OS exclusively.

Can you maybe elaborate a bit in the model you propose should be
implemented?

Cheers!
*Mauro Rizzi*

El lun, 21 dic 2020 a las 1:46, Luciano Notarfrancesco (<luchiano at gmail.com>)
escribió:

> I think global shortcuts should be handled first, like it is now; if you
> give the opportunity to morphs to handle it first I wouldn’t be able to
> override some of the shortcuts I’m using and I would have to change even
> more code all over the place to make my shortcuts work.
>
> Also, if the handling is done in the event classes then nothing was
> solved. I agree with Juan that we have the option to handle global
> shortcuts either in the hand or in the world. Both options make it easy to
> change the behaviour, either by introducing a new hand or a new world.
>
> I never needed the full screen thing in Cuis because my X11 window manager
> (dwm) does that. In fact, I patched it to do this the way I like it with
> win-esc and it works with any window (not only Cuis). I guess some window
> managers don’t have a shortcut for full screen? Or are not configurable
> with the shortcut you prefer and not easy to patch?
>
>
> On Mon, 21 Dec 2020 at 9:22 AM, Mauro Rizzi <mrizzi at fi.uba.ar> wrote:
>
>> Hello Ken
>>
>> You're right, I didn't think about the wasHandled: method before and it's
>> a better solution than the one I proposed (assuming the methods
>> isFindClassShortcut and isCloseWindowShortcut and Franco's
>> isFullScreenShortcut would be moved into handleKeyEvent and the processKey*
>> ones would have their return removed).
>>
>> It would look something like:
>>
>> vvv============vvv
>> KeyBoardEvent>>
>>
>> sentTo: aMorph localPosition: positionInAMorph
>>
>>         "Dispatch the receiver into anObject"
>>
>>    type == #keystroke ifTrue: [
>>          aMorph
>>                  processKeystroke: self
>>                  localPosition: positionInAMorph ].
>>    type == #keyDown ifTrue: [
>>          aMorph
>>                 processKeyDown: self
>>                 localPosition: positionInAMorph ].
>>    type == #keyUp ifTrue: [
>>          aMorph
>>                 processKeyUp: self
>>                 localPosition: positionInAMorph ].
>>
>>     (self wasHandled)
>>          ifTrue: [^aMorph] "done"
>>          ifFalse: [<globaldefaultKeyHandler> handleKeyEvent: self]
>>
>>
>> ^^^============^^^
>>   "Inside globaldefaultKeyHandler, of course if someone thinks this
>> object shouldn't exist you could just put it's content on the ifFalse
>> closure. Also technically the ifFalse is unnecessary, but it does provide a
>> lot of clarity."
>> handleKeyEvent: aKeyboardEvent
>>
>>         aKeyboardEvent isFindClassShortcut
>>                 ifTrue: [ ^ BrowserWindow findClass].
>>         aKeyboardEvent isCloseWindowShortcut
>>                 ifTrue: [ ^ aKeyboardEvent closeCurrentWindowOf: aMorph
>>         aKeyboardEvent isFullScreenShortcut
>>                 ifTrue: [ ^ Display toggleFullScreen ]
>>
>> ^^^============^^^
>>
>> We would have to refactor the current senders of wasHandled: to take into
>> account this change.
>>
>> Thinking on the readability of this method and it might be a bit hard to
>> follow the wasHandled method call for someone who is first discovering it,
>> since they potentially might not understand how keyboardEvent knows the
>> event was handled.
>>
>> I do approve of the idea of having global keystrokes be in a separate
>> object than the standard keyboardEvent, I think it would give clarity to
>> the chain of responsibility if it goes into the morph and then into a
>> global keystroke handler object.
>>
>> Thinking about it from an usability standpoint using franco's full screen
>> shorcut (alt + enter) we would have to (with both of the proposed
>> implementations) make the isFullScreenShortcut check on the keyboardEvent
>> inside the target morph to avoid processing the input at the morph level
>> and marking it as handled.
>>
>> What I mean with this is that all morphs would be responsible of knowing
>> what inputs they should ignore because the keystrokes that we want to
>> capture for system events would also be considered valid inside the morph
>> and would be executed.
>>
>> For example if you press shift enter while writing in a method editor the
>> innerTextPane will happily process the input, put the newline into the pane
>> and mark the event as handled, following that the keyboardEvent will say
>> "ah, well that is done with then, moving on" and the findClass dialogue
>> won't pop up, to avoid this you'd have to check whether the current
>> keystroke is one of the system ones inside the morph's execution chain.
>>
>> While I do like your implementation significantly more I think the one I
>> recommended earlier gets around this issue. Since it becomes something
>> optional, your morph can decide if it wants to override certain keystrokes
>> or not but if you don't implement the method shouldOverride (Note: this is
>> a bad name for this method) then you go back to the current behaviour.
>>
>> Basically one option gives the morph the choice to tell you if it wants
>> to override or not. The other one gives the morph the responsibility of
>> telling you whether you should override or not.
>>
>> And I still feel keyboardEvent should have a hierarchy of the 3 types of
>> keyboard events rather than having a type instance variable.
>>
>> I just want to clarify I quite enjoy writing walls of text and this is
>> intended as constructive brainstorming. I'm sorry if it comes out as
>> anything but.
>>
>> Cheers!
>> *Mauro Rizzi*
>>
>> El dom, 20 dic 2020 a las 20:54, <ken.dickey at whidbey.com> escribió:
>>
>>> On 2020-12-20 21:25, Mauro Rizzi wrote:
>>>
>>> ..
>>> > shouldOverride := aMorph shouldOverride: self
>>>
>>> I am suggesting that if the Morph processes the keystroke, it _has_
>>> overriden and _does NOT need_ a #shouldOverride method.
>>>
>>> So
>>> vvv============vvv
>>> KeyBoardEvent>>
>>>
>>> sentTo: aMorph localPosition: positionInAMorph
>>>
>>>         "Dispatch the receiver into anObject"
>>>
>>>    type == #keystroke ifTrue: [
>>>         self isFindClassShortcut
>>>                 ifTrue: [ ^ BrowserWindow findClass].
>>>         self isCloseWindowShortcut
>>>                 ifTrue: [ ^ self closeCurrentWindowOf: aMorph ].
>>>         ^ aMorph processKeystroke: self
>>>                  localPosition: positionInAMorph ].
>>>    type == #keyDown ifTrue: [
>>>                 ^ aMorph
>>>                         processKeyDown: self
>>>                         localPosition: positionInAMorph ].
>>>    type == #keyUp ifTrue: [
>>>                 ^ aMorph
>>>                         processKeyUp: self
>>>                         localPosition: positionInAMorph ].
>>>
>>>     (self wasHandled)
>>>          ifTrue: [^aMorph] "done"
>>>          ifFalse: [<globaldefaultKeyHandler> handleKeyEvent: self]
>>>
>>>
>>> ^^^============^^^
>>>
>>> Note: I am not an expert here.  Just a guess..
>>>
>>> Prototype is best.
>>> -KenD
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20201221/1ccc70d8/attachment-0001.htm>


More information about the Cuis-dev mailing list