Module: ActiveWindowX::Xlib

Defined in:
lib/active_window_x.rb,
ext/active_window_x/xlib.c

Defined Under Namespace

Classes: Display, UnknownDisplayName, XClientMessageClass, XErrorEvent, XEvent, XPropertyEvent

Constant Summary collapse

X =
INT2NUM(X)
None =
INT2NUM(None)
ParentRelative =
INT2NUM(ParentRelative)
CopyFromParent =
INT2NUM(CopyFromParent)
PointerWindow =
INT2NUM(PointerWindow)
InputFocus =
INT2NUM(InputFocus)
PointerRoot =
INT2NUM(PointerRoot)
AnyPropertyType =
INT2NUM(AnyPropertyType)
AnyKey =
INT2NUM(AnyKey)
AnyButton =
INT2NUM(AnyButton)
AllTemporary =
INT2NUM(AllTemporary)
CurrentTime =
INT2NUM(CurrentTime)
NoSymbol =
INT2NUM(NoSymbol)
NoEventMask =
INT2NUM(NoEventMask)
KeyPressMask =
INT2NUM(KeyPressMask)
KeyReleaseMask =
INT2NUM(KeyReleaseMask)
ButtonPressMask =
INT2NUM(ButtonPressMask)
ButtonReleaseMask =
INT2NUM(ButtonReleaseMask)
EnterWindowMask =
INT2NUM(EnterWindowMask)
LeaveWindowMask =
INT2NUM(LeaveWindowMask)
PointerMotionMask =
INT2NUM(PointerMotionMask)
PointerMotionHintMask =
INT2NUM(PointerMotionHintMask)
ButtonMotionMask =
INT2NUM(ButtonMotionMask)
KeymapStateMask =
INT2NUM(KeymapStateMask)
ExposureMask =
INT2NUM(ExposureMask)
VisibilityChangeMask =
INT2NUM(VisibilityChangeMask)
StructureNotifyMask =
INT2NUM(StructureNotifyMask)
ResizeRedirectMask =
INT2NUM(ResizeRedirectMask)
SubstructureNotifyMask =
INT2NUM(SubstructureNotifyMask)
SubstructureRedirectMask =
INT2NUM(SubstructureRedirectMask)
FocusChangeMask =
INT2NUM(FocusChangeMask)
PropertyChangeMask =
INT2NUM(PropertyChangeMask)
ColormapChangeMask =
INT2NUM(ColormapChangeMask)
OwnerGrabButtonMask =
INT2NUM(OwnerGrabButtonMask)
KeyPress =
INT2NUM(KeyPress)
KeyRelease =
INT2NUM(KeyRelease)
ButtonPress =
INT2NUM(ButtonPress)
ButtonRelease =
INT2NUM(ButtonRelease)
MotionNotify =
INT2NUM(MotionNotify)
EnterNotify =
INT2NUM(EnterNotify)
LeaveNotify =
INT2NUM(LeaveNotify)
FocusIn =
INT2NUM(FocusIn)
FocusOut =
INT2NUM(FocusOut)
KeymapNotify =
INT2NUM(KeymapNotify)
Expose =
INT2NUM(Expose)
GraphicsExpose =
INT2NUM(GraphicsExpose)
NoExpose =
INT2NUM(NoExpose)
VisibilityNotify =
INT2NUM(VisibilityNotify)
CreateNotify =
INT2NUM(CreateNotify)
DestroyNotify =
INT2NUM(DestroyNotify)
UnmapNotify =
INT2NUM(UnmapNotify)
MapNotify =
INT2NUM(MapNotify)
MapRequest =
INT2NUM(MapRequest)
ReparentNotify =
INT2NUM(ReparentNotify)
ConfigureNotify =
INT2NUM(ConfigureNotify)
ConfigureRequest =
INT2NUM(ConfigureRequest)
GravityNotify =
INT2NUM(GravityNotify)
ResizeRequest =
INT2NUM(ResizeRequest)
CirculateNotify =
INT2NUM(CirculateNotify)
CirculateRequest =
INT2NUM(CirculateRequest)
PropertyNotify =
INT2NUM(PropertyNotify)
SelectionClear =
INT2NUM(SelectionClear)
SelectionRequest =
INT2NUM(SelectionRequest)
SelectionNotify =
INT2NUM(SelectionNotify)
ColormapNotify =
INT2NUM(ColormapNotify)
ClientMessage =
INT2NUM(ClientMessage)
MappingNotify =
INT2NUM(MappingNotify)
GenericEvent =
INT2NUM(GenericEvent)
LASTEvent =
INT2NUM(LASTEvent)
ShiftMask =
INT2NUM(ShiftMask)
LockMask =
INT2NUM(LockMask)
ControlMask =
INT2NUM(ControlMask)
Mod =
INT2NUM(Mod)
ShiftMapIndex =
INT2NUM(ShiftMapIndex)
LockMapIndex =
INT2NUM(LockMapIndex)
ControlMapIndex =
INT2NUM(ControlMapIndex)
Button =
INT2NUM(Button)
AnyModifier =
INT2NUM(AnyModifier)
NotifyNormal =
INT2NUM(NotifyNormal)
NotifyGrab =
INT2NUM(NotifyGrab)
NotifyUngrab =
INT2NUM(NotifyUngrab)
NotifyWhileGrabbed =
INT2NUM(NotifyWhileGrabbed)
NotifyHint =
INT2NUM(NotifyHint)
NotifyAncestor =
INT2NUM(NotifyAncestor)
NotifyVirtual =
INT2NUM(NotifyVirtual)
NotifyInferior =
INT2NUM(NotifyInferior)
NotifyNonlinear =
INT2NUM(NotifyNonlinear)
NotifyNonlinearVirtual =
INT2NUM(NotifyNonlinearVirtual)
NotifyPointer =
INT2NUM(NotifyPointer)
NotifyPointerRoot =
INT2NUM(NotifyPointerRoot)
NotifyDetailNone =
INT2NUM(NotifyDetailNone)
VisibilityUnobscured =
INT2NUM(VisibilityUnobscured)
VisibilityPartiallyObscured =
INT2NUM(VisibilityPartiallyObscured)
VisibilityFullyObscured =
INT2NUM(VisibilityFullyObscured)
PlaceOnTop =
INT2NUM(PlaceOnTop)
PlaceOnBottom =
INT2NUM(PlaceOnBottom)
FamilyDECnet =
INT2NUM(FamilyDECnet)
FamilyChaos =
INT2NUM(FamilyChaos)
FamilyInternet =
INT2NUM(FamilyInternet)
FamilyServerInterpreted =
INT2NUM(FamilyServerInterpreted)
PropertyNewValue =
INT2NUM(PropertyNewValue)
PropertyDelete =
INT2NUM(PropertyDelete)
ColormapUninstalled =
INT2NUM(ColormapUninstalled)
ColormapInstalled =
INT2NUM(ColormapInstalled)
GrabModeSync =
INT2NUM(GrabModeSync)
GrabModeAsync =
INT2NUM(GrabModeAsync)
GrabSuccess =
INT2NUM(GrabSuccess)
AlreadyGrabbed =
INT2NUM(AlreadyGrabbed)
GrabInvalidTime =
INT2NUM(GrabInvalidTime)
GrabNotViewable =
INT2NUM(GrabNotViewable)
GrabFrozen =
INT2NUM(GrabFrozen)
AsyncPointer =
INT2NUM(AsyncPointer)
SyncPointer =
INT2NUM(SyncPointer)
ReplayPointer =
INT2NUM(ReplayPointer)
AsyncKeyboard =
INT2NUM(AsyncKeyboard)
SyncKeyboard =
INT2NUM(SyncKeyboard)
ReplayKeyboard =
INT2NUM(ReplayKeyboard)
AsyncBoth =
INT2NUM(AsyncBoth)
SyncBoth =
INT2NUM(SyncBoth)
RevertToNone =
INT2NUM(RevertToNone)
RevertToPointerRoot =
INT2NUM(RevertToPointerRoot)
RevertToParent =
INT2NUM(RevertToParent)
Success =
INT2NUM(Success)
BadRequest =
INT2NUM(BadRequest)
BadValue =
INT2NUM(BadValue)
BadWindow =
INT2NUM(BadWindow)
BadPixmap =
INT2NUM(BadPixmap)
BadAtom =
INT2NUM(BadAtom)
BadCursor =
INT2NUM(BadCursor)
BadFont =
INT2NUM(BadFont)
BadMatch =
INT2NUM(BadMatch)
BadDrawable =
INT2NUM(BadDrawable)
BadAccess =
INT2NUM(BadAccess)
BadAlloc =
INT2NUM(BadAlloc)
BadColor =
INT2NUM(BadColor)
BadGC =
INT2NUM(BadGC)
BadIDChoice =
INT2NUM(BadIDChoice)
BadName =
INT2NUM(BadName)
BadLength =
INT2NUM(BadLength)
BadImplementation =
INT2NUM(BadImplementation)
FirstExtensionError =
INT2NUM(FirstExtensionError)
LastExtensionError =
INT2NUM(LastExtensionError)
InputOutput =
INT2NUM(InputOutput)
InputOnly =
INT2NUM(InputOnly)
CWBackPixmap =
INT2NUM(CWBackPixmap)
CWBackPixel =
INT2NUM(CWBackPixel)
CWBorderPixmap =
INT2NUM(CWBorderPixmap)
CWBorderPixel =
INT2NUM(CWBorderPixel)
CWBitGravity =
INT2NUM(CWBitGravity)
CWWinGravity =
INT2NUM(CWWinGravity)
CWBackingStore =
INT2NUM(CWBackingStore)
CWBackingPlanes =
INT2NUM(CWBackingPlanes)
CWBackingPixel =
INT2NUM(CWBackingPixel)
CWOverrideRedirect =
INT2NUM(CWOverrideRedirect)
CWSaveUnder =
INT2NUM(CWSaveUnder)
CWEventMask =
INT2NUM(CWEventMask)
CWDontPropagate =
INT2NUM(CWDontPropagate)
CWColormap =
INT2NUM(CWColormap)
CWCursor =
INT2NUM(CWCursor)
CWX =
INT2NUM(CWX)
CWY =
INT2NUM(CWY)
CWWidth =
INT2NUM(CWWidth)
CWHeight =
INT2NUM(CWHeight)
CWBorderWidth =
INT2NUM(CWBorderWidth)
CWSibling =
INT2NUM(CWSibling)
CWStackMode =
INT2NUM(CWStackMode)
ForgetGravity =
INT2NUM(ForgetGravity)
NorthWestGravity =
INT2NUM(NorthWestGravity)
NorthGravity =
INT2NUM(NorthGravity)
NorthEastGravity =
INT2NUM(NorthEastGravity)
WestGravity =
INT2NUM(WestGravity)
CenterGravity =
INT2NUM(CenterGravity)
EastGravity =
INT2NUM(EastGravity)
SouthWestGravity =
INT2NUM(SouthWestGravity)
SouthGravity =
INT2NUM(SouthGravity)
SouthEastGravity =
INT2NUM(SouthEastGravity)
StaticGravity =
INT2NUM(StaticGravity)
UnmapGravity =
INT2NUM(UnmapGravity)
NotUseful =
INT2NUM(NotUseful)
WhenMapped =
INT2NUM(WhenMapped)
Always =
INT2NUM(Always)
IsUnmapped =
INT2NUM(IsUnmapped)
IsUnviewable =
INT2NUM(IsUnviewable)
IsViewable =
INT2NUM(IsViewable)
SetModeInsert =
INT2NUM(SetModeInsert)
SetModeDelete =
INT2NUM(SetModeDelete)
DestroyAll =
INT2NUM(DestroyAll)
RetainPermanent =
INT2NUM(RetainPermanent)
RetainTemporary =
INT2NUM(RetainTemporary)
Above =
INT2NUM(Above)
Below =
INT2NUM(Below)
TopIf =
INT2NUM(TopIf)
BottomIf =
INT2NUM(BottomIf)
Opposite =
INT2NUM(Opposite)
RaiseLowest =
INT2NUM(RaiseLowest)
LowerHighest =
INT2NUM(LowerHighest)
PropModeReplace =
INT2NUM(PropModeReplace)
PropModePrepend =
INT2NUM(PropModePrepend)
PropModeAppend =
INT2NUM(PropModeAppend)
GXand =
INT2NUM(GXand)
GXandReverse =
INT2NUM(GXandReverse)
GXcopy =
INT2NUM(GXcopy)
GXandInverted =
INT2NUM(GXandInverted)
GXxor =
INT2NUM(GXxor)
GXor =
INT2NUM(GXor)
GXnor =
INT2NUM(GXnor)
GXequiv =
INT2NUM(GXequiv)
GXinvert =
INT2NUM(GXinvert)
GXorReverse =
INT2NUM(GXorReverse)
GXcopyInverted =
INT2NUM(GXcopyInverted)
GXorInverted =
INT2NUM(GXorInverted)
GXnand =
INT2NUM(GXnand)
GXset =
INT2NUM(GXset)
LineSolid =
INT2NUM(LineSolid)
LineOnOffDash =
INT2NUM(LineOnOffDash)
LineDoubleDash =
INT2NUM(LineDoubleDash)
CapNotLast =
INT2NUM(CapNotLast)
CapButt =
INT2NUM(CapButt)
CapRound =
INT2NUM(CapRound)
CapProjecting =
INT2NUM(CapProjecting)
JoinMiter =
INT2NUM(JoinMiter)
JoinRound =
INT2NUM(JoinRound)
JoinBevel =
INT2NUM(JoinBevel)
FillSolid =
INT2NUM(FillSolid)
FillTiled =
INT2NUM(FillTiled)
FillStippled =
INT2NUM(FillStippled)
FillOpaqueStippled =
INT2NUM(FillOpaqueStippled)
EvenOddRule =
INT2NUM(EvenOddRule)
WindingRule =
INT2NUM(WindingRule)
ClipByChildren =
INT2NUM(ClipByChildren)
IncludeInferiors =
INT2NUM(IncludeInferiors)
Unsorted =
INT2NUM(Unsorted)
YSorted =
INT2NUM(YSorted)
YXSorted =
INT2NUM(YXSorted)
YXBanded =
INT2NUM(YXBanded)
CoordModeOrigin =
INT2NUM(CoordModeOrigin)
CoordModePrevious =
INT2NUM(CoordModePrevious)
Complex =
INT2NUM(Complex)
Nonconvex =
INT2NUM(Nonconvex)
Convex =
INT2NUM(Convex)
ArcChord =
INT2NUM(ArcChord)
ArcPieSlice =
INT2NUM(ArcPieSlice)
GCFunction =
INT2NUM(GCFunction)
GCPlaneMask =
INT2NUM(GCPlaneMask)
GCForeground =
INT2NUM(GCForeground)
GCBackground =
INT2NUM(GCBackground)
GCLineWidth =
INT2NUM(GCLineWidth)
GCLineStyle =
INT2NUM(GCLineStyle)
GCCapStyle =
INT2NUM(GCCapStyle)
GCJoinStyle =
INT2NUM(GCJoinStyle)
GCFillStyle =
INT2NUM(GCFillStyle)
GCFillRule =
INT2NUM(GCFillRule)
GCTile =
INT2NUM(GCTile)
GCStipple =
INT2NUM(GCStipple)
GCTileStipXOrigin =
INT2NUM(GCTileStipXOrigin)
GCTileStipYOrigin =
INT2NUM(GCTileStipYOrigin)
GCFont =
INT2NUM(GCFont)
GCSubwindowMode =
INT2NUM(GCSubwindowMode)
GCGraphicsExposures =
INT2NUM(GCGraphicsExposures)
GCClipXOrigin =
INT2NUM(GCClipXOrigin)
GCClipYOrigin =
INT2NUM(GCClipYOrigin)
GCClipMask =
INT2NUM(GCClipMask)
GCDashOffset =
INT2NUM(GCDashOffset)
GCDashList =
INT2NUM(GCDashList)
GCArcMode =
INT2NUM(GCArcMode)
GCLastBit =
INT2NUM(GCLastBit)
FontLeftToRight =
INT2NUM(FontLeftToRight)
FontRightToLeft =
INT2NUM(FontRightToLeft)
FontChange =
INT2NUM(FontChange)
XYBitmap =
INT2NUM(XYBitmap)
XYPixmap =
INT2NUM(XYPixmap)
ZPixmap =
INT2NUM(ZPixmap)
AllocNone =
INT2NUM(AllocNone)
AllocAll =
INT2NUM(AllocAll)
DoRed =
INT2NUM(DoRed)
DoGreen =
INT2NUM(DoGreen)
DoBlue =
INT2NUM(DoBlue)
CursorShape =
INT2NUM(CursorShape)
TileShape =
INT2NUM(TileShape)
StippleShape =
INT2NUM(StippleShape)
AutoRepeatModeOff =
INT2NUM(AutoRepeatModeOff)
AutoRepeatModeOn =
INT2NUM(AutoRepeatModeOn)
AutoRepeatModeDefault =
INT2NUM(AutoRepeatModeDefault)
LedModeOff =
INT2NUM(LedModeOff)
LedModeOn =
INT2NUM(LedModeOn)
KBKeyClickPercent =
INT2NUM(KBKeyClickPercent)
KBBellPercent =
INT2NUM(KBBellPercent)
KBBellPitch =
INT2NUM(KBBellPitch)
KBBellDuration =
INT2NUM(KBBellDuration)
KBLed =
INT2NUM(KBLed)
KBLedMode =
INT2NUM(KBLedMode)
KBKey =
INT2NUM(KBKey)
KBAutoRepeatMode =
INT2NUM(KBAutoRepeatMode)
MappingSuccess =
INT2NUM(MappingSuccess)
MappingBusy =
INT2NUM(MappingBusy)
MappingFailed =
INT2NUM(MappingFailed)
MappingModifier =
INT2NUM(MappingModifier)
MappingKeyboard =
INT2NUM(MappingKeyboard)
MappingPointer =
INT2NUM(MappingPointer)
DontPreferBlanking =
INT2NUM(DontPreferBlanking)
PreferBlanking =
INT2NUM(PreferBlanking)
DefaultBlanking =
INT2NUM(DefaultBlanking)
DisableScreenSaver =
INT2NUM(DisableScreenSaver)
DisableScreenInterval =
INT2NUM(DisableScreenInterval)
DontAllowExposures =
INT2NUM(DontAllowExposures)
AllowExposures =
INT2NUM(AllowExposures)
DefaultExposures =
INT2NUM(DefaultExposures)
ScreenSaverReset =
INT2NUM(ScreenSaverReset)
ScreenSaverActive =
INT2NUM(ScreenSaverActive)
HostInsert =
INT2NUM(HostInsert)
HostDelete =
INT2NUM(HostDelete)
EnableAccess =
INT2NUM(EnableAccess)
DisableAccess =
INT2NUM(DisableAccess)
StaticGray =
INT2NUM(StaticGray)
GrayScale =
INT2NUM(GrayScale)
StaticColor =
INT2NUM(StaticColor)
PseudoColor =
INT2NUM(PseudoColor)
TrueColor =
INT2NUM(TrueColor)
DirectColor =
INT2NUM(DirectColor)
LSBFirst =
INT2NUM(LSBFirst)
MSBFirst =
INT2NUM(MSBFirst)

Class Method Summary collapse

Class Method Details

.connection_number(display_obj) ⇒ Object

ConnectionNumber



139
140
141
142
143
# File 'ext/active_window_x/xlib.c', line 139

VALUE xlib_connection_number(VALUE self, VALUE display_obj) {
  Display* display;
  GetDisplay(display_obj, display);
  return INT2FIX(ConnectionNumber(display));
}

.default_root_window(d) ⇒ Object

DefaultRootWindow



127
128
129
130
131
132
133
134
135
136
# File 'ext/active_window_x/xlib.c', line 127

VALUE xlib_default_root_window(VALUE self, VALUE d) {
  Display* display;
  Window root;

  GetDisplay(d, display);

  root = DefaultRootWindow(display);

  return root == None ? Qnil : ULONG2NUM(root);
}

.x_close_display(display_obj) ⇒ Object

XCloseDisplay



67
68
69
70
71
72
73
74
# File 'ext/active_window_x/xlib.c', line 67

VALUE xlib_x_close_display(VALUE self, VALUE display_obj) {
  Display* d;
  int i;
  GetDisplay(display_obj, d);
  i = XCloseDisplay(d);
  raise_if_xerror_occurred();
  return INT2FIX(i);
}

.x_get_atom_name(d, atom_obj) ⇒ Object

