Permalink
Browse files

improve selection events

  • Loading branch information...
NotFound committed Dec 8, 2011
1 parent 1a692ba commit 23dba7a237c7469bcf092ae661b9d1789adc63a4
Showing with 146 additions and 26 deletions.
  1. +98 −5 src/Guitor.winxed
  2. +48 −21 src/GuitorNci.winxed
View
@@ -37,6 +37,7 @@ extern function getfocusview;
extern function getmotionview;
extern function getbuttonview;
extern function getkeyview;
+extern function getselectionrequestview;
extern function getselectionview;
extern function getclientview;
extern function getxcolorview;
@@ -392,6 +393,15 @@ class Display
}
return pixmap, shape;
}
+ function SetSelectionOwner(int selection, window, int time)
+ {
+ getfun("XSetSelectionOwner")(self.xdisplay,
+ selection, window.xdrawable, time);
+ }
+ function GetSelectionOwner(int selection)
+ {
+ return int(getfun("XGetSelectionOwner")(self.xdisplay, selection));
+ }
}
//**********************************************************************
@@ -789,6 +799,86 @@ class Event
}
return detail;
}
+ function requestor()
+ {
+ int req = None;
+ int type = self.evtype;
+ var view;
+ int pos;
+ switch (type) {
+ case SelectionRequest:
+ view = getselectionrequestview();
+ pos = 5;
+ break;
+ case SelectionNotify:
+ view = getselectionview();
+ pos = 4;
+ break;
+ }
+ if (view != null)
+ req = view[self.eventdata, pos];
+ return req;
+ }
+ function selection()
+ {
+ int req = None;
+ int type = self.evtype;
+ var view;
+ int pos;
+ switch (type) {
+ case SelectionRequest:
+ view = getselectionrequestview();
+ pos = 6;
+ break;
+ case SelectionNotify:
+ view = getselectionview();
+ pos = 5;
+ break;
+ }
+ if (view != null)
+ req = view[self.eventdata, pos];
+ return req;
+ }
+ function target()
+ {
+ int req = None;
+ int type = self.evtype;
+ var view;
+ int pos;
+ switch (type) {
+ case SelectionRequest:
+ view = getselectionrequestview();
+ pos = 7;
+ break;
+ case SelectionNotify:
+ view = getselectionview();
+ pos = 6;
+ break;
+ }
+ if (view != null)
+ req = view[self.eventdata, pos];
+ return req;
+ }
+ function property()
+ {
+ int req = None;
+ int type = self.evtype;
+ var view;
+ int pos;
+ switch (type) {
+ case SelectionRequest:
+ view = getselectionrequestview();
+ pos = 8;
+ break;
+ case SelectionNotify:
+ view = getselectionview();
+ pos = 7;
+ break;
+ }
+ if (view != null)
+ req = view[self.eventdata, pos];
+ return req;
+ }
function message_type()
{
int type = 0;
@@ -1457,6 +1547,7 @@ class ListenerWindow : Window
var OnLeave;
var OnFocusIn;
var OnFocusOut;
+ var OnSelectionRequest;
var OnSelectionNotify;
var OnClientMessage;
function ListenerWindow(controller)
@@ -1473,6 +1564,7 @@ class ListenerWindow : Window
self.OnLeave = new EventHandler(self, LeaveWindowMask);
self.OnFocusIn = new EventHandler(self, FocusChangeMask);
self.OnFocusOut = new EventHandler(self, FocusChangeMask);
+ self.OnSelectionRequest = new EventHandler(self, 0);
self.OnSelectionNotify = new EventHandler(self, 0);
self.OnClientMessage = new EventHandler(self, 0);
self.controller = controller;
@@ -1524,6 +1616,9 @@ class ListenerWindow : Window
case LeaveNotify:
handler = self.OnLeave;
break;
+ case SelectionRequest:
+ handler = self.OnSelectionRequest;
+ break;
case SelectionNotify:
handler = self.OnSelectionNotify;
break;
@@ -1864,11 +1959,9 @@ class EditBox : ChildWindow
function onselectionnotify(event)
{
var display = self.display;
- var view = getselectionview();
- var data = event.eventdata;
- int selection = view[data, 5];
- int target = view[data, 6];
- int property = view[data, 7];
+ int selection = event.selection();
+ int target = event.target();
+ int property = event.property();
if (property == None) {
if (target == display.InternAtom("UTF8_STRING")) {
// Retry with plain string type
View
@@ -16,27 +16,28 @@ namespace Xlib__nci
{
// Variable names
const string
- XLIB = "guitor_xlib",
- XFTLIB = "guitor_xftlib",
- XPMLIB = "guitor_xpmlib",
- EVENTPAD = "guitor_eventpad",
- ANYVIEW = "guitor_anyview",
- BUTTONVIEW = "guitor_buttonview",
- KEYVIEW = "guitor_keyview",
- MOTIONVIEW = "guitor_motionview",
- STRUCTUREVIEW = "guitor_structureview",
- EXPOSEVIEW = "guitor_exposeview",
- FOCUSVIEW = "guitor_focusview",
- CROSSINGVIEW = "guitor_crossingview",
- SELECTIONVIEW = "guitor_selectionview",
- CLIENTVIEW = "guitor_clientview",
- XAWMHINTSVIEW = "guitor_xawmhintsview",
- ATOMVIEW = "guitor_atomview",
- XCOLORVIEW = "guitor_xcolorview",
- XFTCOLORVIEW = "guitor_xftcolorview",
- XFONTVIEW = "guitor_xfontview",
- XFTFONTVIEW = "guitor_xftfontview",
- GLYPHINFOVIEW = "guitor_glyphinfoview";
+ XLIB = "guitor_xlib",
+ XFTLIB = "guitor_xftlib",
+ XPMLIB = "guitor_xpmlib",
+ EVENTPAD = "guitor_eventpad",
+ ANYVIEW = "guitor_anyview",
+ BUTTONVIEW = "guitor_buttonview",
+ KEYVIEW = "guitor_keyview",
+ MOTIONVIEW = "guitor_motionview",
+ STRUCTUREVIEW = "guitor_structureview",
+ EXPOSEVIEW = "guitor_exposeview",
+ FOCUSVIEW = "guitor_focusview",
+ CROSSINGVIEW = "guitor_crossingview",
+ SELECTIONVIEW = "guitor_selectionview",
+ SELECTIONREQUESTVIEW = "guitor_selectionrequestview",
+ CLIENTVIEW = "guitor_clientview",
+ XAWMHINTSVIEW = "guitor_xawmhintsview",
+ ATOMVIEW = "guitor_atomview",
+ XCOLORVIEW = "guitor_xcolorview",
+ XFTCOLORVIEW = "guitor_xftcolorview",
+ XFONTVIEW = "guitor_xfontview",
+ XFTFONTVIEW = "guitor_xftfontview",
+ GLYPHINFOVIEW = "guitor_glyphinfoview";
function loadXlib()
{
@@ -326,6 +327,26 @@ function getcrossingview()
return st;
}
+function getselectionrequestview()
+{
+ var ns = namespace Xlib__nci;
+ var st = ns[SELECTIONREQUESTVIEW];
+ if (st == null)
+ ns[SELECTIONVIEW] = st = new ["StructView"]( [ DATATYPE_STRUCT, 10,
+ DATATYPE_INT, // type
+ DATATYPE_LONG, // serial
+ XLIB_Bool, // send event
+ DATATYPE_PTR, // display
+ XLIB_Window, // owner
+ XLIB_Window, // requestor
+ XLIB_Atom, // selection
+ XLIB_Atom, // target
+ XLIB_Atom, // property
+ XLIB_time_t // time
+ ] );
+ return st;
+}
+
function getselectionview()
{
var ns = namespace Xlib__nci;
@@ -675,6 +696,12 @@ function create_function(string funcname)
case "XGetWindowProperty":
sig = "ipiilliippppp";
break;
+ case "XSetSelectionOwner":
+ sig = "vpiil";
+ break;
+ case "XGetSelectionOwner":
+ sig = "ipi";
+ break;
case "XConvertSelection":
sig = "vpiiiil";
break;

0 comments on commit 23dba7a

Please sign in to comment.