Skip to content

Commit 81d7e31

Browse files
committed
Merge branch 'develop'
2 parents de477e1 + 263ee83 commit 81d7e31

File tree

6 files changed

+47
-21
lines changed

6 files changed

+47
-21
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/Cacao/UIApplication.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,13 @@ public final class UIApplication: UIResponder {
8383
/// after handling the event in your implementation.
8484
public func sendEvent(_ event: UIEvent) {
8585

86-
keyWindow?.sendEvent(event)
86+
self.windows.forEach { $0.sendEvent(event) }
8787
}
8888

89-
public func sendAction(_ selector: String, to target: AnyObject?, from sender: AnyObject?, for event: UIEvent?) {
89+
public func sendAction(_ selector: String,
90+
to target: AnyObject?,
91+
from sender: AnyObject?,
92+
for event: UIEvent?) {
9093

9194

9295
}

Sources/Cacao/UIEventEnvironment.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal final class UIEventEnvironment {
3939
guard let event = event(for: sdlEvent)
4040
else { handleNonUIEvent(sdlEvent); continue }
4141

42-
42+
application.sendEvent(event)
4343
}
4444

4545
// clear queue

Sources/Cacao/UIView.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,15 +694,6 @@ open class UIView: UIResponder {
694694
// CoreGraphics drawing
695695
draw(in: context)
696696

697-
/// FIXME: temporary workaround for Linux
698-
/// We have to convert the surface to PNG, even though we discard it.
699-
/// For some reason this changes something internally in Cairo,
700-
/// even though the texture and surface pixel buffer doesn't seem to change.
701-
#if os(Linux)
702-
let pngData = try! surface.writePNG()
703-
assert(pngData.isEmpty == false)
704-
#endif
705-
706697
/// flush surface
707698
surface.flush()
708699
surface.finish()

Sources/Cacao/UIWindow.swift

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,29 @@ open class UIWindow: UIView {
6161

6262
let gestureEnvironment = UIApplication.shared.gestureEnvironment
6363

64-
switch event.type {
64+
// handle touches event
65+
if let touchesEvent = event as? UITouchesEvent {
6566

66-
case .touches:
67+
gestureEnvironment.updateGestures(for: event, window: self)
68+
69+
sendTouches(for: touchesEvent)
70+
71+
} else if let pressesEvent = event as? UIPressesEvent {
72+
73+
guard isUserInteractionEnabled else { return }
6774

6875
gestureEnvironment.updateGestures(for: event, window: self)
6976

70-
/*
77+
sendButtons(for: pressesEvent)
78+
}
79+
80+
81+
82+
/*
83+
switch event.type {
84+
85+
case .touches:
86+
7187
let touches = event.touches(for: self) ?? []
7288

7389
let gestureRecognizers = touches.reduce([UIGestureRecognizer](), { $0 + ($1.gestureRecognizers ?? []) })
@@ -104,12 +120,12 @@ open class UIWindow: UIView {
104120
case .ended: touch.view?.touchesEnded(touches, with: event)
105121
case .cancelled: touch.view?.touchesCancelled(touches, with: event)
106122
}
107-
}*/
123+
}
108124

109125
default:
110126

111127
fatalError("\(event.type) events not implemented")
112-
}
128+
}*/
113129
}
114130

115131
// MARK: - Subclassed Methods
@@ -140,7 +156,23 @@ open class UIWindow: UIView {
140156
layoutIfNeeded()
141157
}
142158

143-
private func sendTouches(for event: UIEvent) {
159+
private func sendTouches(for event: UITouchesEvent) {
160+
161+
let touches = event.touches
162+
163+
for touch in touches {
164+
165+
switch touch.phase {
166+
case .began: touch.view?.touchesBegan(touches, with: event)
167+
case .moved: touch.view?.touchesMoved(touches, with: event)
168+
case .stationary: break
169+
case .ended: touch.view?.touchesEnded(touches, with: event)
170+
case .cancelled: touch.view?.touchesCancelled(touches, with: event)
171+
}
172+
}
173+
}
174+
175+
private func sendButtons(for event: UIPressesEvent) {
144176

145177

146178
}

Sources/CacaoDemo/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
3131

3232
self.window = UIWindow(frame: UIScreen.main.bounds)
3333

34-
self.window?.rootViewController = TimerViewController()
34+
self.window?.rootViewController = SwitchViewController()
3535

3636
self.window?.makeKeyAndVisible()
3737

0 commit comments

Comments
 (0)