aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Events.c
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-10-10 17:58:31 +0200
committerReinhard Tartler <siretart@tauware.de>2011-10-10 17:58:31 +0200
commit1c25e92b9ea5811d8ab9c2bfdc0dcb2e4d21bd0a (patch)
tree56b1d4196538a8abb7747e8455b59aa778d6b948 /nx-X11/programs/Xserver/hw/nxagent/Events.c
parent266b5554943baffafbf1d574f567283cc9792278 (diff)
downloadnx-libs-1c25e92b9ea5811d8ab9c2bfdc0dcb2e4d21bd0a.tar.gz
nx-libs-1c25e92b9ea5811d8ab9c2bfdc0dcb2e4d21bd0a.tar.bz2
nx-libs-1c25e92b9ea5811d8ab9c2bfdc0dcb2e4d21bd0a.zip
Imported nxagent-3.2.0-10.tar.gznxagent/3.2.0-10
Summary: Imported nxagent-3.2.0-10.tar.gz Keywords: Imported nxagent-3.2.0-10.tar.gz into Git repository
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Events.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Events.c204
1 files changed, 146 insertions, 58 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c
index d2d9f87ea..b37d81adf 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c
@@ -22,6 +22,7 @@
#include "Xproto.h"
#include "screenint.h"
#include "input.h"
+#include "dix.h"
#include "misc.h"
#include "scrnintstr.h"
#include "windowstr.h"
@@ -61,6 +62,9 @@
#include "NXvars.h"
#include "NXproto.h"
+#include "xfixesproto.h"
+#include <X11/extensions/Xfixes.h>
+
#ifdef NXAGENT_FIXKEYS
#include "inputstr.h"
#include "input.h"
@@ -113,6 +117,15 @@ extern int nxagentLastClipboardClient;
extern Bool nxagentRootlessTreesMatch(void);
#endif
+extern Selection *CurrentSelections;
+extern int NumCurrentSelections;
+
+typedef union _XFixesSelectionEvent {
+ int type;
+ XFixesSelectionNotifyEvent xfixesselection;
+ XEvent core;
+} XFixesSelectionEvent;
+
Bool xkbdRunning = False;
pid_t pidkbd;
@@ -742,7 +755,19 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
if (nxagentXkbState.Initialized == 0)
{
+ if (X.xkey.keycode == 66)
+ {
+ nxagentXkbCapsTrap = 1;
+ }
+ else if (X.xkey.keycode == 77)
+ {
+ nxagentXkbNumTrap = 1;
+ }
+
nxagentInitKeyboardState();
+
+ nxagentXkbCapsTrap = 0;
+ nxagentXkbNumTrap = 0;
}
x.u.u.type = KeyRelease;
@@ -1283,10 +1308,6 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
X.xcrossing.mode == NotifyNormal)
{
nxagentUngrabPointerAndKeyboard(&X);
-
- pScreen = nxagentScreen(X.xcrossing.window);
-
- minimize = True;
}
}
@@ -1610,7 +1631,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
* state modification event.
*/
- if (nxagentHandleKeyboardEvent(&X) == 0)
+ if (nxagentHandleKeyboardEvent(&X) == 0 && nxagentHandleXFixesSelectionNotify(&X) == 0)
{
#ifdef TEST
fprintf(stderr, "nxagentDispatchEvents: WARNING! Unhandled event code [%d].\n",
@@ -1805,7 +1826,19 @@ int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result)
if (nxagentXkbState.Initialized == 0)
{
+ if (X -> xkey.keycode == 66)
+ {
+ nxagentXkbCapsTrap = 1;
+ }
+ else if (X -> xkey.keycode == 77)
+ {
+ nxagentXkbNumTrap = 1;
+ }
+
nxagentInitKeyboardState();
+
+ nxagentXkbCapsTrap = 0;
+ nxagentXkbNumTrap = 0;
}
if (nxagentCheckSpecialKeystroke(&X -> xkey, result))
@@ -2228,7 +2261,11 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result)
{
pScreen = nxagentScreen(X -> xmap.window);
- nxagentMaximizeToFullScreen(pScreen);
+ XMapRaised(nxagentDisplay, nxagentFullscreenWindow);
+
+ XIconifyWindow(nxagentDisplay, nxagentIconWindow,
+ DefaultScreen(nxagentDisplay));
+
}
if (X -> xclient.window == (nxagentOption(Fullscreen) ?
@@ -2273,7 +2310,10 @@ int nxagentHandleKeyboardEvent(XEvent *X)
fprintf(stderr, "nxagentHandleKeyboardEvent: Sending fake key [66] to engage capslock.\n");
#endif
- nxagentSendFakeKey(66);
+ if (!nxagentXkbCapsTrap)
+ {
+ nxagentSendFakeKey(66);
+ }
}
if (nxagentXkbState.Caps == 1 &&
@@ -2288,6 +2328,18 @@ int nxagentHandleKeyboardEvent(XEvent *X)
nxagentSendFakeKey(66);
}
+ if (nxagentXkbState.Caps == 0 &&
+ !(nxagentXkbState.Locked & CAPSFLAG_IN_EVENT) &&
+ nxagentXkbCapsTrap)
+ {
+
+ #ifdef TEST
+ fprintf(stderr, "nxagentHandleKeyboardEvent: Sending fake key [66] to release capslock.\n");
+ #endif
+
+ nxagentSendFakeKey(66);
+ }
+
if (nxagentXkbState.Num == 0 &&
(nxagentXkbState.Locked & NUMFLAG_IN_EVENT))
{
@@ -2297,7 +2349,10 @@ int nxagentHandleKeyboardEvent(XEvent *X)
fprintf(stderr, "nxagentHandleKeyboardEvent: Sending fake key [77] to engage numlock.\n");
#endif
- nxagentSendFakeKey(77);
+ if (!nxagentXkbNumTrap)
+ {
+ nxagentSendFakeKey(77);
+ }
}
if (nxagentXkbState.Num == 1 &&
@@ -2312,12 +2367,95 @@ int nxagentHandleKeyboardEvent(XEvent *X)
nxagentSendFakeKey(77);
}
+ if (nxagentXkbState.Num == 0 &&
+ !(nxagentXkbState.Locked & NUMFLAG_IN_EVENT) &&
+ nxagentXkbNumTrap)
+ {
+
+ #ifdef TEST
+ fprintf(stderr, "nxagentHandleKeyboardEvent: Sending fake key [77] to release numlock.\n");
+ #endif
+
+ nxagentSendFakeKey(77);
+ }
+
return 1;
}
return 0;
}
+int nxagentHandleXFixesSelectionNotify(XEvent *X)
+{
+ int i;
+ Atom local;
+
+ XFixesSelectionEvent *xfixesEvent = (XFixesSelectionEvent *) X;
+
+ if (nxagentXFixesInfo.Initialized == 0 ||
+ xfixesEvent -> type != (nxagentXFixesInfo.EventBase + XFixesSelectionNotify))
+ return 0;
+
+ #ifdef TEST
+ fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Handling event.\n");
+ #endif
+
+ local = nxagentRemoteToLocalAtom(xfixesEvent -> xfixesselection.selection);
+
+ if (SelectionCallback)
+ {
+ i = 0;
+
+ while ((i < NumCurrentSelections) &&
+ CurrentSelections[i].selection != local)
+ i++;
+
+ if (i < NumCurrentSelections)
+ {
+ SelectionInfoRec info;
+
+ if (CurrentSelections[i].client != 0)
+ {
+ #ifdef TEST
+ fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Do nothing.\n");
+ #endif
+
+ return 1;
+ }
+
+ #ifdef TEST
+ fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Calling callbacks for %d [%s] selection.\n",
+ CurrentSelections[i].selection, NameForAtom(CurrentSelections[i].selection));
+ #endif
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Subtype ");
+
+ switch (xfixesEvent -> xfixesselection.subtype)
+ {
+ case SelectionSetOwner:
+ fprintf(stderr, "SelectionSetOwner.\n");
+ break;
+ case SelectionWindowDestroy:
+ fprintf(stderr, "SelectionWindowDestroy.\n");
+ break;
+ case SelectionClientClose:
+ fprintf(stderr, "SelectionClientClose.\n");
+ break;
+ default:
+ fprintf(stderr, ".\n");
+ break;
+ }
+ #endif
+
+ info.selection = &CurrentSelections[i];
+ info.kind = xfixesEvent->xfixesselection.subtype;
+ CallCallbacks(&SelectionCallback, &info);
+ }
+ }
+ return 1;
+}
+
int nxagentHandleProxyEvent(XEvent *X)
{
switch (X -> xclient.data.l[0])
@@ -2924,56 +3062,6 @@ int nxagentHandleReparentNotify(XEvent* X)
return 1;
}
- else
- {
- /*
- * This code is supposed to detect if a window manager
- * is running but in some cases it may be unreliable.
- * Each window manager behaves differently so the check
- * can fail for some less common WMs.
- */
-
- if (!nxagentWMIsRunning && nxagentOption(Fullscreen) &&
- X -> xreparent.window == nxagentDefaultWindows[pScreen -> myNum])
- {
- #ifdef WARNING
- fprintf(stderr, "Warning: The agent window was reparented. Is a "
- "window manager running?\n");
- #endif
-
- /*
- * If no window manager is running and we are supposed to
- * be in fullscreen mode then don't wait for the reparent
- * event. We can assume that there is an undetected window
- * manager and, as switching to fullscreen could have fail-
- * ed, we try it again.
- */
-
- nxagentSwitchFullscreen(pScreen, True);
-
- nxagentWMIsRunning = True;
- }
- else if (nxagentWMIsRunning && X -> xreparent.window ==
- nxagentDefaultWindows[pScreen -> myNum] && X -> xreparent.parent ==
- RootWindow(nxagentDisplay, (pScreen -> myNum)))
- {
- #ifdef WARNING
-
- fprintf(stderr, "Warning: The agent window has been reparented to the root.\n");
-
- fprintf(stderr, "Warning: No window manager seems to be running.\n");
-
- #endif
-
- /*
- * The agent window was unexpectedly reparented
- * to the root window. We assume that the window
- * manager was terminated.
- */
-
- nxagentWMIsRunning = False;
- }
- }
return 1;
}