Skip to content

Event subscriptions#122

Merged
hecrj merged 22 commits into
masterfrom
feature/event-subscriptions
Dec 16, 2019
Merged

Event subscriptions#122
hecrj merged 22 commits into
masterfrom
feature/event-subscriptions

Conversation

@hecrj
Copy link
Copy Markdown
Member

@hecrj hecrj commented Dec 14, 2019

Closes #29, closes #109, and fixes #123.

Stopwatch - Iced

This PR adds support for event subscriptions. Event subscriptions are inspired by Elm's subscriptions and can be used to listen to external events that do not necessarily occur as a response to some interaction or command. For instance, you can use event subscriptions to create a websocket connection, listen to incoming messages, and even handle reconnects graciously.

Event subscriptions are built on top of futures::stream::Stream. The messages produced by a subscription are provided to Application::update and, of course, can be used to change the state of the Application.

The iced_winit shell keeps a subscription alive as long as the user returns it in the new Application::subscription method. Therefore, unsubscribing simply consists in not returning the subscription anymore.

Moreover, subscriptions can be created by libraries and/or end-users using the new subscription::Recipe trait (name subject to change), which requires just a couple of methods.

For now, there is only one built-in Subscription in iced_native: subscription::events. This subscription will notify an application of all the runtime events that occur, producing Event values. It can be useful if you want to listen to keyboard or mouse events (and most likely window events soon):

Events - Iced

Two examples have been added that showcase event subscriptions:

  • events, which uses the new built-in subscription::events.
  • stopwatch, which showcases a custom event subscription that produces messages periodically at a configurable time interval.

@hecrj hecrj added the feature New feature or request label Dec 14, 2019
@hecrj hecrj added this to the 0.1.0 milestone Dec 14, 2019
@hecrj hecrj self-assigned this Dec 14, 2019
@clarkmoody
Copy link
Copy Markdown
Contributor

Demo app works on my system, thanks!

Testing my reflexes now.
Screen Shot 2019-12-14 at 12 21 52 AM

@hecrj hecrj merged commit 0f2e20f into master Dec 16, 2019
@hecrj hecrj deleted the feature/event-subscriptions branch December 16, 2019 20:38
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
sctk: Use empty input region for subsurfaces

This seems to work, and is a better way to deal with subsurface input if
there aren't any problems. This way, input events simply go to the
parent surface, so we don't have to deal with various edge cases related
to that. (Though for compositor-side issues, we still need to fix those
for other clients.)

This helps with an issue with drag-and-drop and subsurfaces on Smithay,
and a different issue on Kwin (in KDE 5.27, at least).

sctk: Fix handling of DnD with subsurfaces (iced-rs#122)

Map subsurface to parent and add offset.

fixes for dnd

Send `DataSource` events to all surfaces

Previously these events are directed to the first surface, then removed
from `sctk_events`. Which is definitely not right.

fix(sctk): nested popup parent
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
sctk: Use empty input region for subsurfaces

This seems to work, and is a better way to deal with subsurface input if
there aren't any problems. This way, input events simply go to the
parent surface, so we don't have to deal with various edge cases related
to that. (Though for compositor-side issues, we still need to fix those
for other clients.)

This helps with an issue with drag-and-drop and subsurfaces on Smithay,
and a different issue on Kwin (in KDE 5.27, at least).

sctk: Fix handling of DnD with subsurfaces (iced-rs#122)

Map subsurface to parent and add offset.

fixes for dnd

Send `DataSource` events to all surfaces

Previously these events are directed to the first surface, then removed
from `sctk_events`. Which is definitely not right.

fix(sctk): nested popup parent
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
sctk: Use empty input region for subsurfaces

This seems to work, and is a better way to deal with subsurface input if
there aren't any problems. This way, input events simply go to the
parent surface, so we don't have to deal with various edge cases related
to that. (Though for compositor-side issues, we still need to fix those
for other clients.)

This helps with an issue with drag-and-drop and subsurfaces on Smithay,
and a different issue on Kwin (in KDE 5.27, at least).

sctk: Fix handling of DnD with subsurfaces (iced-rs#122)

Map subsurface to parent and add offset.

fixes for dnd

Send `DataSource` events to all surfaces

Previously these events are directed to the first surface, then removed
from `sctk_events`. Which is definitely not right.

fix(sctk): nested popup parent
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
sctk: Use empty input region for subsurfaces

This seems to work, and is a better way to deal with subsurface input if
there aren't any problems. This way, input events simply go to the
parent surface, so we don't have to deal with various edge cases related
to that. (Though for compositor-side issues, we still need to fix those
for other clients.)

This helps with an issue with drag-and-drop and subsurfaces on Smithay,
and a different issue on Kwin (in KDE 5.27, at least).

sctk: Fix handling of DnD with subsurfaces (iced-rs#122)

Map subsurface to parent and add offset.

fixes for dnd

Send `DataSource` events to all surfaces

Previously these events are directed to the first surface, then removed
from `sctk_events`. Which is definitely not right.

fix(sctk): nested popup parent
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
sctk: Use empty input region for subsurfaces

This seems to work, and is a better way to deal with subsurface input if
there aren't any problems. This way, input events simply go to the
parent surface, so we don't have to deal with various edge cases related
to that. (Though for compositor-side issues, we still need to fix those
for other clients.)

This helps with an issue with drag-and-drop and subsurfaces on Smithay,
and a different issue on Kwin (in KDE 5.27, at least).

sctk: Fix handling of DnD with subsurfaces (iced-rs#122)

Map subsurface to parent and add offset.

fixes for dnd

Send `DataSource` events to all surfaces

Previously these events are directed to the first surface, then removed
from `sctk_events`. Which is definitely not right.

fix(sctk): nested popup parent
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
sctk: Use empty input region for subsurfaces

This seems to work, and is a better way to deal with subsurface input if
there aren't any problems. This way, input events simply go to the
parent surface, so we don't have to deal with various edge cases related
to that. (Though for compositor-side issues, we still need to fix those
for other clients.)

This helps with an issue with drag-and-drop and subsurfaces on Smithay,
and a different issue on Kwin (in KDE 5.27, at least).

sctk: Fix handling of DnD with subsurfaces (iced-rs#122)

Map subsurface to parent and add offset.

fixes for dnd

Send `DataSource` events to all surfaces

Previously these events are directed to the first surface, then removed
from `sctk_events`. Which is definitely not right.

fix(sctk): nested popup parent
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
sctk: Use empty input region for subsurfaces

This seems to work, and is a better way to deal with subsurface input if
there aren't any problems. This way, input events simply go to the
parent surface, so we don't have to deal with various edge cases related
to that. (Though for compositor-side issues, we still need to fix those
for other clients.)

This helps with an issue with drag-and-drop and subsurfaces on Smithay,
and a different issue on Kwin (in KDE 5.27, at least).

sctk: Fix handling of DnD with subsurfaces (iced-rs#122)

Map subsurface to parent and add offset.

fixes for dnd

Send `DataSource` events to all surfaces

Previously these events are directed to the first surface, then removed
from `sctk_events`. Which is definitely not right.

fix(sctk): nested popup parent
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
ryanabx pushed a commit to ryanabx-contrib/iced that referenced this pull request Jul 29, 2024
Map subsurface to parent and add offset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

None of the async examples are actually async Allow defining global shortcuts Event subscriptions

2 participants