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
58183b7c
Commit
58183b7c
authored
Mar 05, 2017
by
Ulrich Sibiller
Committed by
Mike Gabriel
Aug 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nxagent: Add autograb mode.
You can now toggle between autograb mode by pressing CTRL-ALT-G (default, can be adjusted in keystrokes.cfg). Fixes ArcticaProject/nx-libs#384.
parent
daa50fd8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
5 deletions
+97
-5
README.keystrokes
doc/nxagent/README.keystrokes
+3
-0
keystrokes.cfg
etc/keystrokes.cfg
+1
-0
Events.c
nx-X11/programs/Xserver/hw/nxagent/Events.c
+81
-3
Events.h
nx-X11/programs/Xserver/hw/nxagent/Events.h
+2
-1
Keystroke.c
nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
+8
-1
Keystroke.h
nx-X11/programs/Xserver/hw/nxagent/Keystroke.h
+2
-0
No files found.
doc/nxagent/README.keystrokes
View file @
58183b7c
...
...
@@ -126,6 +126,9 @@ reread_keystrokes
Forces nxagent to re-read the keystroke configuration. Useful to
add/change keystrokes to a running session.
autograb
Toggles autograb mode
force_synchronization
Forces immediate drawing of elements to be synchronized which can
fix some visual bugs.
etc/keystrokes.cfg
View file @
58183b7c
...
...
@@ -24,4 +24,5 @@
<keystroke
action=
"viewport_scroll_down"
Control=
"1"
AltMeta=
"1"
key=
"Down"
/>
<keystroke
action=
"viewport_scroll_down"
Control=
"1"
AltMeta=
"1"
key=
"KP_Down"
/>
<keystroke
action=
"reread_keystrokes"
Control=
"1"
AltMeta=
"1"
key=
"k"
/>
<keystroke
action=
"autograb"
Control=
"1"
AltMeta=
"1"
key=
"g"
/>
</keystrokes>
nx-X11/programs/Xserver/hw/nxagent/Events.c
View file @
58183b7c
...
...
@@ -674,6 +674,40 @@ static void nxagentSwitchDeferMode(void)
}
}
static
Bool
autograb
=
False
;
static
void
nxagentEnableAutoGrab
(
void
)
{
#ifdef DEBUG
fprintf
(
stderr
,
"enabling autograb
\n
"
);
#endif
nxagentGrabPointerAndKeyboard
(
NULL
);
autograb
=
True
;
}
static
void
nxagentDisableAutoGrab
(
void
)
{
#ifdef DEBUG
fprintf
(
stderr
,
"disabling autograb
\n
"
);
#endif
nxagentUngrabPointerAndKeyboard
(
NULL
);
autograb
=
False
;
}
static
void
nxagentToggleAutoGrab
(
void
)
{
/* autograb only works in windowed mode */
if
(
nxagentOption
(
Rootless
)
||
nxagentOption
(
Fullscreen
))
return
;
if
(
!
autograb
)
nxagentEnableAutoGrab
();
else
nxagentDisableAutoGrab
();
}
static
Bool
nxagentExposurePredicate
(
Display
*
display
,
XEvent
*
event
,
XPointer
window
)
{
/*
...
...
@@ -1060,6 +1094,12 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
break
;
}
case
doAutoGrab
:
{
nxagentToggleAutoGrab
();
break
;
}
default:
{
FatalError
(
"nxagentDispatchEvent: handleKeyPress returned unknown value
\n
"
);
...
...
@@ -1519,6 +1559,17 @@ FIXME: Don't enqueue the KeyRelease event if the key was
}
}
/* FIXME: only when in windowed mode! */
if
(
autograb
)
{
if
(
X
.
xfocus
.
window
==
nxagentDefaultWindows
[
0
]
&&
X
.
xfocus
.
mode
==
NotifyNormal
)
{
#ifdef DEBUG
fprintf
(
stderr
,
"%s: (FocusIn): grabbing
\n
"
,
__func__
);
#endif
nxagentGrabPointerAndKeyboard
(
NULL
);
}
}
break
;
}
case
FocusOut
:
...
...
@@ -1597,6 +1648,19 @@ FIXME: Don't enqueue the KeyRelease event if the key was
#endif
/* NXAGENT_FIXKEYS */
if
(
autograb
)
{
XlibWindow
w
;
int
revert_to
;
XGetInputFocus
(
nxagentDisplay
,
&
w
,
&
revert_to
);
if
(
w
!=
nxagentDefaultWindows
[
0
]
&&
X
.
xfocus
.
mode
==
NotifyWhileGrabbed
)
{
#ifdef DEBUG
fprintf
(
stderr
,
"%s: (FocusOut): ungrabbing
\n
"
,
__func__
);
#endif
nxagentUngrabPointerAndKeyboard
(
NULL
);
}
}
break
;
}
case
KeymapNotify
:
...
...
@@ -3827,13 +3891,26 @@ void nxagentGrabPointerAndKeyboard(XEvent *X)
fprintf
(
stderr
,
"nxagentGrabPointerAndKeyboard: Going to grab the keyboard in context [B1].
\n
"
);
#endif
result
=
XGrabKeyboard
(
nxagentDisplay
,
nxagentFullscreenWindow
,
True
,
GrabModeAsync
,
GrabModeAsync
,
now
);
if
(
nxagentFullscreenWindow
)
result
=
XGrabKeyboard
(
nxagentDisplay
,
nxagentFullscreenWindow
,
True
,
GrabModeAsync
,
GrabModeAsync
,
now
);
else
result
=
XGrabKeyboard
(
nxagentDisplay
,
RootWindow
(
nxagentDisplay
,
DefaultScreen
(
nxagentDisplay
)),
True
,
GrabModeAsync
,
GrabModeAsync
,
now
);
if
(
result
!=
GrabSuccess
)
{
#ifdef DEBUG
fprintf
(
stderr
,
"%s: keyboard grab failed.
\n
"
,
__func__
);
#endif
return
;
}
#ifdef DEBUG
else
{
fprintf
(
stderr
,
"%s: keyboard grab successful.
\n
"
,
__func__
);
}
#endif
/*
* The smart scheduler could be stopped while
...
...
@@ -3851,7 +3928,8 @@ void nxagentGrabPointerAndKeyboard(XEvent *X)
resource
=
nxagentWaitForResource
(
NXGetCollectGrabPointerResource
,
nxagentCollectGrabPointerPredicate
);
NXCollectGrabPointer
(
nxagentDisplay
,
resource
,
if
(
nxagentFullscreenWindow
)
NXCollectGrabPointer
(
nxagentDisplay
,
resource
,
nxagentFullscreenWindow
,
True
,
NXAGENT_POINTER_EVENT_MASK
,
GrabModeAsync
,
GrabModeAsync
,
None
,
None
,
now
);
...
...
nx-X11/programs/Xserver/hw/nxagent/Events.h
View file @
58183b7c
...
...
@@ -50,7 +50,8 @@ enum HandleEventResult
doViewportRight
,
doViewportDown
,
doSwitchResizeMode
,
doSwitchDeferMode
doSwitchDeferMode
,
doAutoGrab
,
};
extern
CARD32
nxagentLastEventTime
;
...
...
nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
View file @
58183b7c
...
...
@@ -99,6 +99,9 @@ char * nxagentSpecialKeystrokeNames[] = {
"viewport_scroll_down"
,
"reread_keystrokes"
,
"autograb"
,
NULL
,
};
...
...
@@ -138,6 +141,7 @@ struct nxagentSpecialKeystrokeMap default_map[] = {
{
KEYSTROKE_VIEWPORT_SCROLL_DOWN
,
ControlMask
,
True
,
XK_Down
},
{
KEYSTROKE_VIEWPORT_SCROLL_DOWN
,
ControlMask
,
True
,
XK_KP_Down
},
{
KEYSTROKE_REREAD_KEYSTROKES
,
ControlMask
,
True
,
XK_k
},
{
KEYSTROKE_AUTOGRAB
,
ControlMask
,
True
,
XK_g
},
{
KEYSTROKE_END_MARKER
,
0
,
False
,
NoSymbol
},
};
struct
nxagentSpecialKeystrokeMap
*
map
=
default_map
;
...
...
@@ -467,7 +471,7 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X)
#endif
for
(
struct
nxagentSpecialKeystrokeMap
*
cur
=
map
;
cur
->
stroke
!=
KEYSTROKE_END_MARKER
;
cur
++
)
{
#ifdef DEBUG
fprintf
(
stderr
,
"%s: checking keysym '%c' (%d)
\n
"
,
__func__
,
cur
->
keysym
,
cur
->
keysym
);
fprintf
(
stderr
,
"%s: keysym %d stroke %d, type %d
\n
"
,
__func__
,
cur
->
keysym
,
cur
->
stroke
,
X
->
type
);
#endif
if
(
cur
->
keysym
==
keysym
&&
modifier_matches
(
cur
->
modifierMask
,
cur
->
modifierAltMeta
,
X
->
state
))
{
#ifdef DEBUG
...
...
@@ -627,6 +631,9 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result)
if
(
X
->
type
==
KeyRelease
)
nxagentInitKeystrokes
(
True
);
break
;
case
KEYSTROKE_AUTOGRAB
:
*
result
=
doAutoGrab
;
break
;
case
KEYSTROKE_NOTHING
:
/* do nothing. difference to KEYSTROKE_IGNORE is the return value */
case
KEYSTROKE_END_MARKER
:
/* just to make gcc STFU */
case
KEYSTROKE_MAX
:
...
...
nx-X11/programs/Xserver/hw/nxagent/Keystroke.h
View file @
58183b7c
...
...
@@ -73,6 +73,8 @@ enum nxagentSpecialKeystroke {
KEYSTROKE_REREAD_KEYSTROKES
,
KEYSTROKE_AUTOGRAB
,
KEYSTROKE_NOTHING
,
/* insert more here and in the string translation */
...
...
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