Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KWin
Commits
41fbb0a6
Commit
41fbb0a6
authored
Nov 25, 2014
by
Martin Flöser
Browse files
[server] Keep timestamp in SeatInterface instead of PointerInterface
parent
12477a66
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/wayland/autotests/client/test_wayland_seat.cpp
View file @
41fbb0a6
...
...
@@ -315,17 +315,17 @@ void TestWaylandSeat::testPointer()
QCOMPARE
(
enteredSpy
.
first
().
last
().
toPoint
(),
QPoint
(
10
,
3
));
// test motion
serverPointer
->
update
Timestamp
(
1
);
m_seatInterface
->
set
Timestamp
(
1
);
serverPointer
->
setGlobalPos
(
QPoint
(
10
,
16
));
QVERIFY
(
motionSpy
.
wait
());
QCOMPARE
(
motionSpy
.
first
().
first
().
toPoint
(),
QPoint
(
0
,
1
));
QCOMPARE
(
motionSpy
.
first
().
last
().
value
<
quint32
>
(),
quint32
(
1
));
// test axis
serverPointer
->
update
Timestamp
(
2
);
m_seatInterface
->
set
Timestamp
(
2
);
serverPointer
->
axis
(
Qt
::
Horizontal
,
10
);
QVERIFY
(
axisSpy
.
wait
());
serverPointer
->
update
Timestamp
(
3
);
m_seatInterface
->
set
Timestamp
(
3
);
serverPointer
->
axis
(
Qt
::
Vertical
,
20
);
QVERIFY
(
axisSpy
.
wait
());
QCOMPARE
(
axisSpy
.
first
().
at
(
0
).
value
<
quint32
>
(),
quint32
(
2
));
...
...
@@ -337,19 +337,19 @@ void TestWaylandSeat::testPointer()
QCOMPARE
(
axisSpy
.
last
().
at
(
2
).
value
<
qreal
>
(),
qreal
(
20
));
// test button
serverPointer
->
update
Timestamp
(
4
);
m_seatInterface
->
set
Timestamp
(
4
);
serverPointer
->
buttonPressed
(
1
);
QVERIFY
(
buttonSpy
.
wait
());
QCOMPARE
(
buttonSpy
.
at
(
0
).
at
(
0
).
value
<
quint32
>
(),
m_display
->
serial
());
serverPointer
->
update
Timestamp
(
5
);
m_seatInterface
->
set
Timestamp
(
5
);
serverPointer
->
buttonPressed
(
2
);
QVERIFY
(
buttonSpy
.
wait
());
QCOMPARE
(
buttonSpy
.
at
(
1
).
at
(
0
).
value
<
quint32
>
(),
m_display
->
serial
());
serverPointer
->
update
Timestamp
(
6
);
m_seatInterface
->
set
Timestamp
(
6
);
serverPointer
->
buttonReleased
(
2
);
QVERIFY
(
buttonSpy
.
wait
());
QCOMPARE
(
buttonSpy
.
at
(
2
).
at
(
0
).
value
<
quint32
>
(),
m_display
->
serial
());
serverPointer
->
update
Timestamp
(
7
);
m_seatInterface
->
set
Timestamp
(
7
);
serverPointer
->
buttonReleased
(
1
);
QVERIFY
(
buttonSpy
.
wait
());
QCOMPARE
(
buttonSpy
.
count
(),
4
);
...
...
@@ -461,7 +461,7 @@ void TestWaylandSeat::testPointerButton()
quint32
msec
=
QDateTime
::
currentMSecsSinceEpoch
();
QCOMPARE
(
serverPointer
->
isButtonPressed
(
waylandButton
),
false
);
QCOMPARE
(
serverPointer
->
isButtonPressed
(
qtButton
),
false
);
serverPointer
->
update
Timestamp
(
msec
);
m_seatInterface
->
set
Timestamp
(
msec
);
serverPointer
->
buttonPressed
(
qtButton
);
QCOMPARE
(
serverPointer
->
isButtonPressed
(
waylandButton
),
true
);
QCOMPARE
(
serverPointer
->
isButtonPressed
(
qtButton
),
true
);
...
...
@@ -473,7 +473,7 @@ void TestWaylandSeat::testPointerButton()
QCOMPARE
(
buttonChangedSpy
.
last
().
at
(
2
).
value
<
quint32
>
(),
waylandButton
);
QCOMPARE
(
buttonChangedSpy
.
last
().
at
(
3
).
value
<
KWayland
::
Client
::
Pointer
::
ButtonState
>
(),
Pointer
::
ButtonState
::
Pressed
);
msec
=
QDateTime
::
currentMSecsSinceEpoch
();
serverPointer
->
update
Timestamp
(
QDateTime
::
currentMSecsSinceEpoch
());
m_seatInterface
->
set
Timestamp
(
QDateTime
::
currentMSecsSinceEpoch
());
serverPointer
->
buttonReleased
(
qtButton
);
QCOMPARE
(
serverPointer
->
isButtonPressed
(
waylandButton
),
false
);
QCOMPARE
(
serverPointer
->
isButtonPressed
(
qtButton
),
false
);
...
...
src/wayland/pointer_interface.cpp
View file @
41fbb0a6
...
...
@@ -54,7 +54,6 @@ public:
wl_resource
*
pointer
=
nullptr
;
};
QList
<
ResourceData
>
resources
;
quint32
eventTime
=
0
;
struct
FocusedSurface
{
SurfaceInterface
*
surface
=
nullptr
;
QPoint
offset
=
QPoint
();
...
...
@@ -99,7 +98,7 @@ PointerInterface::PointerInterface(SeatInterface *parent)
connect
(
parent
,
&
SeatInterface
::
pointerPosChanged
,
[
this
](
const
QPointF
&
pos
)
{
if
(
d
->
focusedSurface
.
surface
&&
d
->
focusedSurface
.
pointer
)
{
const
QPointF
pos
=
d
->
seat
->
pointerPos
()
-
d
->
focusedSurface
.
offset
;
wl_pointer_send_motion
(
d
->
focusedSurface
.
pointer
,
d
->
eventTime
,
wl_pointer_send_motion
(
d
->
focusedSurface
.
pointer
,
d
->
seat
->
timestamp
()
,
wl_fixed_from_double
(
pos
.
x
()),
wl_fixed_from_double
(
pos
.
y
()));
}
});
...
...
@@ -188,11 +187,6 @@ void PointerInterface::setGlobalPos(const QPointF &pos)
d
->
seat
->
setPointerPos
(
pos
);
}
void
PointerInterface
::
updateTimestamp
(
quint32
time
)
{
d
->
eventTime
=
time
;
}
static
quint32
qtToWaylandButton
(
Qt
::
MouseButton
button
)
{
static
const
QHash
<
Qt
::
MouseButton
,
quint32
>
s_buttons
({
...
...
@@ -225,7 +219,7 @@ void PointerInterface::buttonPressed(quint32 button)
if
(
!
d
->
focusedSurface
.
surface
||
!
d
->
focusedSurface
.
pointer
)
{
return
;
}
wl_pointer_send_button
(
d
->
focusedSurface
.
pointer
,
serial
,
d
->
eventTime
,
button
,
WL_POINTER_BUTTON_STATE_PRESSED
);
wl_pointer_send_button
(
d
->
focusedSurface
.
pointer
,
serial
,
d
->
seat
->
timestamp
()
,
button
,
WL_POINTER_BUTTON_STATE_PRESSED
);
}
void
PointerInterface
::
buttonPressed
(
Qt
::
MouseButton
button
)
...
...
@@ -245,7 +239,7 @@ void PointerInterface::buttonReleased(quint32 button)
if
(
!
d
->
focusedSurface
.
surface
||
!
d
->
focusedSurface
.
pointer
)
{
return
;
}
wl_pointer_send_button
(
d
->
focusedSurface
.
pointer
,
serial
,
d
->
eventTime
,
button
,
WL_POINTER_BUTTON_STATE_RELEASED
);
wl_pointer_send_button
(
d
->
focusedSurface
.
pointer
,
serial
,
d
->
seat
->
timestamp
()
,
button
,
WL_POINTER_BUTTON_STATE_RELEASED
);
}
void
PointerInterface
::
buttonReleased
(
Qt
::
MouseButton
button
)
...
...
@@ -314,7 +308,7 @@ void PointerInterface::axis(Qt::Orientation orientation, quint32 delta)
if
(
!
d
->
focusedSurface
.
surface
||
!
d
->
focusedSurface
.
pointer
)
{
return
;
}
wl_pointer_send_axis
(
d
->
focusedSurface
.
pointer
,
d
->
eventTime
,
wl_pointer_send_axis
(
d
->
focusedSurface
.
pointer
,
d
->
seat
->
timestamp
()
,
(
orientation
==
Qt
::
Vertical
)
?
WL_POINTER_AXIS_VERTICAL_SCROLL
:
WL_POINTER_AXIS_HORIZONTAL_SCROLL
,
wl_fixed_from_int
(
delta
));
}
...
...
src/wayland/pointer_interface.h
View file @
41fbb0a6
...
...
@@ -45,7 +45,6 @@ public:
void
createInterface
(
wl_client
*
client
,
wl_resource
*
parentResource
,
uint32_t
id
);
void
updateTimestamp
(
quint32
time
);
/**
* Convenient method to set the pointer position of the SeatInterface.
* @see SeatInterface::setPointerPos
...
...
src/wayland/seat_interface.cpp
View file @
41fbb0a6
...
...
@@ -54,6 +54,7 @@ public:
QList
<
wl_resource
*>
resources
;
PointerInterface
*
pointerInterface
=
nullptr
;
KeyboardInterface
*
keyboardInterface
=
nullptr
;
quint32
timestamp
=
0
;
// Pointer related members
QPointF
pointerPos
;
...
...
@@ -286,5 +287,21 @@ void SeatInterface::setPointerPos(const QPointF &pos)
emit
pointerPosChanged
(
pos
);
}
quint32
SeatInterface
::
timestamp
()
const
{
Q_D
();
return
d
->
timestamp
;
}
void
SeatInterface
::
setTimestamp
(
quint32
time
)
{
Q_D
();
if
(
d
->
timestamp
==
time
)
{
return
;
}
d
->
timestamp
=
time
;
emit
timestampChanged
(
time
);
}
}
}
src/wayland/seat_interface.h
View file @
41fbb0a6
...
...
@@ -47,6 +47,7 @@ class KWAYLANDSERVER_EXPORT SeatInterface : public Global
Q_PROPERTY
(
bool
keyboard
READ
hasKeyboard
WRITE
setHasKeyboard
NOTIFY
hasKeyboardChanged
)
Q_PROPERTY
(
bool
tourch
READ
hasTouch
WRITE
setHasTouch
NOTIFY
hasTouchChanged
)
Q_PROPERTY
(
QPointF
pointerPos
READ
pointerPos
WRITE
setPointerPos
NOTIFY
pointerPosChanged
)
Q_PROPERTY
(
quint32
timestamp
READ
timestamp
WRITE
setTimestamp
NOTIFY
timestampChanged
)
public:
virtual
~
SeatInterface
();
...
...
@@ -62,6 +63,9 @@ public:
void
setHasKeyboard
(
bool
has
);
void
setHasTouch
(
bool
has
);
void
setTimestamp
(
quint32
time
);
quint32
timestamp
()
const
;
// pointer related methods
void
setPointerPos
(
const
QPointF
&
pos
);
QPointF
pointerPos
()
const
;
...
...
@@ -74,6 +78,7 @@ Q_SIGNALS:
void
hasKeyboardChanged
(
bool
);
void
hasTouchChanged
(
bool
);
void
pointerPosChanged
(
const
QPointF
&
pos
);
void
timestampChanged
(
quint32
);
private:
friend
class
Display
;
...
...
src/wayland/tests/renderingservertest.cpp
View file @
41fbb0a6
...
...
@@ -139,7 +139,7 @@ void CompositorWindow::mouseMoveEvent(QMouseEvent *event)
pointer
->
setFocusedSurface
(
m_stackingOrder
.
last
()
->
surface
());
}
}
pointer
->
update
Timestamp
(
event
->
timestamp
());
m_seat
->
set
Timestamp
(
event
->
timestamp
());
pointer
->
setGlobalPos
(
event
->
localPos
().
toPoint
());
}
...
...
@@ -152,7 +152,7 @@ void CompositorWindow::mousePressEvent(QMouseEvent *event)
pointer
->
setFocusedSurface
(
m_stackingOrder
.
last
()
->
surface
());
}
}
pointer
->
update
Timestamp
(
event
->
timestamp
());
m_seat
->
set
Timestamp
(
event
->
timestamp
());
pointer
->
buttonPressed
(
event
->
button
());
}
...
...
@@ -160,7 +160,7 @@ void CompositorWindow::mouseReleaseEvent(QMouseEvent *event)
{
QWidget
::
mouseReleaseEvent
(
event
);
const
auto
pointer
=
m_seat
->
pointer
();
pointer
->
update
Timestamp
(
event
->
timestamp
());
m_seat
->
set
Timestamp
(
event
->
timestamp
());
pointer
->
buttonReleased
(
event
->
button
());
}
...
...
@@ -168,7 +168,7 @@ void CompositorWindow::wheelEvent(QWheelEvent *event)
{
QWidget
::
wheelEvent
(
event
);
const
auto
pointer
=
m_seat
->
pointer
();
pointer
->
update
Timestamp
(
event
->
timestamp
());
m_seat
->
set
Timestamp
(
event
->
timestamp
());
const
QPoint
&
angle
=
event
->
angleDelta
()
/
(
8
*
15
);
if
(
angle
.
x
()
!=
0
)
{
pointer
->
axis
(
Qt
::
Horizontal
,
angle
.
x
());
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment