Some improvements to WindowsTty. The init function will now catch and
propagate an error.InvalidHandle so that caller can catch/handle it.
In addition, I added packed structs for the input/output
console modes which makes it convenient to manage the bits and is what
zigwin32 generates for its bindings. I also made these newly added types
and wrapper functions public as they can be generally useful for terminal
applications.
It should be pretty safe to assume that posix.empty_sigset
is supported on most, if not all, posix systems. Individual
OSes that need a different default value may add a case to
the switch like macos.
This should open up support for most other posix systems.
closes#151
Use an empty slice instead of undefined for the screen's default buffer.
This prevents segfaults if an app is deinitialized prior to receiving a
winsize event.
The focus handler was clearing memory after each frame, losing track of
the focused widget unless a new request was made. Properly handle focus
nodes and focused widgets. Send focus_in and focus_out events on
requestFocus
Accumulate any negative offsets in order to properly clip windows to
their parents. Previously, we only clipped if the window would be off
the screen from a negative offset. In the diagram below, we should
expect that if B is a child of A, it can't print in the non-overlapping
area. That is, B can only print in the overlapping region with A because
it is a child of A. This patch fixes this.
+-----------------------------------------------------+
| |
| +--------+ |
| | B | |
| | +---|-----+ |
| | | | | |
| +--------+ | |
| | | |
| | A | |
| +---------+ |
| |
| |
| |
+-----------------------------------------------------+
We set the value of pending_lines to -n, which has the side effect of
ignoring any subsequent scroll up events before the next draw. Subtract
the scroll up quantity from the current value, instead.
We previously passed the root window to the root surface, however the
root surface could actually be smaller than the root window. This can
lead to confusing rendering because it was possible for children to be
rendered outside of their parent
Modify the handling and hit testing:
- Only widgets which have event handlers or capture handlers are
considered for the hit list
- The topmost widget is always the target. We used to consider the last
widget which handled the mouse as the target. Now we consider the
topmost the target. This lets us generate an explicit mouse_enter
event since we can determine this before sending events
- Modify relevant widgets to remove noopEventHandler and remove this
function entirely
- mouse_enter and mouse_leave events are based on how browsers determine
these events. Any widget hit this frame that was not hit last frame
gets a mouse_enter. Any widget which was hit last_frame but not this
frame gets a mouse_leave.
Follow-up to my previous patch; this fixes an issue where the mouse_leave
event was never sent because maybe_last_handler was only set when there
was already a maybe_last_handler widget set.
The change here makes it so that every time an event is consumed libvaxis
keeps track of which widget did that through the maybe_last_handler
variable.
In other words: we update maybe_last_handler every time an event is
explcitly consumed.
The MouseHandler used to only consume the mouse events if there was a
last_handler widget defined AND whoever is using the API set
ctx.consume_event to true.
This change makes it so the event is consumed when ctx.consume_event is
set to true, even if there is no last_handler widget defined.
Don't require that surfaces explicitly declare mouse handling. We either
pass an event to the eventHandler or we don't. Along with this, we
remove all native widget passthrough events (IE we never pass an event
to a child). Native widgets which don't handle events also set
eventHandler to null, which prevents any null pointer issues also
Move capture handling of events to a different method on Widget. Having
capturing phase in the same method makes it very easy to accidentally
capture an event, producing confusing results. Browsers and GTK both
require handlers to explicitly listen to capturing phase events, so
there is precedence for having this as a separate method. For
applications that want to handle it all within the same function, the
signature is the same so they can use the same function for both methods
and achieve the same result.
Check if the target mods have shift or caps lock, and uppercase our
codepoint if they do. Someday we will need to allocate zg.case_data to
handle all of unicode casing, but for now we handle ascii until we
figure out a nice way to plumb in case_data.