Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
5de8bac2
Commit
5de8bac2
authored
Aug 05, 2019
by
Ulrich Sibiller
Committed by
Mike Gabriel
Sep 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clipboard.c: introduce nxagentFind*Index functions
At some places we were using NumCurrentSelections. We replace that by nxagentMaxSelections because they always have the identical value.
parent
79867f4a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
50 deletions
+33
-50
Clipboard.c
nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
+30
-39
Clipboard.h
nx-X11/programs/Xserver/hw/nxagent/Clipboard.h
+1
-0
Events.c
nx-X11/programs/Xserver/hw/nxagent/Events.c
+1
-6
NXdispatch.c
nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c
+1
-5
No files found.
nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
View file @
5de8bac2
...
...
@@ -524,10 +524,30 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
nxagentPrintClipboardStat
(
"after nxagentClearClipboard"
);
}
void
nxagentClearSelection
(
XEvent
*
X
)
int
nxagentFindLastSelectionOwnerIndex
(
Atom
sel
)
{
int
i
=
0
;
while
((
i
<
nxagentMaxSelections
)
&&
(
lastSelectionOwner
[
i
].
selection
!=
sel
))
{
i
++
;
}
return
i
;
}
int
nxagentFindCurrentSelectionIndex
(
Atom
sel
)
{
int
i
=
0
;
while
((
i
<
NumCurrentSelections
)
&&
(
CurrentSelections
[
i
].
selection
!=
sel
))
{
i
++
;
}
return
i
;
}
void
nxagentClearSelection
(
XEvent
*
X
)
{
#ifdef DEBUG
fprintf
(
stderr
,
"%s: SelectionClear event for selection [%lu].
\n
"
,
__func__
,
X
->
xselectionclear
.
selection
);
#endif
...
...
@@ -540,11 +560,7 @@ void nxagentClearSelection(XEvent *X)
return
;
}
while
((
i
<
nxagentMaxSelections
)
&&
(
lastSelectionOwner
[
i
].
selection
!=
X
->
xselectionclear
.
selection
))
{
i
++
;
}
int
i
=
nxagentFindLastSelectionOwnerIndex
(
X
->
xselectionclear
.
selection
);
if
(
i
<
nxagentMaxSelections
)
{
...
...
@@ -573,7 +589,6 @@ void nxagentClearSelection(XEvent *X)
void
nxagentRequestSelection
(
XEvent
*
X
)
{
int
i
=
0
;
XSelectionEvent
eventSelection
=
{
0
};
#ifdef DEBUG
...
...
@@ -628,10 +643,8 @@ FIXME: Do we need this?
}
else
if
(
X
->
xselectionrequest
.
target
==
nxagentTimestampAtom
)
{
while
((
i
<
NumCurrentSelections
)
&&
lastSelectionOwner
[
i
].
selection
!=
X
->
xselectionrequest
.
selection
)
i
++
;
if
(
i
<
NumCurrentSelections
)
int
i
=
nxagentFindLastSelectionOwnerIndex
(
X
->
xselectionrequest
.
selection
);
if
(
i
<
nxagentMaxSelections
)
{
XChangeProperty
(
nxagentDisplay
,
X
->
xselectionrequest
.
requestor
,
...
...
@@ -661,13 +674,8 @@ FIXME: Do we need this?
nxagentLastRequestedSelection
=
X
->
xselectionrequest
.
selection
;
/* FIXME: shouldn't we reset i to 0 here first? */
while
((
i
<
nxagentMaxSelections
)
&&
(
lastSelectionOwner
[
i
].
selection
!=
X
->
xselectionrequest
.
selection
))
{
i
++
;
}
/* find the index of the requested selection */
int
i
=
nxagentFindLastSelectionOwnerIndex
(
X
->
xselectionrequest
.
selection
);
if
(
i
<
nxagentMaxSelections
)
{
if
((
lastClientWindowPtr
!=
NULL
)
&&
(
lastSelectionOwner
[
i
].
client
!=
NULL
))
...
...
@@ -1109,13 +1117,7 @@ void nxagentNotifySelection(XEvent *X)
}
else
{
int
i
=
0
;
while
((
i
<
nxagentMaxSelections
)
&&
(
lastSelectionOwner
[
i
].
selection
!=
X
->
xselection
.
selection
))
{
i
++
;
}
int
i
=
nxagentFindLastSelectionOwnerIndex
(
X
->
xselection
.
selection
);
if
(
i
<
nxagentMaxSelections
)
{
if
((
lastSelectionOwner
[
i
].
client
!=
NULL
)
&&
...
...
@@ -1417,7 +1419,6 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
Window
requestor
,
Atom
property
,
Atom
target
,
Time
time
)
{
const
char
*
strTarget
;
int
i
;
if
(
agentClipboardStatus
!=
1
||
nxagentOption
(
Clipboard
)
==
ClipboardServer
)
...
...
@@ -1433,7 +1434,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
* Only for PRIMARY and CLIPBOARD selections.
*/
for
(
i
=
0
;
i
<
nxagentMaxSelections
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
nxagentMaxSelections
;
i
++
)
{
if
((
selection
==
CurrentSelections
[
i
].
selection
)
&&
(
lastSelectionOwner
[
i
].
client
!=
NULL
))
...
...
@@ -1510,11 +1511,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
if
(
target
==
MakeAtom
(
"TIMESTAMP"
,
9
,
1
))
{
int
i
=
0
;
while
((
i
<
NumCurrentSelections
)
&&
CurrentSelections
[
i
].
selection
!=
selection
)
i
++
;
int
i
=
nxagentFindCurrentSelectionIndex
(
selection
);
if
(
i
<
NumCurrentSelections
)
{
ChangeWindowProperty
(
pWin
,
...
...
@@ -1673,17 +1670,11 @@ int nxagentSendNotify(xEvent *event)
WindowPtr
nxagentGetClipboardWindow
(
Atom
property
,
WindowPtr
pWin
)
{
int
i
=
0
;
#ifdef DEBUG
fprintf
(
stderr
,
"%s: Got called, property [%d][%s] window [%p].
\n
"
,
__func__
,
property
,
NameForAtom
(
property
),
(
void
*
)
pWin
);
#endif
while
((
i
<
nxagentMaxSelections
)
&&
(
lastSelectionOwner
[
i
].
selection
!=
nxagentLastRequestedSelection
))
{
i
++
;
}
int
i
=
nxagentFindLastSelectionOwnerIndex
(
nxagentLastRequestedSelection
);
if
((
i
<
nxagentMaxSelections
)
&&
(
property
==
clientCutProperty
)
&&
(
lastSelectionOwner
[
i
].
windowPtr
!=
NULL
))
...
...
nx-X11/programs/Xserver/hw/nxagent/Clipboard.h
View file @
5de8bac2
...
...
@@ -66,4 +66,5 @@ void nxagentClearSelection();
void
nxagentRequestSelection
();
void
nxagentNotifySelection
();
int
nxagentFindCurrentSelectionIndex
(
Atom
sel
);
#endif
/* __Clipboard_H__ */
nx-X11/programs/Xserver/hw/nxagent/Events.c
View file @
5de8bac2
...
...
@@ -2933,12 +2933,7 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X)
if
(
SelectionCallback
)
{
int
i
=
0
;
while
((
i
<
NumCurrentSelections
)
&&
CurrentSelections
[
i
].
selection
!=
local
)
i
++
;
int
i
=
nxagentFindCurrentSelectionIndex
(
local
);
if
(
i
<
NumCurrentSelections
)
{
SelectionInfoRec
info
;
...
...
nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c
View file @
5de8bac2
...
...
@@ -691,11 +691,7 @@ ProcConvertSelection(register ClientPtr client)
(
stuff
->
selection
==
MakeAtom
(
"CLIPBOARD"
,
9
,
0
)))
&&
nxagentOption
(
Clipboard
)
!=
ClipboardNone
)
{
int
i
=
0
;
while
((
i
<
NumCurrentSelections
)
&&
CurrentSelections
[
i
].
selection
!=
stuff
->
selection
)
i
++
;
int
i
=
nxagentFindCurrentSelectionIndex
(
stuff
->
selection
);
if
((
i
<
NumCurrentSelections
)
&&
(
CurrentSelections
[
i
].
window
!=
None
))
{
if
(
nxagentConvertSelection
(
client
,
pWin
,
stuff
->
selection
,
stuff
->
requestor
,
...
...
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