#define PLATE_EVENTMASK (SubstructureRedirectMask | ButtonPressMask)
#define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask)
+#define ELEMENT_EVENTMASK (ButtonPressMask | ButtonReleaseMask | \
+ ButtonMotionMask | ExposureMask | \
+ EnterWindowMask | LeaveWindowMask)
/* style settings - geometry */
int s_bevel;
self->frame.plate = createWindow(self->frame.window, mask, &attrib);
mask = CWEventMask;
- attrib.event_mask = (ButtonPressMask | ButtonReleaseMask |
- ButtonMotionMask | ExposureMask);
+ attrib.event_mask = ELEMENT_EVENTMASK;
self->title = createWindow(self->frame.window, mask, &attrib);
self->label = createWindow(self->title, mask, &attrib);
self->max = createWindow(self->title, mask, &attrib);
static void render(ObFrame *self)
{
- if (self->frame.client->focused) {
+ if (client_focused(self->frame.client)) {
XSetWindowBorder(ob_display, self->frame.plate,
s_cb_focused_color->pixel);
} else {
}
if (self->frame.client->decorations & Decor_Titlebar) {
- paint(self->title, (self->frame.client->focused ?
+ paint(self->title, (client_focused(self->frame.client) ?
self->a_focused_title :
self->a_unfocused_title),
0, 0, self->width, TITLE_HEIGHT);
}
if (self->frame.client->decorations & Decor_Handle) {
- paint(self->handle, (self->frame.client->focused ?
+ paint(self->handle, (client_focused(self->frame.client) ?
self->a_focused_handle :
self->a_unfocused_handle),
GRIP_WIDTH + self->bwidth, 0,
HANDLE_WIDTH(self), s_handle_height);
- paint(self->lgrip, (self->frame.client->focused ?
+ paint(self->lgrip, (client_focused(self->frame.client) ?
a_focused_grip :
a_unfocused_grip),
0, 0, GRIP_WIDTH, s_handle_height);
- paint(self->rgrip, (self->frame.client->focused ?
+ paint(self->rgrip, (client_focused(self->frame.client) ?
a_focused_grip :
a_unfocused_grip),
0, 0, GRIP_WIDTH, s_handle_height);
if (self->label_x < 0) return;
- a = (self->frame.client->focused ?
+ a = (client_focused(self->frame.client) ?
self->a_focused_label : self->a_unfocused_label);
/* set the texture's text! */
if (self->max_x < 0) return;
- paint(self->max, (self->frame.client->focused ?
+ paint(self->max, (client_focused(self->frame.client) ?
(press ?
a_focused_pressed_max :
a_focused_unpressed_max) :
{
if (self->iconify_x < 0) return;
- paint(self->iconify, (self->frame.client->focused ?
+ paint(self->iconify, (client_focused(self->frame.client) ?
(self->iconify_press ?
a_focused_pressed_iconify :
a_focused_unpressed_iconify) :
if (self->desk_x < 0) return;
- paint(self->desk, (self->frame.client->focused ?
+ paint(self->desk, (client_focused(self->frame.client) ?
(press ?
a_focused_pressed_desk :
a_focused_unpressed_desk) :
{
if (self->close_x < 0) return;
- paint(self->close, (self->frame.client->focused ?
+ paint(self->close, (client_focused(self->frame.client) ?
(self->close_press ?
a_focused_pressed_close :
a_focused_unpressed_close) :
/* unfocus the client (dispatchs the focus event) (we're out of the
transient lists already, so being modal doesn't matter) */
- if (client->focused)
+ if (client_focused(client))
client_unfocus(client);
if (ob_state != State_Exiting) {
self->title = self->icon_title = NULL;
self->res_name = self->res_class = self->role = NULL;
self->wmstate = NormalState;
- self->focused = FALSE;
self->transient = FALSE;
self->transients = NULL;
self->transient_for = NULL;
Client *c = it->data;
if (c == skip) continue; /* circular? */
if ((ret = search_focus_tree(c, skip))) return ret;
- if (c->focused) return c;
+ if (client_focused(c)) return c;
}
return NULL;
}
return FALSE;
}
}
+
+ if (client_focused(self))
+ return TRUE;
+
+ g_print("Focusing: %lx\n", self->window);
if (self->can_focus)
XSetInputFocus(ob_display, self->window, RevertToNone, CurrentTime);
XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
}
- /*XSync(ob_display, FALSE); XXX Why sync? */
+ /* XSync(ob_display, FALSE); XXX Why sync? */
return TRUE;
}
void client_unfocus(Client *self)
{
g_assert(focus_client == self);
+ g_print("UNFocusing: %lx\n", self->window);
focus_set_client(NULL);
}
+
+gboolean client_focused(Client *self)
+{
+ return self == focus_client;
+}
static void events(ObEvent *e, void *foo)
{
+ g_message("event %d", e->type);
switch (e->type) {
case Event_Client_Mapped:
if (focus_new && client_normal(e->data.c.client))
case Event_Client_Unmapped:
if (ob_state == State_Exiting) break;
- if (e->data.c.client->focused)
+ if (client_focused(e->data.c.client))
if (!follow_mouse || !focus_under_pointer())
focus_fallback(FALSE);
break;
--skip_enter;
}
else*/
- if (e->data.x.client != NULL && client_normal(e->data.x.client))
+ if (e->data.x.client != NULL && client_normal(e->data.x.client)) {
client_focus(e->data.x.client);
+ g_message("enter %lx", e->data.x.client->window);
+ }
break;
default: