1 #include "clientwrap.h"
8 /***************************************************************************
10 Define the type 'ClientWrap'
12 ***************************************************************************/
14 #define IS_CWRAP(v) ((v)->ob_type == &ClientWrapType)
15 #define IS_VALID_CWRAP(v) ((v)->client != NULL)
16 #define CHECK_CWRAP(self, funcname) { \
17 if (!IS_CWRAP(self)) { \
18 PyErr_SetString(PyExc_TypeError, \
19 "descriptor '" funcname "' requires a 'Client' " \
23 if (!IS_VALID_CWRAP(self)) { \
24 PyErr_SetString(PyExc_ValueError, \
25 "This 'Client' is wrapping a client which no longer "\
32 staticforward PyTypeObject ClientWrapType
;
34 /***************************************************************************
38 ***************************************************************************/
40 static PyObject
*cwrap_window(ClientWrap
*self
, PyObject
*args
)
42 CHECK_CWRAP(self
, "window");
43 if (!PyArg_ParseTuple(args
, ":window"))
45 return PyInt_FromLong(self
->client
->window
);
48 static PyObject
*cwrap_group(ClientWrap
*self
, PyObject
*args
)
50 CHECK_CWRAP(self
, "group");
51 if (!PyArg_ParseTuple(args
, ":group"))
53 return PyInt_FromLong(self
->client
->group
);
56 static PyObject
*cwrap_parent(ClientWrap
*self
, PyObject
*args
)
58 CHECK_CWRAP(self
, "parent");
59 if (!PyArg_ParseTuple(args
, ":parent"))
61 if (self
->client
->transient_for
!= NULL
)
62 return clientwrap_new(self
->client
->transient_for
);
67 static PyObject
*cwrap_children(ClientWrap
*self
, PyObject
*args
)
73 CHECK_CWRAP(self
, "children");
74 if (!PyArg_ParseTuple(args
, ":children"))
76 s
= g_slist_length(self
->client
->transients
);
78 for (i
= 0, it
= self
->client
->transients
; i
< s
; ++i
, it
= it
->next
)
79 PyList_SET_ITEM(list
, i
, clientwrap_new(it
->data
));
83 static PyObject
*cwrap_desktop(ClientWrap
*self
, PyObject
*args
)
85 CHECK_CWRAP(self
, "desktop");
86 if (!PyArg_ParseTuple(args
, ":desktop"))
88 return PyInt_FromLong(self
->client
->desktop
);
91 static PyObject
*cwrap_title(ClientWrap
*self
, PyObject
*args
)
93 CHECK_CWRAP(self
, "title");
94 if (!PyArg_ParseTuple(args
, ":title"))
96 return PyString_FromString(self
->client
->title
);
99 static PyObject
*cwrap_iconTitle(ClientWrap
*self
, PyObject
*args
)
101 CHECK_CWRAP(self
, "iconTitle");
102 if (!PyArg_ParseTuple(args
, ":iconTitle"))
104 return PyString_FromString(self
->client
->icon_title
);
107 static PyObject
*cwrap_resName(ClientWrap
*self
, PyObject
*args
)
109 CHECK_CWRAP(self
, "resName");
110 if (!PyArg_ParseTuple(args
, ":resName"))
112 return PyString_FromString(self
->client
->res_name
);
115 static PyObject
*cwrap_resClass(ClientWrap
*self
, PyObject
*args
)
117 CHECK_CWRAP(self
, "resClass");
118 if (!PyArg_ParseTuple(args
, ":resClass"))
120 return PyString_FromString(self
->client
->res_class
);
123 static PyObject
*cwrap_role(ClientWrap
*self
, PyObject
*args
)
125 CHECK_CWRAP(self
, "role");
126 if (!PyArg_ParseTuple(args
, ":role"))
128 return PyString_FromString(self
->client
->role
);
131 static PyObject
*cwrap_type(ClientWrap
*self
, PyObject
*args
)
133 CHECK_CWRAP(self
, "type");
134 if (!PyArg_ParseTuple(args
, ":type"))
136 return PyInt_FromLong(self
->client
->type
);
139 static PyObject
*cwrap_area(ClientWrap
*self
, PyObject
*args
)
143 CHECK_CWRAP(self
, "area");
144 if (!PyArg_ParseTuple(args
, ":area"))
146 tuple
= PyTuple_New(4);
147 PyTuple_SET_ITEM(tuple
, 0, PyInt_FromLong(self
->client
->area
.x
));
148 PyTuple_SET_ITEM(tuple
, 1, PyInt_FromLong(self
->client
->area
.y
));
149 PyTuple_SET_ITEM(tuple
, 2, PyInt_FromLong(self
->client
->area
.width
));
150 PyTuple_SET_ITEM(tuple
, 3, PyInt_FromLong(self
->client
->area
.height
));
154 static PyObject
*cwrap_screenArea(ClientWrap
*self
, PyObject
*args
)
158 CHECK_CWRAP(self
, "screenArea");
159 if (!PyArg_ParseTuple(args
, ":screenArea"))
161 tuple
= PyTuple_New(4);
162 PyTuple_SET_ITEM(tuple
, 0, PyInt_FromLong(self
->client
->frame
->area
.x
));
163 PyTuple_SET_ITEM(tuple
, 1, PyInt_FromLong(self
->client
->frame
->area
.y
));
164 PyTuple_SET_ITEM(tuple
, 2,
165 PyInt_FromLong(self
->client
->frame
->area
.width
));
166 PyTuple_SET_ITEM(tuple
, 3,
167 PyInt_FromLong(self
->client
->frame
->area
.height
));
171 static PyObject
*cwrap_strut(ClientWrap
*self
, PyObject
*args
)
175 CHECK_CWRAP(self
, "strut");
176 if (!PyArg_ParseTuple(args
, ":strut"))
178 tuple
= PyTuple_New(4);
179 PyTuple_SET_ITEM(tuple
, 0, PyInt_FromLong(self
->client
->strut
.left
));
180 PyTuple_SET_ITEM(tuple
, 1, PyInt_FromLong(self
->client
->strut
.top
));
181 PyTuple_SET_ITEM(tuple
, 2, PyInt_FromLong(self
->client
->strut
.right
));
182 PyTuple_SET_ITEM(tuple
, 3, PyInt_FromLong(self
->client
->strut
.bottom
));
186 static PyObject
*cwrap_logicalSize(ClientWrap
*self
, PyObject
*args
)
190 CHECK_CWRAP(self
, "logicalSize");
191 if (!PyArg_ParseTuple(args
, ":logicalSize"))
193 tuple
= PyTuple_New(2);
194 PyTuple_SET_ITEM(tuple
, 0,
195 PyInt_FromLong(self
->client
->logical_size
.width
));
196 PyTuple_SET_ITEM(tuple
, 1,
197 PyInt_FromLong(self
->client
->logical_size
.height
));
201 static PyObject
*cwrap_minRatio(ClientWrap
*self
, PyObject
*args
)
203 CHECK_CWRAP(self
, "minRatio");
204 if (!PyArg_ParseTuple(args
, ":minRatio"))
206 return PyFloat_FromDouble(self
->client
->min_ratio
);
209 static PyObject
*cwrap_maxRatio(ClientWrap
*self
, PyObject
*args
)
211 CHECK_CWRAP(self
, "maxRatio");
212 if (!PyArg_ParseTuple(args
, ":maxRatio"))
214 return PyFloat_FromDouble(self
->client
->max_ratio
);
217 static PyObject
*cwrap_minSize(ClientWrap
*self
, PyObject
*args
)
221 CHECK_CWRAP(self
, "minSize");
222 if (!PyArg_ParseTuple(args
, ":minSize"))
224 tuple
= PyTuple_New(2);
225 PyTuple_SET_ITEM(tuple
, 0, PyInt_FromLong(self
->client
->min_size
.width
));
226 PyTuple_SET_ITEM(tuple
, 1, PyInt_FromLong(self
->client
->min_size
.height
));
230 static PyObject
*cwrap_maxSize(ClientWrap
*self
, PyObject
*args
)
234 CHECK_CWRAP(self
, "maxSize");
235 if (!PyArg_ParseTuple(args
, ":maxSize"))
237 tuple
= PyTuple_New(2);
238 PyTuple_SET_ITEM(tuple
, 0, PyInt_FromLong(self
->client
->max_size
.width
));
239 PyTuple_SET_ITEM(tuple
, 1, PyInt_FromLong(self
->client
->max_size
.height
));
243 static PyObject
*cwrap_sizeIncrement(ClientWrap
*self
, PyObject
*args
)
247 CHECK_CWRAP(self
, "sizeIncrement");
248 if (!PyArg_ParseTuple(args
, ":sizeIncrement"))
250 tuple
= PyTuple_New(2);
251 PyTuple_SET_ITEM(tuple
, 0, PyInt_FromLong(self
->client
->size_inc
.width
));
252 PyTuple_SET_ITEM(tuple
, 1, PyInt_FromLong(self
->client
->size_inc
.height
));
256 static PyObject
*cwrap_baseSize(ClientWrap
*self
, PyObject
*args
)
260 CHECK_CWRAP(self
, "baseSize");
261 if (!PyArg_ParseTuple(args
, ":baseSize"))
263 tuple
= PyTuple_New(2);
264 PyTuple_SET_ITEM(tuple
, 0, PyInt_FromLong(self
->client
->base_size
.width
));
265 PyTuple_SET_ITEM(tuple
, 1, PyInt_FromLong(self
->client
->base_size
.height
));
269 static PyObject
*cwrap_gravity(ClientWrap
*self
, PyObject
*args
)
271 CHECK_CWRAP(self
, "gravity");
272 if (!PyArg_ParseTuple(args
, ":gravity"))
274 return PyInt_FromLong(self
->client
->gravity
);
277 static PyObject
*cwrap_canClose(ClientWrap
*self
, PyObject
*args
)
279 CHECK_CWRAP(self
, "canClose");
280 if (!PyArg_ParseTuple(args
, ":canClose"))
282 return PyInt_FromLong(self
->client
->delete_window
? 1 : 0);
285 static PyObject
*cwrap_positionRequested(ClientWrap
*self
, PyObject
*args
)
287 CHECK_CWRAP(self
, "positionRequested");
288 if (!PyArg_ParseTuple(args
, ":positionRequested"))
290 return PyInt_FromLong(self
->client
->positioned
? 1 : 0);
293 static PyObject
*cwrap_canFocus(ClientWrap
*self
, PyObject
*args
)
295 CHECK_CWRAP(self
, "canFocus");
296 if (!PyArg_ParseTuple(args
, ":canFocus"))
298 return PyInt_FromLong(self
->client
->can_focus
||
299 self
->client
->focus_notify
);
302 static PyObject
*cwrap_urgent(ClientWrap
*self
, PyObject
*args
)
304 CHECK_CWRAP(self
, "urgent");
305 if (!PyArg_ParseTuple(args
, ":urgent"))
307 return PyInt_FromLong(self
->client
->urgent
? 1 : 0);
310 static PyObject
*cwrap_focused(ClientWrap
*self
, PyObject
*args
)
312 CHECK_CWRAP(self
, "focused");
313 if (!PyArg_ParseTuple(args
, ":focused"))
315 return PyInt_FromLong(self
->client
->focused
? 1 : 0);
318 static PyObject
*cwrap_modal(ClientWrap
*self
, PyObject
*args
)
320 CHECK_CWRAP(self
, "modal");
321 if (!PyArg_ParseTuple(args
, ":modal"))
323 return PyInt_FromLong(self
->client
->modal
? 1 : 0);
326 static PyObject
*cwrap_shaded(ClientWrap
*self
, PyObject
*args
)
328 CHECK_CWRAP(self
, "shaded");
329 if (!PyArg_ParseTuple(args
, ":shaded"))
331 return PyInt_FromLong(self
->client
->shaded
? 1 : 0);
334 static PyObject
*cwrap_iconic(ClientWrap
*self
, PyObject
*args
)
336 CHECK_CWRAP(self
, "iconic");
337 if (!PyArg_ParseTuple(args
, ":iconc"))
339 return PyInt_FromLong(self
->client
->iconic
? 1 : 0);
342 static PyObject
*cwrap_maximizedVertical(ClientWrap
*self
, PyObject
*args
)
344 CHECK_CWRAP(self
, "maximizedVertical");
345 if (!PyArg_ParseTuple(args
, ":maximizedVertical"))
347 return PyInt_FromLong(self
->client
->max_vert
? 1 : 0);
350 static PyObject
*cwrap_maximizedHorizontal(ClientWrap
*self
, PyObject
*args
)
352 CHECK_CWRAP(self
, "maximizedHorizontal");
353 if (!PyArg_ParseTuple(args
, ":maximizedHorizontal"))
355 return PyInt_FromLong(self
->client
->max_horz
? 1 : 0);
358 static PyObject
*cwrap_skipPager(ClientWrap
*self
, PyObject
*args
)
360 CHECK_CWRAP(self
, "skipPager");
361 if (!PyArg_ParseTuple(args
, ":skipPager"))
363 return PyInt_FromLong(self
->client
->skip_pager
? 1 : 0);
366 static PyObject
*cwrap_skipTaskbar(ClientWrap
*self
, PyObject
*args
)
368 CHECK_CWRAP(self
, "skipTaskbar");
369 if (!PyArg_ParseTuple(args
, ":skipTaskbar"))
371 return PyInt_FromLong(self
->client
->skip_taskbar
? 1 : 0);
374 static PyObject
*cwrap_fullscreen(ClientWrap
*self
, PyObject
*args
)
376 CHECK_CWRAP(self
, "fullscreen");
377 if (!PyArg_ParseTuple(args
, ":fullscreen"))
379 return PyInt_FromLong(self
->client
->fullscreen
? 1 : 0);
382 static PyObject
*cwrap_above(ClientWrap
*self
, PyObject
*args
)
384 CHECK_CWRAP(self
, "above");
385 if (!PyArg_ParseTuple(args
, ":above"))
387 return PyInt_FromLong(self
->client
->above
? 1 : 0);
390 static PyObject
*cwrap_below(ClientWrap
*self
, PyObject
*args
)
392 CHECK_CWRAP(self
, "below");
393 if (!PyArg_ParseTuple(args
, ":below"))
395 return PyInt_FromLong(self
->client
->below
? 1 : 0);
398 static PyObject
*cwrap_layer(ClientWrap
*self
, PyObject
*args
)
400 CHECK_CWRAP(self
, "layer");
401 if (!PyArg_ParseTuple(args
, ":layer"))
403 return PyInt_FromLong(self
->client
->layer
);
406 static PyObject
*cwrap_decorations(ClientWrap
*self
, PyObject
*args
)
408 CHECK_CWRAP(self
, "decorations");
409 if (!PyArg_ParseTuple(args
, ":decorations"))
411 return PyInt_FromLong(self
->client
->decorations
);
414 static PyObject
*cwrap_disabledDecorations(ClientWrap
*self
, PyObject
*args
)
416 CHECK_CWRAP(self
, "disabledDecorations");
417 if (!PyArg_ParseTuple(args
, ":disabledDecorations"))
419 return PyInt_FromLong(self
->client
->disabled_decorations
);
422 static PyObject
*cwrap_functions(ClientWrap
*self
, PyObject
*args
)
424 CHECK_CWRAP(self
, "functions");
425 if (!PyArg_ParseTuple(args
, ":functions"))
427 return PyInt_FromLong(self
->client
->functions
);
430 static PyObject
*cwrap_visible(ClientWrap
*self
, PyObject
*args
)
432 CHECK_CWRAP(self
, "visible");
433 if (!PyArg_ParseTuple(args
, ":visible"))
435 return PyInt_FromLong(self
->client
->frame
->visible
? 1 : 0);
438 static PyObject
*cwrap_decorationSize(ClientWrap
*self
, PyObject
*args
)
442 CHECK_CWRAP(self
, "decorationSize");
443 if (!PyArg_ParseTuple(args
, ":decorationSize"))
445 tuple
= PyTuple_New(4);
446 PyTuple_SET_ITEM(tuple
, 0, PyInt_FromLong(self
->client
->frame
->size
.left
));
447 PyTuple_SET_ITEM(tuple
, 1, PyInt_FromLong(self
->client
->frame
->size
.top
));
448 PyTuple_SET_ITEM(tuple
, 2,
449 PyInt_FromLong(self
->client
->frame
->size
.right
));
450 PyTuple_SET_ITEM(tuple
, 3,
451 PyInt_FromLong(self
->client
->frame
->size
.bottom
));
455 static PyObject
*cwrap_normal(ClientWrap
*self
, PyObject
*args
)
457 CHECK_CWRAP(self
, "normal");
458 if (!PyArg_ParseTuple(args
, ":normal"))
460 return PyInt_FromLong(client_normal(self
->client
) ? 1 : 0);
463 static PyObject
*cwrap_setVisible(ClientWrap
*self
, PyObject
*args
)
467 CHECK_CWRAP(self
, "setVisible");
468 if (!PyArg_ParseTuple(args
, "i:setVisible", &i
))
471 frame_show(self
->client
->frame
);
473 frame_hide(self
->client
->frame
);
478 static PyObject
*cwrap_raiseWindow(ClientWrap
*self
, PyObject
*args
)
480 CHECK_CWRAP(self
, "raiseWindow");
481 if (!PyArg_ParseTuple(args
, ":raiseWindow"))
483 stacking_raise(self
->client
);
488 static PyObject
*cwrap_lowerWindow(ClientWrap
*self
, PyObject
*args
)
490 CHECK_CWRAP(self
, "lowerWindow");
491 if (!PyArg_ParseTuple(args
, ":lowerWindow"))
493 stacking_lower(self
->client
);
498 static PyObject
*cwrap_focus(ClientWrap
*self
, PyObject
*args
)
500 CHECK_CWRAP(self
, "focus");
501 if (!PyArg_ParseTuple(args
, ":focus"))
503 return PyInt_FromLong(client_focus(self
->client
) ? 1 : 0);
506 static PyObject
*cwrap_unfocus(ClientWrap
*self
, PyObject
*args
)
508 CHECK_CWRAP(self
, "unfocus");
509 if (!PyArg_ParseTuple(args
, ":unfocus"))
511 client_unfocus(self
->client
);
516 static PyObject
*cwrap_move(ClientWrap
*self
, PyObject
*args
)
520 CHECK_CWRAP(self
, "move");
521 if (!PyArg_ParseTuple(args
, "ii|i:unfocus", &x
, &y
, &final
))
523 /* get the client's position based on x,y for the frame */
524 frame_frame_gravity(self
->client
->frame
, &x
, &y
);
526 client_configure(self
->client
, Corner_TopLeft
, x
, y
,
527 self
->client
->area
.width
, self
->client
->area
.height
,
533 #define ATTRMETH(n, d) {#n, (PyCFunction)cwrap_##n, METH_VARARGS, #d}
535 static PyMethodDef ClientWrapMethods
[] = {
537 "c.window() -- Returns the window id for the Client."),
539 "c.group() -- Returns the group id for the Client."),
541 "c.parent() -- Returns the parent Client for the Client, or the "
542 "Client for which this Client is a transient. Returns None if it "
543 "is not a transient."),
545 "c.parent() -- Returns a list of child Clients for the Client, "
546 "or the Clients transients."),
548 "c.desktop() -- Returns the desktop on which the Client resides, "
549 "or 0xffffffff for 'all desktops'."),
551 "c.title() -- Returns the Client's title string. This is in "
554 "c.iconTitle() -- Returns the Client's icon title string. This "
555 "is in UTF-8 encoding."),
557 "c.resName() -- Returns the application's specified resource "
560 "c.resClass() -- Returns the application's specified resource "
563 "c.role() -- Returns the window's role, which should be unique "
564 "for every window of an application, if it is not empty."),
566 "c.type() -- Returns the window's type, one of the ob.Type_ "
567 "constants. This is the logical type of the window."),
569 "c.area() -- Returns the area rectangle for the Client in a "
570 "tuple. The tuple's format is (x, y, width, height). This is "
571 "not the area on-screen that the Client and frame occupies, but "
572 "rather, the position and size that the Client has requested, "
573 "before its gravity() and decorations have been applied. You "
574 "should use the c.screenArea() to get the actual on-screen area "
577 "c.screenArea() -- Returns the on-screen area rectangle for the "
578 "Client in a tuple. The tuple's format is (x, y, width, height). "
579 "This is the actual position and size of the Client plus its "
582 "c.strut() -- Returns the strut requested by the Client in a "
583 "tuple. The format of the tuple is (left, top, right, bottom)."),
584 ATTRMETH(logicalSize
,
585 "c.logicalSize() -- Returns the logical size of the Client. This "
586 "is the 'user friendly' size for the Client, such as for an "
587 "xterm, it will be the number of characters in the xterm "
588 "instead of the number of pixels it takes up."),
590 "c.minRatio() -- Returns the minimum width:height ratio for "
591 "the Client. A value of 0 implies no ratio enforcement."),
593 "c.maxRatio() -- Returns the maximum width:height ratio for "
594 "the Client. A value of 0 implies no ratio enforcement."),
596 "c.minSize() -- Returns the minimum size of the Client."),
598 "c.maxSize() -- Returns the maximum size of the Client."),
599 ATTRMETH(sizeIncrement
,
600 "c.sizeIncrement() -- Returns the size increments in which the "
601 "Client must be resized."),
603 "c.baseSize() -- Returns the base size of the Client, which is "
604 "subtracted from the Client's size before comparing to its "
605 "various sizing constraints."),
607 "c.gravity() -- Returns the gravity for the Client. One of the "
608 "ob.Gravity_ constants."),
610 "c.canClose() -- Returns whether or not the Client provides a "
611 "means for Openbox to request that it close."),
612 ATTRMETH(positionRequested
,
613 "c.positionRequested() -- Returns whether or not the Client has "
614 "requested a specified position on screen. When it has it should "
615 "probably not be placed using an algorithm when it is managed."),
617 "c.canFocus() -- Returns whether or not the Client can be "
618 "given input focus."),
620 "c.urgent() -- Returns the urgent state of the window (on/off)."),
622 "c.focused() -- Returns whether or not the Client has the input "
625 "c.modal() -- Returns whether or not the Client is modal. A "
626 "modal Client implies that it needs to be closed before its "
627 "parent() can be used (focsed) again."),
629 "c.shaded() -- Returns whether or not the Client is shaded. "
630 "Shaded clients are hidden except for their titlebar."),
632 "c.iconic() -- Returns whether or not the Client is iconic. "
633 "Iconic windows are represented only by icons, or possibly "
635 ATTRMETH(maximizedVertical
,
636 "c.maximizedVertical() -- Returns whether or not the Client is "
637 "maxized vertically. When a Client is maximized it will expand "
638 "to fill as much of the screen as it can in that direction."),
639 ATTRMETH(maximizedHorizontal
,
640 "c.maximizedHorizontal() -- Returns whether or not the Client is "
641 "maxized horizontally. When a Client is maximized it will expand "
642 "to fill as much of the screen as it can in that direction."),
644 "c.skipPager() -- Returns whether the Client as requested to be "
645 "skipped by pagers."),
646 ATTRMETH(skipTaskbar
,
647 "c.skipTaskbar() -- Returns whether the Client as requested to "
648 "be skipped by taskbars."),
650 "c.fullscreen() -- Returns whether the Client is in fullscreen "
653 "c.above() -- Returns whether the Client should be stacked above "
654 "other windows of the same type."),
656 "c.below() -- Returns whether the Client should be stacked below "
657 "other windows of the same type."),
659 "c.layer() -- Returns the layer in which the window should be "
660 "stacked. This is one of the ob.Layer_ constants. Windows in "
661 "layers with higher values should be kept above windows in lower "
663 ATTRMETH(decorations
,
664 "c.decorations() -- Returns a mask of decorations which the "
665 "Client will be given. It is made up of the ob.Decor_ constants. "
666 "These can be turned off with the "
667 " disabledDecorations()."),
668 ATTRMETH(disabledDecorations
,
669 "c.disabledDecorations() -- returns a mask of decorations which "
670 "are disabled on the Client. This is made up of the ob.Decor_ "
673 "ob.functions() -- Returns the list of functionality for the "
674 "Client, in a mask made up of the ob.Func_ constants."),
676 "ob.visible() -- Returns if the client is currently visible "
678 ATTRMETH(decorationSize
,
679 "c.decorationSize() -- Returns the size of the Client's "
680 "decorations around the Client window, in a tuple. The format of "
681 "the tuple is (left, top, right, bottom)."),
683 "c.normal() -- Returns if the window should be treated as a "
684 "normal window. Some windows (desktops, docks, splash screens) "
685 "should have special rules applied to them in a number of "
686 "places regarding focus or user interaction."),
688 "c.setVisible(show) -- Shows or hides the Client."),
689 ATTRMETH(raiseWindow
,
690 "c.raiseWindow() -- Raises the Client to the top of its layer."),
691 ATTRMETH(lowerWindow
,
692 "c.lowerWindow() -- Lowers the Client to the bottom of its "
695 "c.focus() -- Focuses the Client. Returns 1 if the Client will "
696 "be focused, or 0 if it will not."),
698 "c.unfocus() -- Unfocuses the Client, leaving nothing focused."),
700 "c.move(x, y) -- Moves the Client to the specified position. The "
701 "top left corner of the Client's decorations is positioned at "
703 { NULL
, NULL
, 0, NULL
}
706 /***************************************************************************
710 ***************************************************************************/
712 /*static PyObject *cwrap_getattr(ClientWrap *self, char *name)
714 CHECK_CWRAP(self, "getattr");
715 return Py_FindMethod(ClientWrapAttributeMethods, (PyObject*)self, name);
718 static void cwrap_dealloc(ClientWrap
*self
)
720 if (self
->client
!= NULL
)
721 self
->client
->wrap
= NULL
;
722 PyObject_Del((PyObject
*) self
);
725 static PyObject
*cwrap_repr(ClientWrap
*self
)
727 CHECK_CWRAP(self
, "repr");
728 return PyString_FromFormat("0x%x", (guint
)self
->client
->window
);
731 static int cwrap_compare(ClientWrap
*self
, ClientWrap
*other
)
734 if (!IS_VALID_CWRAP(self
)) {
735 PyErr_SetString(PyExc_ValueError
,
736 "This 'Client' is wrapping a client which no longer "
740 w1
= self
->client
->window
;
741 w2
= self
->client
->window
;
742 return w1
> w2
? 1 : w1
< w2
? -1 : 0;
745 static PyTypeObject ClientWrapType
= {
746 PyObject_HEAD_INIT(NULL
)
751 (destructor
) cwrap_dealloc
, /*tp_dealloc*/
755 (cmpfunc
) cwrap_compare
, /*tp_compare*/
756 (reprfunc
) cwrap_repr
, /*tp_repr*/
758 0, /*tp_as_sequence*/
763 /***************************************************************************
767 ***************************************************************************/
769 void clientwrap_startup()
771 ClientWrapType
.ob_type
= &PyType_Type
;
772 ClientWrapType
.tp_methods
= ClientWrapMethods
;
773 PyType_Ready(&ClientWrapType
);
776 void clientwrap_shutdown()
780 PyObject
*clientwrap_new(Client
*client
)
782 g_assert(client
!= NULL
);
784 if (client
->wrap
!= NULL
) {
785 /* already has a wrapper! */
786 Py_INCREF((PyObject
*) client
->wrap
);
788 client
->wrap
= PyObject_New(ClientWrap
, &ClientWrapType
);
789 client
->wrap
->client
= client
;
791 return (PyObject
*) client
->wrap
;