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
8f2f9479
Commit
8f2f9479
authored
Nov 26, 2014
by
Martin Flöser
Browse files
Cleanup SeatInterface after refactoring
parent
7baf5896
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/wayland/seat_interface.cpp
View file @
8f2f9479
...
...
@@ -57,31 +57,31 @@ public:
bool
keyboard
=
false
;
bool
touch
=
false
;
QList
<
wl_resource
*>
resources
;
struct
FocusedPointer
{
SurfaceInterface
*
surface
=
nullptr
;
PointerInterface
*
pointer
=
nullptr
;
QMetaObject
::
Connection
destroyConnection
;
QPointF
offset
=
QPointF
();
quint32
serial
=
0
;
};
FocusedPointer
focusedPointer
=
FocusedPointer
();
quint32
timestamp
=
0
;
QVector
<
PointerInterface
*>
pointers
;
QVector
<
KeyboardInterface
*>
keyboards
;
// Pointer related members
struct
Pointer
{
enum
class
Button
State
{
enum
class
State
{
Released
,
Pressed
};
QHash
<
quint32
,
quint32
>
buttonSerials
;
QHash
<
quint32
,
Button
State
>
buttonStates
;
QHash
<
quint32
,
State
>
buttonStates
;
QPointF
pos
;
struct
Focus
{
SurfaceInterface
*
surface
=
nullptr
;
PointerInterface
*
pointer
=
nullptr
;
QMetaObject
::
Connection
destroyConnection
;
QPointF
offset
=
QPointF
();
quint32
serial
=
0
;
};
Focus
focus
;
};
Pointer
globalPointer
;
void
updatePointerButtonSerial
(
quint32
button
,
quint32
serial
);
void
updatePointerButtonState
(
quint32
button
,
Pointer
::
Button
State
state
);
void
updatePointerButtonState
(
quint32
button
,
Pointer
::
State
state
);
// Keyboard related members
struct
Keyboard
{
...
...
@@ -207,7 +207,7 @@ void SeatInterface::Private::updatePointerButtonSerial(quint32 button, quint32 s
it
.
value
()
=
serial
;
}
void
SeatInterface
::
Private
::
updatePointerButtonState
(
quint32
button
,
Pointer
::
Button
State
state
)
void
SeatInterface
::
Private
::
updatePointerButtonState
(
quint32
button
,
Pointer
::
State
state
)
{
auto
it
=
globalPointer
.
buttonStates
.
find
(
button
);
if
(
it
==
globalPointer
.
buttonStates
.
end
())
{
...
...
@@ -337,18 +337,18 @@ void SeatInterface::Private::getPointer(wl_client *client, wl_resource *resource
return
;
}
pointers
<<
pointer
;
if
(
focused
Pointer
.
surface
&&
focused
Pointer
.
surface
->
client
()
->
client
()
==
client
)
{
if
(
global
Pointer
.
focus
.
surface
&&
global
Pointer
.
focus
.
surface
->
client
()
->
client
()
==
client
)
{
// this is a pointer for the currently focused pointer surface
if
(
!
focused
Pointer
.
pointer
)
{
focused
Pointer
.
pointer
=
pointer
;
pointer
->
setFocusedSurface
(
focused
Pointer
.
surface
,
focused
Pointer
.
serial
);
if
(
!
global
Pointer
.
focus
.
pointer
)
{
global
Pointer
.
focus
.
pointer
=
pointer
;
pointer
->
setFocusedSurface
(
global
Pointer
.
focus
.
surface
,
global
Pointer
.
focus
.
serial
);
}
}
QObject
::
connect
(
pointer
,
&
QObject
::
destroyed
,
q
,
[
pointer
,
this
]
{
pointers
.
removeAt
(
pointers
.
indexOf
(
pointer
));
if
(
focused
Pointer
.
pointer
==
pointer
)
{
focused
Pointer
.
pointer
=
nullptr
;
if
(
global
Pointer
.
focus
.
pointer
==
pointer
)
{
global
Pointer
.
focus
.
pointer
=
nullptr
;
}
}
);
...
...
@@ -465,32 +465,32 @@ void SeatInterface::setTimestamp(quint32 time)
SurfaceInterface
*
SeatInterface
::
focusedPointerSurface
()
const
{
Q_D
();
return
d
->
focused
Pointer
.
surface
;
return
d
->
global
Pointer
.
focus
.
surface
;
}
void
SeatInterface
::
setFocusedPointerSurface
(
SurfaceInterface
*
surface
,
const
QPointF
&
surfacePosition
)
{
Q_D
();
const
quint32
serial
=
d
->
display
->
nextSerial
();
if
(
d
->
focused
Pointer
.
pointer
)
{
d
->
focused
Pointer
.
pointer
->
setFocusedSurface
(
nullptr
,
serial
);
if
(
d
->
global
Pointer
.
focus
.
pointer
)
{
d
->
global
Pointer
.
focus
.
pointer
->
setFocusedSurface
(
nullptr
,
serial
);
}
if
(
d
->
focused
Pointer
.
surface
)
{
disconnect
(
d
->
focused
Pointer
.
destroyConnection
);
if
(
d
->
global
Pointer
.
focus
.
surface
)
{
disconnect
(
d
->
global
Pointer
.
focus
.
destroyConnection
);
}
d
->
focused
Pointer
=
Private
::
Focused
Pointer
();
d
->
focused
Pointer
.
surface
=
surface
;
d
->
global
Pointer
.
focus
=
Private
::
Pointer
::
Focus
();
d
->
global
Pointer
.
focus
.
surface
=
surface
;
PointerInterface
*
p
=
d
->
pointerForSurface
(
surface
);
d
->
focused
Pointer
.
pointer
=
p
;
if
(
d
->
focused
Pointer
.
surface
)
{
d
->
focused
Pointer
.
destroyConnection
=
connect
(
surface
,
&
QObject
::
destroyed
,
this
,
d
->
global
Pointer
.
focus
.
pointer
=
p
;
if
(
d
->
global
Pointer
.
focus
.
surface
)
{
d
->
global
Pointer
.
focus
.
destroyConnection
=
connect
(
surface
,
&
QObject
::
destroyed
,
this
,
[
this
]
{
Q_D
();
d
->
focused
Pointer
=
Private
::
Focused
Pointer
();
d
->
global
Pointer
.
focus
=
Private
::
Pointer
::
Focus
();
}
);
d
->
focused
Pointer
.
offset
=
surfacePosition
;
d
->
focused
Pointer
.
serial
=
serial
;
d
->
global
Pointer
.
focus
.
offset
=
surfacePosition
;
d
->
global
Pointer
.
focus
.
serial
=
serial
;
}
if
(
!
p
)
{
return
;
...
...
@@ -501,21 +501,21 @@ void SeatInterface::setFocusedPointerSurface(SurfaceInterface *surface, const QP
PointerInterface
*
SeatInterface
::
focusedPointer
()
const
{
Q_D
();
return
d
->
focused
Pointer
.
pointer
;
return
d
->
global
Pointer
.
focus
.
pointer
;
}
void
SeatInterface
::
setFocusedPointerSurfacePosition
(
const
QPointF
&
surfacePosition
)
{
Q_D
();
if
(
d
->
focused
Pointer
.
surface
)
{
d
->
focused
Pointer
.
offset
=
surfacePosition
;
if
(
d
->
global
Pointer
.
focus
.
surface
)
{
d
->
global
Pointer
.
focus
.
offset
=
surfacePosition
;
}
}
QPointF
SeatInterface
::
focusedPointerSurfacePosition
()
const
{
Q_D
();
return
d
->
focused
Pointer
.
offset
;
return
d
->
global
Pointer
.
focus
.
offset
;
}
static
quint32
qtToWaylandButton
(
Qt
::
MouseButton
button
)
...
...
@@ -554,14 +554,14 @@ bool SeatInterface::isPointerButtonPressed(quint32 button) const
if
(
it
==
d
->
globalPointer
.
buttonStates
.
constEnd
())
{
return
false
;
}
return
it
.
value
()
==
Private
::
Pointer
::
Button
State
::
Pressed
?
true
:
false
;
return
it
.
value
()
==
Private
::
Pointer
::
State
::
Pressed
?
true
:
false
;
}
void
SeatInterface
::
pointerAxis
(
Qt
::
Orientation
orientation
,
quint32
delta
)
{
Q_D
();
if
(
d
->
focused
Pointer
.
pointer
&&
d
->
focused
Pointer
.
surface
)
{
d
->
focused
Pointer
.
pointer
->
axis
(
orientation
,
delta
);
if
(
d
->
global
Pointer
.
focus
.
pointer
&&
d
->
global
Pointer
.
focus
.
surface
)
{
d
->
global
Pointer
.
focus
.
pointer
->
axis
(
orientation
,
delta
);
}
}
...
...
@@ -579,9 +579,9 @@ void SeatInterface::pointerButtonPressed(quint32 button)
Q_D
();
const
quint32
serial
=
d
->
display
->
nextSerial
();
d
->
updatePointerButtonSerial
(
button
,
serial
);
d
->
updatePointerButtonState
(
button
,
Private
::
Pointer
::
Button
State
::
Pressed
);
if
(
d
->
focused
Pointer
.
pointer
&&
d
->
focused
Pointer
.
surface
)
{
d
->
focused
Pointer
.
pointer
->
buttonPressed
(
button
,
serial
);
d
->
updatePointerButtonState
(
button
,
Private
::
Pointer
::
State
::
Pressed
);
if
(
d
->
global
Pointer
.
focus
.
pointer
&&
d
->
global
Pointer
.
focus
.
surface
)
{
d
->
global
Pointer
.
focus
.
pointer
->
buttonPressed
(
button
,
serial
);
}
}
...
...
@@ -599,9 +599,9 @@ void SeatInterface::pointerButtonReleased(quint32 button)
Q_D
();
const
quint32
serial
=
d
->
display
->
nextSerial
();
d
->
updatePointerButtonSerial
(
button
,
serial
);
d
->
updatePointerButtonState
(
button
,
Private
::
Pointer
::
Button
State
::
Released
);
if
(
d
->
focused
Pointer
.
pointer
&&
d
->
focused
Pointer
.
surface
)
{
d
->
focused
Pointer
.
pointer
->
buttonReleased
(
button
,
serial
);
d
->
updatePointerButtonState
(
button
,
Private
::
Pointer
::
State
::
Released
);
if
(
d
->
global
Pointer
.
focus
.
pointer
&&
d
->
global
Pointer
.
focus
.
surface
)
{
d
->
global
Pointer
.
focus
.
pointer
->
buttonReleased
(
button
,
serial
);
}
}
...
...
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