Skip to content
Browse files

Enter and Leave events

  • Loading branch information...
1 parent 77c9ed2 commit 3801b142de14a20ec2bb6c0d2a4e0163c3c45e57 @NotFound committed Dec 4, 2011
Showing with 83 additions and 2 deletions.
  1. +10 −0 GuitorConstants.winxhead
  2. +42 −1 src/Guitor.winxed
  3. +31 −1 src/GuitorNci.winxed
View
10 GuitorConstants.winxhead
@@ -40,6 +40,14 @@ const int
const int None = 0;
const int CurrentTime = 0;
+// Enter and Leave
+const int
+ NotifyAncestor = 0,
+ NotifyVirtual = 1,
+ NotifyInferior = 2,
+ NotifyNonlinear = 3,
+ NotifyNonlinearVirtual = 4;
+
// Focus revert type
const int
RevertToNone = 0,
@@ -71,6 +79,8 @@ const int
ButtonPress = 4,
ButtonRelease = 5,
MotionNotify = 6,
+ EnterNotify = 7,
+ LeaveNotify = 8,
FocusIn = 9,
FocusOut = 10,
Expose = 12,
View
43 src/Guitor.winxed
@@ -31,6 +31,7 @@ extern function geteventpad;
extern function getanyview;
extern function getstructureview;
extern function getexposeview;
+extern function getcrossingview;
extern function getfocusview;
extern function getmotionview;
extern function getbuttonview;
@@ -561,6 +562,7 @@ class Event
var evheight;
var evkeycode;
var evbutton;
+ var evstate;
function Event()
{
self.eventdata = geteventpad().alloc();
@@ -574,6 +576,7 @@ class Event
self.evheight = 0;
self.evkeycode = -1;
self.evbutton = 0;
+ self.evstate = 0;
}
function _get(xdisplay, fn)
{
@@ -584,7 +587,8 @@ class Event
self.evtype =: type;
int x = 0, y = 0, x_root = 0, y_root = 0,
width = 0, height = 0,
- keycode = -1, button = 0;
+ keycode = -1, button = 0,
+ state = 0;
switch (type) {
case ConfigureNotify:
view = getstructureview();
@@ -607,6 +611,7 @@ class Event
x_root = view[eventdata, 10];
y_root = view[eventdata, 11];
keycode = view[eventdata, 13];
+ state = view[eventdata, 12];
break;
case ButtonPress:
case ButtonRelease:
@@ -616,18 +621,29 @@ class Event
x_root = view[eventdata, 10];
y_root = view[eventdata, 11];
button = view[eventdata, 13];
+ state = view[eventdata, 12];
break;
case MotionNotify:
view = getmotionview();
x = view[eventdata, 8];
y = view[eventdata, 9];
x_root = view[eventdata, 10];
y_root = view[eventdata, 11];
+ state = view[eventdata, 12];
break;
case FocusIn:
case FocusOut:
view = getfocusview();
break;
+ case EnterNotify:
+ case LeaveNotify:
+ view = getcrossingview();
+ x = view[eventdata, 8];
+ y = view[eventdata, 9];
+ x_root = view[eventdata, 10];
+ y_root = view[eventdata, 11];
+ state = view[eventdata, 16];
+ break;
}
self.evx =: x;
self.evy =: y;
@@ -637,6 +653,7 @@ class Event
self.evheight =: height;
self.evkeycode =: keycode;
self.evbutton =: button;
+ self.evstate =: state;
}
function type()
{
@@ -700,6 +717,20 @@ class Event
{
return int(self.evbutton);
}
+ function state()
+ {
+ return int(self.evstate);
+ }
+ function detail()
+ {
+ int detail = 0;
+ int type = self.evtype;
+ if (type == EnterNotify || type == LeaveNotify) {
+ var view = getcrossingview();
+ detail = view[self.eventdata, 13];
+ }
+ return detail;
+ }
function message_type()
{
int type = 0;
@@ -1165,6 +1196,8 @@ class ListenerWindow : Window
var OnButtonRelease;
var OnMotion;
var OnDestroy;
+ var OnEnter;
+ var OnLeave;
var OnFocusIn;
var OnFocusOut;
var OnClientMessage;
@@ -1178,6 +1211,8 @@ class ListenerWindow : Window
self.OnButtonRelease = new EventHandler(self, ButtonReleaseMask);
self.OnMotion = new EventHandler(self, PointerMotionMask);
self.OnDestroy = new EventHandler(self, StructureNotifyMask);
+ self.OnEnter = new EventHandler(self, EnterWindowMask);
+ self.OnLeave = new EventHandler(self, LeaveWindowMask);
self.OnFocusIn = new EventHandler(self, FocusChangeMask);
self.OnFocusOut = new EventHandler(self, FocusChangeMask);
self.OnClientMessage = new EventHandler(self, 0);
@@ -1224,6 +1259,12 @@ class ListenerWindow : Window
case FocusOut:
handler = self.OnFocusOut;
break;
+ case EnterNotify:
+ handler = self.OnEnter;
+ break;
+ case LeaveNotify:
+ handler = self.OnLeave;
+ break;
case ClientMessage:
handler = self.OnClientMessage;
break;
View
32 src/GuitorNci.winxed
@@ -28,6 +28,7 @@ const string
STRUCTUREVIEW = "guitor_structureview",
EXPOSEVIEW = "guitor_exposeview",
FOCUSVIEW = "guitor_focusview",
+ CROSSINGVIEW = "guitor_crossingview",
CLIENTVIEW = "guitor_clientview",
XAWMHINTSVIEW = "guitor_xawmhintsview",
ATOMVIEW = "guitor_atomview",
@@ -322,10 +323,39 @@ function getfocusview()
var ns = namespace Xlib__private;
var st = ns[FOCUSVIEW];
if (st == null)
- ns[FOCUSVIEW] = st = create_exposeview();
+ ns[FOCUSVIEW] = st = create_focusview();
return st;
}
+function getcrossingview()
+{
+ var ns = namespace Xlib__private;
+ var st = ns[CROSSINGVIEW];
+ if (st == null)
+ ns[CROSSINGVIEW] = st = new ["StructView"] ( [ DATATYPE_STRUCT, 17,
+ DATATYPE_INT, // type
+ DATATYPE_LONG, // Serial
+ XLIB_Bool, // send event
+ DATATYPE_PTR, // display
+ XLIB_Window, // window
+ XLIB_Window, // root
+ XLIB_Window, // subwindow
+ XLIB_time_t, // time
+ DATATYPE_INT, // x
+ DATATYPE_INT, // y
+ DATATYPE_INT, // x_root
+ DATATYPE_INT, // y_root
+ DATATYPE_INT, // mode
+ DATATYPE_INT, // detail
+ XLIB_Bool, // same_screen
+ XLIB_Bool, // focus
+ DATATYPE_INT // state
+ ] );
+ return st;
+}
+
+
+
function getclientview()
{
var ns = namespace Xlib__private;

0 comments on commit 3801b14

Please sign in to comment.
Something went wrong with that request. Please try again.