XGetAtomName



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'ext/active_window_x/xlib.c', line 163

static VALUE xlib_x_get_atom_name(VALUE self, VALUE d, VALUE atom_obj){
  Display* display;
  Atom atom;
  char *name;
  VALUE r;

  GetDisplay(d, display);
  atom = NUM2ULONG(atom_obj);

  name = XGetAtomName(display, atom);
  raise_if_xerror_occurred();

  if(name == NULL) {
    r = Qnil;
  } else {
    r = rb_str_new2(name);
    XFree(name);
  }
  return r;
}

.x_get_input_focus(display_obj) ⇒ Object

XGetInputFocus



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'ext/active_window_x/xlib.c', line 77

VALUE xlib_x_get_input_focus(VALUE self, VALUE display_obj) {
  Display* d;
  Window window;
  int revert_to;
  VALUE arr_obj;

  GetDisplay(display_obj, d);
  XGetInputFocus(d, &window, &revert_to);
  raise_if_xerror_occurred();

  arr_obj = rb_ary_new2(2L);
  rb_ary_push(arr_obj, window == None ? Qnil : ULONG2NUM((unsigned long) window));
  rb_ary_push(arr_obj, INT2FIX(revert_to));

  return arr_obj;
}

.x_get_window_property(display_obj, w_obj, property_obj, long_offset_obj, long_length_obj, delete_obj, req_type_obj) ⇒ Object

XGetWindowProperty



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'ext/active_window_x/xlib.c', line 185

static VALUE xlib_x_get_window_property(VALUE self, VALUE display_obj, VALUE w_obj,
                                        VALUE property_obj, VALUE long_offset_obj,
                                        VALUE long_length_obj, VALUE delete_obj,
                                        VALUE req_type_obj){
  Display* display;
  Window w;
  Atom property;
  long long_offset, long_length;
  Bool delete;
  Atom req_type;
  Atom actual_type_return;
  int actual_format_return;
  unsigned long nitems_return;
  unsigned long bytes_after_return;
  unsigned char *prop_return;
  int result, prop_size, nbytes;
  VALUE ary, prop;

  GetDisplay(display_obj, display);
  w = (Window) NUM2ULONG(w_obj);
  property = (Atom) NUM2ULONG(property_obj);
  long_offset = NUM2LONG(long_offset_obj);
  long_length = NUM2LONG(long_length_obj);
  delete = (delete_obj == Qfalse || delete_obj == Qnil) ? False : True;
  req_type = (Atom) NUM2ULONG(req_type_obj);

  result = XGetWindowProperty(display, w, property, long_offset, long_length, delete,
                              req_type,
                              &actual_type_return, &actual_format_return,
                              &nitems_return, &bytes_after_return, &prop_return);
  raise_if_xerror_occurred();
  if (result != Success)
    rb_raise(rb_eRuntimeError, "XGetWindowProperty faild");

  if (prop_return == NULL) {
    prop = Qnil;
  } else {
    // get nbytes (reffer to Get_Window_Property_Data_And_Type of xprop)
    switch (actual_format_return) {
    case 32 : nbytes = sizeof(long); break;
    case 16 : nbytes = 2; break;
    case 8 : nbytes = 1; break;
    case 0 : nbytes = 0; break;
    default: rb_raise(rb_eRuntimeError,
                      "Unexpected actual_format_return(%d) on XGetWindowProperty",
                      actual_format_return);
    }
    prop_size = nbytes * nitems_return;
    prop = rb_str_new((const char*) prop_return, prop_size);
    XFree(prop_return);
  }

  ary = rb_ary_new2(5L);
  rb_ary_push(ary, ULONG2NUM(actual_type_return));
  rb_ary_push(ary, INT2FIX(actual_format_return));
  rb_ary_push(ary, LONG2NUM(nitems_return));
  rb_ary_push(ary, LONG2NUM(bytes_after_return));
  rb_ary_push(ary, prop);

  return ary;
}

