Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multitouch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
multitouch
Commits
b3dd89c3
Commit
b3dd89c3
authored
12 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Added 'threaded' keyword argument to event driver.
parent
a7d80112
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/driver.py
+11
-2
11 additions, 2 deletions
src/driver.py
tests/draw.py
+1
-4
1 addition, 4 deletions
tests/draw.py
tests/testapp.py
+1
-4
1 addition, 4 deletions
tests/testapp.py
with
13 additions
and
10 deletions
src/driver.py
+
11
−
2
View file @
b3dd89c3
from
threading
import
Thread
from
logger
import
Logger
...
...
@@ -24,14 +26,21 @@ class EventDriver(Logger):
if
self
.
root_area
.
contains_event
(
event
):
self
.
root_area
.
delegate_event
(
event
)
def
start
(
self
):
def
start
(
self
,
threaded
=
False
):
"""
Start the event loop. A root area is needed to be able to delegate
events, so check if it exists first.
events, so check if it exists first. The argument determines if the
driver should start in a new (daemon) thread.
"""
if
not
self
.
root_area
:
raise
ValueError
(
'
Cannot start event server without root area.
'
)
if
threaded
:
thread
=
Thread
(
target
=
self
.
start
)
thread
.
daemon
=
True
thread
.
start
()
return
thread
self
.
start_loop
()
def
start_loop
(
self
):
...
...
This diff is collapsed.
Click to expand it.
tests/draw.py
+
1
−
4
View file @
b3dd89c3
#!/usr/bin/env python
from
__future__
import
division
import
pygame
from
threading
import
Thread
from
math
import
degrees
from
src
import
FullscreenArea
,
create_driver
...
...
@@ -160,9 +159,7 @@ area.on_point_up(lambda g: points.remove(g.get_event().point))
try
:
# Start touch gesture server in separate thread
thread
=
Thread
(
target
=
driver
.
start
)
thread
.
daemon
=
True
thread
.
start
()
driver
.
start
(
threaded
=
True
)
# Start GUI event loop
def
is_quit_event
(
e
):
...
...
This diff is collapsed.
Click to expand it.
tests/testapp.py
+
1
−
4
View file @
b3dd89c3
...
...
@@ -342,10 +342,7 @@ if __name__ == '__main__':
create_context_window
(
800
,
600
,
on_show
)
# Run multi-touch gesture server in separate thread
driver
=
mt
.
create_driver
(
screen
)
mt_thread
=
Thread
(
target
=
driver
.
start
)
mt_thread
.
daemon
=
True
mt_thread
.
start
()
mt
.
create_driver
(
screen
).
start
(
threaded
=
True
)
# Flick movement is also handled in a separate thread
flicks
=
FlickThread
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment