Class: X11::WindowManager
- Inherits:
-
Object
- Object
- X11::WindowManager
- Defined in:
- lib/ruby-x11.rb,
ext/x11_wrap.c
Defined Under Namespace
Classes: Client
Instance Method Summary collapse
- #clients ⇒ Object
- #debug_event_loop ⇒ Object
- #event_pop ⇒ Object
- #get_event ⇒ Object
- #get_grab_key(r_keysym, r_mods) ⇒ Object
- #get_ungrab_key(r_keysym, r_mods) ⇒ Object
- #manage(r_client, x, y, w, h) ⇒ Object
- #manage_override_redirect_windows ⇒ Object
- #manage_override_redirect_windows=(flag) ⇒ Object
- #next_event ⇒ Object
- #next_event_source ⇒ Object
- #number_of_clients ⇒ Object
- #pending_event_count ⇒ Object
- #query ⇒ Object
- #screenheight ⇒ Object
- #screenwidth ⇒ Object
- #screenxpos ⇒ Object
- #screenypos ⇒ Object
- #selected ⇒ Object
- #windowareaheight ⇒ Object
- #windowareaheight=(newval) ⇒ Object
- #windowareawidth ⇒ Object
- #windowareawidth=(newval) ⇒ Object
- #windowareaxpos ⇒ Object
- #windowareaxpos=(newval) ⇒ Object
- #windowareaypos ⇒ Object
- #windowareaypos=(newval) ⇒ Object
Instance Method Details
#clients ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'ext/x11_wrap.c', line 186
static VALUE wm_clients(VALUE self) {
WM *newwm;
//Client *c;
VALUE obj;
VALUE arr;
int i;
arr = rb_ary_new();
Data_Get_Struct(self, WM, newwm);
for (i=0; i<newwm->clients_num; i++) {
obj = client_make(cClient, &newwm->clients[i]);
rb_ary_push(arr, obj);
}
return arr;
}
|
#debug_event_loop ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/ruby-x11.rb', line 107 def debug_event_loop loop do ev = get_event if ev.type == MapRequest && ev.client manage ev.client,10,10,100,100 end break if ev.keysym == "Escape" puts "#{EVENT_NAMES[ev.type]} #{ev.wid.to_s(16)}:#{ev.client} " \ "keysym=#{ev.keysym} mods=#{ev.mods} button=#{ev.} coord=(#{ev.x},#{ev.y})" end end |
#event_pop ⇒ Object
231 232 233 234 235 236 237 |
# File 'ext/x11_wrap.c', line 231 static VALUE wm_event_pop(VALUE self) { WM *newwm; Data_Get_Struct(self, WM, newwm); event_pop(newwm); return Qnil; } |
#get_event ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'ext/x11_wrap.c', line 287
static VALUE wm_get_event(VALUE self) {
WM* wm;
XEvent* pev;
VALUE r_ev,r_mods,r_keysym;
int i;
Data_Get_Struct(self,WM,wm);
pev = (XEvent*) calloc(1,sizeof(XEvent));
XNextEvent(wm->dpy,pev);
r_ev = event_wrap(cEvent,pev);
switch(pev->type) {
case ButtonPress:
case ButtonRelease:
rb_ivar_set(r_ev, id_client, r_client_for_window(wm,pev->xbutton.window));
rb_ivar_set(r_ev,id_x,INT2NUM(pev->xbutton.x));
rb_ivar_set(r_ev,id_y,INT2NUM(pev->xbutton.y));
break;
case KeyPress:
case KeyRelease:
rb_ivar_set(r_ev, id_client, r_client_for_window(wm,pev->xkey.window));
rb_ivar_set(r_ev,id_keycode,INT2NUM(pev->xkey.keycode));
rb_ivar_set(r_ev,id_state,INT2NUM(pev->xkey.state));
r_keysym = rb_str_new2(XKeysymToString(XLookupKeysym((XKeyEvent*)pev,0)));
r_mods = rb_hash_new();
for (i = 0; i < numKeyMasks; i++) {
if (pev->xkey.state & (1 << i))
rb_hash_aset(r_mods,ID2SYM(id_keymasks[i]),Qtrue);
}
rb_ivar_set(r_ev,id_keysym,r_keysym);
rb_ivar_set(r_ev,id_mods,r_mods);
break;
case ConfigureNotify:
rb_ivar_set(r_ev, id_client, r_client_for_window(wm,pev->xconfigure.window));
break;
case FocusIn:
case FocusOut:
rb_ivar_set(r_ev, id_client, r_client_for_window(wm,pev->xfocus.window));
break;
case EnterNotify:
case LeaveNotify:
rb_ivar_set(r_ev, id_client, r_client_for_window(wm,pev->xcrossing.window));
break;
case CreateNotify:
rb_ivar_set(r_ev, id_client, r_client_for_window(wm,pev->xcreatewindow.window));
break;
case DestroyNotify:
rb_ivar_set(r_ev, id_client, r_client_for_window(wm,pev->xdestroywindow.window));
break;
case MapRequest:
rb_ivar_set(r_ev, id_client, r_client_for_window(wm,pev->xmaprequest.window));
break;
}
return r_ev;
}
|
#get_grab_key(r_keysym, r_mods) ⇒ Object
354 355 356 357 358 359 360 361 362 363 364 |
# File 'ext/x11_wrap.c', line 354
static VALUE wm_grab_key(VALUE self, VALUE r_keysym, VALUE r_mods) {
KeySym keysym = keysym_to_c(r_keysym);
KeyCode keycode;
int mods = keymask_to_c(r_mods);
WM* wm;
Data_Get_Struct(self,WM,wm);
keycode = XKeysymToKeycode(wm->dpy, keysym);
XGrabKey(wm->dpy, keycode, mods, wm->root, True, GrabModeAsync, GrabModeAsync);
return Qnil;
}
|
#get_ungrab_key(r_keysym, r_mods) ⇒ Object
366 367 368 369 370 371 372 373 374 375 376 |
# File 'ext/x11_wrap.c', line 366
static VALUE wm_ungrab_key(VALUE self, VALUE r_keysym, VALUE r_mods) {
KeySym keysym = keysym_to_c(r_keysym);
KeyCode keycode;
int mods = keymask_to_c(r_mods);
WM* wm;
Data_Get_Struct(self,WM,wm);
keycode = XKeysymToKeycode(wm->dpy, keysym);
XUngrabKey(wm->dpy, keycode, mods, wm->root);
return Qnil;
}
|
#manage(r_client, x, y, w, h) ⇒ Object
265 266 267 268 269 270 271 272 273 274 275 |
# File 'ext/x11_wrap.c', line 265
static VALUE wm_manage(VALUE self, VALUE r_client, VALUE x, VALUE y, VALUE w, VALUE h) {
WM* wm = wm_to_c(self);
Client* c = client_to_c(r_client);
XWindowAttributes wa;
wa.x = NUM2INT(x);
wa.y = NUM2INT(y);
wa.width = NUM2INT(w);
wa.height = NUM2INT(h);
manage_client(wm,&wa,c);
return Qtrue;
}
|
#manage_override_redirect_windows ⇒ Object
109 110 111 112 113 |
# File 'ext/x11_wrap.c', line 109
static VALUE wm_manage_override_redirect_windows(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return newwm->manage_override_redirect_windows ? Qtrue : Qfalse;
}
|
#manage_override_redirect_windows=(flag) ⇒ Object
115 116 117 118 119 120 |
# File 'ext/x11_wrap.c', line 115
static VALUE wm_manage_override_redirect_windows_set(VALUE self, VALUE flag) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
newwm->manage_override_redirect_windows = (flag == Qtrue ? 1 : 0);
return newwm->manage_override_redirect_windows ? Qtrue : Qfalse;
}
|
#next_event ⇒ Object
220 221 222 223 224 225 226 227 228 229 |
# File 'ext/x11_wrap.c', line 220
static VALUE wm_event_next_type(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
if (event_next_type(newwm) != NULL)
return rb_str_new2(event_next_type(newwm));
else {
return Qnil;
}
}
|
#next_event_source ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 |
# File 'ext/x11_wrap.c', line 208
static VALUE wm_event_next_source(VALUE self) {
WM *newwm;
int c;
Data_Get_Struct(self, WM, newwm);
c = event_next_source(newwm);
if (c > 0)
return client_make(cClient, &newwm->clients[c]);
else
return Qnil;
}
|
#number_of_clients ⇒ Object
161 162 163 164 165 |
# File 'ext/x11_wrap.c', line 161
static VALUE wm_num_clients(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return INT2NUM(newwm->clients_num);
}
|
#pending_event_count ⇒ Object
202 203 204 205 206 |
# File 'ext/x11_wrap.c', line 202
static VALUE wm_pending_event_count(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return INT2NUM(XPending(newwm->dpy));
}
|
#query ⇒ Object
65 66 67 68 69 70 |
# File 'ext/x11_wrap.c', line 65
static VALUE wm_query(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
newwm->clients = query_clients(newwm);
return Qnil;
}
|
#screenheight ⇒ Object
90 91 92 93 94 |
# File 'ext/x11_wrap.c', line 90
static VALUE wm_sh(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return INT2NUM(newwm->sh);
}
|
#screenwidth ⇒ Object
84 85 86 87 88 |
# File 'ext/x11_wrap.c', line 84
static VALUE wm_sw(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return INT2NUM(newwm->sw);
}
|
#screenxpos ⇒ Object
72 73 74 75 76 |
# File 'ext/x11_wrap.c', line 72
static VALUE wm_sx(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return INT2NUM(newwm->sx);
}
|
#screenypos ⇒ Object
78 79 80 81 82 |
# File 'ext/x11_wrap.c', line 78
static VALUE wm_sy(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return INT2NUM(newwm->sy);
}
|
#selected ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'ext/x11_wrap.c', line 167
static VALUE wm_selected(VALUE self) {
WM *newwm;
XEvent event_return, event_saviour;
int i;
Data_Get_Struct(self, WM, newwm);
// Cycle through focus events and get the most recent
XCheckTypedEvent(newwm->dpy, FocusIn, &event_return);
/*
while (XCheckTypedEvent(newwm->dpy, FocusIn, &event_return))
*/
event_saviour = event_return;
for (i=0; i<newwm->clients_num; i++)
if (&newwm->clients[i].win == &event_saviour.xany.window)
newwm->selected = &newwm->clients[i];
return client_make(cClient, newwm->selected);
}
|
#windowareaheight ⇒ Object
148 149 150 151 152 |
# File 'ext/x11_wrap.c', line 148
static VALUE wm_wah(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return INT2NUM(newwm->wah);
}
|
#windowareaheight=(newval) ⇒ Object
154 155 156 157 158 159 |
# File 'ext/x11_wrap.c', line 154
static VALUE wm_wah_set(VALUE self, VALUE newval) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
newwm->wah = NUM2INT(newval);
return Qnil;
}
|
#windowareawidth ⇒ Object
135 136 137 138 139 |
# File 'ext/x11_wrap.c', line 135
static VALUE wm_waw(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return INT2NUM(newwm->waw);
}
|
#windowareawidth=(newval) ⇒ Object
141 142 143 144 145 146 |
# File 'ext/x11_wrap.c', line 141
static VALUE wm_waw_set(VALUE self, VALUE newval) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
newwm->waw = NUM2INT(newval);
return Qnil;
}
|
#windowareaxpos ⇒ Object
96 97 98 99 100 |
# File 'ext/x11_wrap.c', line 96
static VALUE wm_wax(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return INT2NUM(newwm->wax);
}
|
#windowareaxpos=(newval) ⇒ Object
102 103 104 105 106 107 |
# File 'ext/x11_wrap.c', line 102
static VALUE wm_wax_set(VALUE self, VALUE newval) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
newwm->wax = NUM2INT(newval);
return Qnil;
}
|
#windowareaypos ⇒ Object
122 123 124 125 126 |
# File 'ext/x11_wrap.c', line 122
static VALUE wm_way(VALUE self) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
return INT2NUM(newwm->way);
}
|
#windowareaypos=(newval) ⇒ Object
128 129 130 131 132 133 |
# File 'ext/x11_wrap.c', line 128
static VALUE wm_way_set(VALUE self, VALUE newval) {
WM *newwm;
Data_Get_Struct(self, WM, newwm);
newwm->way = NUM2INT(newval);
return Qnil;
}
|