samuraix.client

class samuraix.client.Client(screen, window, geometry)

A client is managing an X top-level window. samurai-x2 has the concept of windows and actors (see The Client concept)

all_clients
A list of all available Client instances.
window_2_client_map
A weakref.WeakValueDictionary mapping ooxcb.xproto.Window objects to Client instances.
actor
The actor window, as explained in the The Client concept.
window
The foreign top-level window, as explained in the The Client concept.

Events:

on_before_focus(client)
Dispatched in focus() before anything is done.
on_focus(client)
Dispatched in focus() after the client was focused.
on_blur(client)
Dispatched in blur(). The client is not focused anymore.
on_handle_net_wm_state(client, present, atom, source_indication)
Dispatched in msg_wm_state() if a _NET_WM_STATE client message was received. You can implement new handlers for such client messages using this event. present is a bool value - True if the atom is now included in the window’s state, False if it is not.
on_removed(client)
Dispatched when the client’s foreign window was destroyed.
on_updated_geom(client)
Dispatched when the client’s geometry (the geom attribute) was updated.

Members:

actor_on_configure_notify(evt)
Event handler for ooxcb.xproto.ConfigureNotifyEvent: update the geometry
add_net_wm_state(name)
add the atom with the name name to the list of states for _NET_WM_STATE.
apply_normal_hints(hints=None, geom=None)

apply the WM_NORMAL_HINTS (TODO: complete)

Parameters:
  • hints – A SizeHints object or None (fetch it)
  • geom – received geom - will not be modified; if None, use a copy of self.geom
ban(withdrawn=True, hidden=True)

Unmap the actor window and set WM_STATE.

Parameters:
withdrawn: bool

If True, the WM_STATE is set to withdrawn If False, it’s Iconic.

hidden: bool

add _NET_WM_STATE_HIDDEN to the net wm state if True

blur()
Blur / Unfocus the client. Do not call, use Screen.focus.
focus(bring_forward=True)

Focus the client. Do not call that, use Screen.focus instead.

As first, it dispatches the on_before_focus event. Then it grabs the input focus and raises the client window if bring_forward is True. After that, on_focus is dispatched.

classmethod get_by_window(window)
returns the Client instance for the given window or None if there is no client managing window.
get_referrers()

returns a list of all referrers to self, presented by Python’s gc module.

That’s here for debugging using sx-web’s interface.

get_window_title()
returns the window title you should use - or an empty string if it couldn’t be retrieved.
iconify()
same as self.ban(False)
init()
Initialize the actor. Called internally by samuraix.screen.manage() after self.actor is set. That’s not so nice.
install_handlers()

Install all client message handlers.

Note:called internally
is_focused()
returns True if self is its screen’s focused client
kill()
kill the client. If protocols contains WM_DELETE_WINDOW, send such a client message, otherwise, use kill_client.
msg_active_window(evt)

Handler for the _NET_ACTIVE_WINDOW client message.

If the window is banned (WM_STATE is not WMState.Normal), it is unbanned.

If it is called on an unmanaged window, it will not be handled - that’s what we want.

Todo:check if it’s on the correct desktop
msg_change_state(evt)

handler for WM_CHANGE_STATE.

This will iconify(?) me.

msg_wm_state(evt)

handler for _NET_WM_STATE.

That updates self.state and dispatches the ‘on_handle_net_wm_state’ event at least one time (or two, if two atoms were specified)

on_client_message(evt)
Event handler for ooxcb.xproto.ClientMessageEvent. prints a debug message to the logs and calls process_netwm_client_message().
on_destroy_notify(evt)
Event handler for ooxcb.xproto.DestroyNotifyEvent. Prints a debug message and calls remove() if the top-level window was destroyed.
on_handle_net_wm_state(client, present, atom, source_indication)
Default event handler: handles _NET_WM_STATE_HIDDEN!
on_map_notify(evt)
window’s event handler for map notify events
on_property_notify(evt)
Event handler for ooxcb.xproto.PropertyNotifyEvent, just a debug printout at the moment
process_netwm_client_message(evt)
process an EWMH / NETWM client message event.
remove()
Called if the client lost its permission to exist. Sets self.window.valid to False and dispatches the on_removed event.
remove_net_wm_state(name)
remove the atom with the name name from the list of states for _NET_WM_STATE. Catch errors.
resize(geom)
Configure the main window (not the actor) to use width and height from geom.
set_input_focus()
grant the input focus. If protocols contains WM_TAKE_FOCUS, send such a client message, otherwise use set_input_focus.
unban()
Map the actor window.
unmanage()
Remove myself ... called by the screen
update_geom(geom)
geom is the new geometry of the actor(!) window. Dispatches ‘on_updated_geom’.
update_net_wm_state()
ensure that the window’s _NET_WM_STATE property contains the same atoms as self.state.
update_protocols()
get the WM_PROTOCOLS property from the window and update protocols.
user_ban(withdrawn=True)
That does nothing except call ban().
user_unban()
map the actor window, as requested by the user. This will focus the actor.
viewable
is True if the client is on the currently active desktop -> it could be shown.

samurai-x

Previous topic

samuraix.base

Next topic

samuraix.defaultconfig

This Page