Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Fred Fonkle
Krita
Commits
26e76078
Commit
26e76078
authored
Apr 18, 2016
by
Dmitry Kazakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compress mouse events as well
It really needs testing!
parent
44306bff
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
38 deletions
+58
-38
libs/ui/input/kis_input_manager.cpp
libs/ui/input/kis_input_manager.cpp
+48
-32
libs/ui/input/kis_input_manager.h
libs/ui/input/kis_input_manager.h
+4
-0
libs/ui/input/kis_input_manager_p.cpp
libs/ui/input/kis_input_manager_p.cpp
+4
-4
libs/ui/input/kis_input_manager_p.h
libs/ui/input/kis_input_manager_p.h
+2
-2
No files found.
libs/ui/input/kis_input_manager.cpp
View file @
26e76078
...
...
@@ -210,6 +210,49 @@ bool KisInputManager::eventFilter(QObject* object, QEvent* event)
return
eventFilterImpl
(
event
);
}
template
<
class
Event
>
bool
KisInputManager
::
compressMoveEventCommon
(
Event
*
event
)
{
/**
* We construct a copy of this event object, so we must ensure it
* has a correct type.
*/
static_assert
(
std
::
is_same
<
Event
,
QMouseEvent
>::
value
||
std
::
is_same
<
Event
,
QTabletEvent
>::
value
,
"event should a mouse or a tablet event"
);
bool
retval
=
false
;
/**
* Compress the events if the tool doesn't need high resolution input
*/
if
((
event
->
type
()
==
QEvent
::
MouseMove
||
event
->
type
()
==
QEvent
::
TabletMove
)
&&
(
!
d
->
matcher
.
supportsHiResInputEvents
()
||
d
->
testingCompressBrushEvents
))
{
d
->
compressedMoveEvent
.
reset
(
new
Event
(
*
event
));
d
->
moveEventCompressor
.
start
();
/**
* On Linux Qt eats the rest of unneeded events if we
* ignore the first of the chunk of tablet events. So
* generally we should never activate this feature. Only
* for testing purposes!
*/
if
(
d
->
testingAcceptCompressedTabletEvents
)
{
event
->
setAccepted
(
true
);
}
retval
=
true
;
}
else
{
slotCompressedMoveEvent
();
retval
=
d
->
handleCompressedTabletEvent
(
event
);
}
return
retval
;
}
bool
KisInputManager
::
eventFilterImpl
(
QEvent
*
event
)
{
// TODO: Handle touch events correctly.
...
...
@@ -281,12 +324,9 @@ bool KisInputManager::eventFilterImpl(QEvent * event)
d
->
debugEvent
<
QMouseEvent
,
true
>
(
event
);
break_if_should_ignore_cursor_events
();
if
(
!
d
->
matcher
.
pointerMoved
(
event
))
{
//Update the current tool so things like the brush outline gets updated.
d
->
toolProxy
->
forwardHoverEvent
(
event
);
}
retval
=
true
;
event
->
setAccepted
(
retval
);
QMouseEvent
*
mouseEvent
=
static_cast
<
QMouseEvent
*>
(
event
);
retval
=
compressMoveEventCommon
(
mouseEvent
);
break
;
}
case
QEvent
::
Wheel
:
{
...
...
@@ -376,33 +416,9 @@ bool KisInputManager::eventFilterImpl(QEvent * event)
case
QEvent
::
TabletMove
:
{
d
->
debugEvent
<
QTabletEvent
,
false
>
(
event
);
QTabletEvent
*
tabletEvent
=
static_cast
<
QTabletEvent
*>
(
event
);
/**
* Compress the events if the tool doesn't need high resolution input
*/
if
(
tabletEvent
->
type
()
==
QEvent
::
TabletMove
&&
(
!
d
->
matcher
.
supportsHiResInputEvents
()
||
d
->
testingCompressBrushEvents
))
{
d
->
compressedMoveEvent
.
reset
(
new
QTabletEvent
(
*
tabletEvent
));
d
->
moveEventCompressor
.
start
();
/**
* On Linux Qt eats the rest of unneeded events if we
* ignore the first of the chunk of tablet events. So
* generally we should never activate this feature. Only
* for testing purposes!
*/
if
(
d
->
testingAcceptCompressedTabletEvents
)
{
tabletEvent
->
setAccepted
(
true
);
}
retval
=
true
;
}
else
{
slotCompressedMoveEvent
();
retval
=
d
->
handleCompressedTabletEvent
(
tabletEvent
);
}
QTabletEvent
*
tabletEvent
=
static_cast
<
QTabletEvent
*>
(
event
);
retval
=
compressMoveEventCommon
(
tabletEvent
);
/**
* The flow of tablet events means the tablet is in the
...
...
libs/ui/input/kis_input_manager.h
View file @
26e76078
...
...
@@ -115,6 +115,10 @@ private Q_SLOTS:
void
profileChanged
();
void
slotCompressedMoveEvent
();
private:
template
<
class
Event
>
bool
compressMoveEventCommon
(
Event
*
event
);
private:
class
Private
;
Private
*
const
d
;
...
...
libs/ui/input/kis_input_manager_p.cpp
View file @
26e76078
...
...
@@ -426,15 +426,15 @@ void KisInputManager::Private::eatOneMousePress()
eventEater
.
eatOneMousePress
();
}
bool
KisInputManager
::
Private
::
handleCompressedTabletEvent
(
Q
Tablet
Event
*
t
event
)
bool
KisInputManager
::
Private
::
handleCompressedTabletEvent
(
QEvent
*
event
)
{
bool
retval
=
false
;
if
(
!
matcher
.
pointerMoved
(
t
event
))
{
toolProxy
->
forwardHoverEvent
(
t
event
);
if
(
!
matcher
.
pointerMoved
(
event
))
{
toolProxy
->
forwardHoverEvent
(
event
);
}
retval
=
true
;
t
event
->
setAccepted
(
true
);
event
->
setAccepted
(
true
);
return
retval
;
}
libs/ui/input/kis_input_manager_p.h
View file @
26e76078
...
...
@@ -47,7 +47,7 @@ public:
bool
processUnhandledEvent
(
QEvent
*
event
);
void
setupActions
();
void
saveTouchEvent
(
QTouchEvent
*
event
);
bool
handleCompressedTabletEvent
(
Q
Tablet
Event
*
t
event
);
bool
handleCompressedTabletEvent
(
QEvent
*
event
);
KisInputManager
*
q
;
...
...
@@ -67,7 +67,7 @@ public:
QObject
*
eventsReceiver
=
0
;
KisSignalCompressor
moveEventCompressor
;
QScopedPointer
<
Q
Tablet
Event
>
compressedMoveEvent
;
QScopedPointer
<
QEvent
>
compressedMoveEvent
;
bool
testingAcceptCompressedTabletEvents
=
false
;
bool
testingCompressBrushEvents
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment