Permalink
Browse files

initial support for property changes and send events, SelectionReques…

…t events
  • Loading branch information...
NotFound committed Dec 8, 2011
1 parent 23dba7a commit 2c1484bdd95aed18ca9bccef8857a42df064c8ed
Showing with 76 additions and 2 deletions.
  1. +6 −0 GuitorConstants.winxhead
  2. +64 −2 src/Guitor.winxed
  3. +6 −0 src/GuitorNci.winxed
View
@@ -60,6 +60,12 @@ const int
GrabModeSync = 0,
GrabModeAsync = 1;
+// Property change modes
+const int
+ PropModeReplace = 0,
+ PropModePrepend = 1,
+ PropModeAppend = 2;
+
// WM hints
const int InputHint = 1;
View
@@ -282,6 +282,11 @@ class Display
var fn = getfun("XNextEvent");
event._get(self.xdisplay, fn);
}
+ function SendEvent(int xwindow, int propagate, int event_mask, event)
+ {
+ getfun("XSendEvent")(self.xdisplay, xwindow,
+ propagate, event_mask, event.eventdata);
+ }
function SetWMProtocols(drawable, names)
{
__DEBUG__ && cry(__FUNCTION__);
@@ -402,6 +407,24 @@ class Display
{
return int(getfun("XGetSelectionOwner")(self.xdisplay, selection));
}
+ function ChangePropertyInt32(int xwindow,
+ int property, int type, int mode, int value)
+ {
+ var viewint = new ["StructView"] ( [ DATATYPE_STRUCT, 1, DATATYPE_INT ] );
+ var pvalue = viewint.alloc();
+ viewint[pvalue, 0] = value;
+ var fun = getfun("XChangeProperty");
+ fun(self.xdisplay, xwindow, property, type, 32, mode,
+ pvalue, 1);
+ }
+ function ChangePropertyString(int xwindow,
+ int property, int type, int mode, string value)
+ {
+ var pvalue = str_to_achar_utf8(value);
+ var fun = getfun("XChangeProperty");
+ fun(self.xdisplay, xwindow, property, type, 8, mode,
+ pvalue, elements(pvalue));
+ }
}
//**********************************************************************
@@ -627,11 +650,12 @@ class Event
var evbutton;
var evstate;
var time;
- function Event()
+ function Event(int type[optional])
{
self.eventdata = geteventpad().alloc();
self.anyview = getanyview();
- self.evtype = 0;
+ self.evtype = type;
+ self.anyview[self.eventdata, 0] = type;
self.evx = 0;
self.evy = 0;
self.evx_root = 0;
@@ -642,6 +666,44 @@ class Event
self.evbutton = 0;
self.evstate = 0;
}
+ function getview()
+ {
+ var view = self.anyview;
+ int type = view[self.eventdata, 0];
+ switch (type) {
+ case ConfigureNotify:
+ view = getstructureview();
+ break;
+ case Expose:
+ view = getexposeview();
+ break;
+ case KeyPress:
+ view = getkeyview();
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ view = getbuttonview();
+ break;
+ case MotionNotify:
+ view = getmotionview();
+ break;
+ case FocusIn:
+ case FocusOut:
+ view = getfocusview();
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ view = getcrossingview();
+ break;
+ case SelectionRequest:
+ view = getselectionrequestview();
+ break;
+ case SelectionNotify:
+ view = getselectionview();
+ break;
+ }
+ return view;
+ }
function _get(xdisplay, fn)
{
var eventdata = self.eventdata;
View
@@ -601,6 +601,9 @@ function create_function(string funcname)
case "XFilterEvent":
sig = "ipi";
break;
+ case "XSendEvent":
+ sig = "ipiilp";
+ break;
case "XKeycodeToKeysym":
sig = "ipii";
break;
@@ -696,6 +699,9 @@ function create_function(string funcname)
case "XGetWindowProperty":
sig = "ipiilliippppp";
break;
+ case "XChangeProperty":
+ sig = "vpiiiiipi";
+ break;
case "XSetSelectionOwner":
sig = "vpiil";
break;

0 comments on commit 2c1484b

Please sign in to comment.