.x_intern_atom(d, name_obj, b) ⇒ Object

XInternAtom



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'ext/active_window_x/xlib.c', line 146

static VALUE xlib_x_intern_atom(VALUE self, VALUE d, VALUE name_obj, VALUE b) {
  Display* display;
  Atom atom;
  char *name;
  Bool bool;

  GetDisplay(d, display);
  name = StringValuePtr(name_obj);
  bool = (b == Qfalse || b == Qnil) ? False : True;

  atom = XInternAtom(display, name, bool);
  raise_if_xerror_occurred();

  return atom == None ? Qnil : ULONG2NUM((unsigned long) atom);
}

.x_list_properties(display_obj, w_obj) ⇒ Object



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'ext/active_window_x/xlib.c', line 247

VALUE xlib_x_list_properties(VALUE self, VALUE display_obj, VALUE w_obj) {
  Display *display;
  Window w;
  int num_prop_return;
  Atom *result;
  int i;
  VALUE ary;

  GetDisplay(display_obj, display);
  w = (Window) NUM2ULONG(w_obj);

  result = XListProperties(display, w, &num_prop_return);
  raise_if_xerror_occurred();
  if (result == NULL) {
    ary = Qnil;
  }else{
    ary = rb_ary_new2(num_prop_return);
    for(i=0; i<num_prop_return; i++){
      rb_ary_push(ary, result[i] == None ? Qnil : ULONG2NUM(result[i]));
    }
    XFree(result);
  }

  return ary;
}

.x_next_event(display_obj) ⇒ Object



324
325
326
327
328
329
330
331
332
333
334
# File 'ext/active_window_x/xlib.c', line 324

VALUE xlib_x_next_event(VALUE self, VALUE display_obj) {
  Display *display;
  XEvent *event_return;

  GetDisplay(display_obj, display);
  event_return = ALLOC(XEvent);

  XNextEvent(display, event_return);

  return x_event_new(event_return);
}

.x_open_display(name_obj) ⇒ Object

XOpenDisplay



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'ext/active_window_x/xlib.c', line 49

VALUE xlib_x_open_display(VALUE self, VALUE name_obj) {
  const char* name;
  Display* d;
  if (TYPE(name_obj) == T_NIL){
    name = NULL;
  }else{
    name = (const char*) StringValuePtr(name_obj);
  }
  d = XOpenDisplay(name);

  if (d == NULL) {
    rb_raise(unknown_display_name_class, "invalid name: %s", name);
    return Qnil;
  }
  return Data_Wrap_Struct(display_class, 0, 0, d);
}

.x_pending(display_obj) ⇒ Object



336
337
338
339
340
# File 'ext/active_window_x/xlib.c', line 336

VALUE xlib_x_pending(VALUE self, VALUE display_obj) {
  Display *display;
  GetDisplay(display_obj, display);
  return INT2FIX(XPending(display));
}

.x_query_tree(d, w) ⇒ Object

XQueryTree



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'ext/active_window_x/xlib.c', line 95

VALUE xlib_x_query_tree(VALUE self, VALUE d, VALUE w){
  Display* display;
  Window window;
  Window root;
  Window parent;
  Window* children;
  unsigned int nchildren, i;
  VALUE arr_obj, children_obj;

  GetDisplay(d, display);
  window = NUM2ULONG(w);

  i = XQueryTree(display, window, &root, &parent, &children, &nchildren);
  raise_if_xerror_occurred();
  if(i == 0) rb_raise(rb_eRuntimeError, "XQueryTree fail");

  children_obj = rb_ary_new2(nchildren);
  for(i=0; i < nchildren; i++){
    rb_ary_push(children_obj, ULONG2NUM((unsigned long) children[i]));
  }

  arr_obj = rb_ary_new2(3L);
  rb_ary_push(arr_obj, root == None ? Qnil : ULONG2NUM((unsigned long) root));
  rb_ary_push(arr_obj, parent == None ? Qnil : ULONG2NUM((unsigned long) parent));
  rb_ary_push(arr_obj, children_obj);

  if(children != NULL) XFree(children);

  return arr_obj;
}

.x_select_input(display_obj, w_obj, event_mask_obj) ⇒ Object



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'ext/active_window_x/xlib.c', line 273

VALUE xlib_x_select_input(VALUE self, VALUE display_obj, VALUE w_obj, VALUE event_mask_obj){
  Display *display;
  Window w;
  long event_mask;
  int result;

  GetDisplay(display_obj, display);
  w = (Window) NUM2ULONG(w_obj);
  event_mask = NUM2LONG(event_mask_obj);

  result = XSelectInput(display, w, event_mask);
  raise_if_xerror_occurred();

  return INT2NUM(result);
}

.x_set_wm_protocols(display_obj, w_obj, atom_ary_obj) ⇒ Object



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'ext/active_window_x/xlib.c', line 342

VALUE xlib_x_set_wm_protocols(VALUE self, VALUE display_obj, VALUE w_obj,
                              VALUE atom_ary_obj) {
  Display *display;
  Window w;
  Atom *atom_ary;
  int count, s, i;

  GetDisplay(display_obj, display);
  count = RARRAY_LEN(atom_ary_obj);
  atom_ary = ALLOC_N(Atom, count);
  for (i=0; i<count; i++)
    atom_ary[i] = RARRAY_PTR(atom_ary_obj)[i];

  w = (Window) NUM2ULONG(w_obj);

  s = XSetWMProtocols(display, w, atom_ary, count);
  raise_if_xerror_occurred();
  if (s != Success) rb_raise(rb_eRuntimeError, "XSetWMProtocols faild");

  return INT2FIX(s);
}