rm the focused member from the client struct, it was redundant with the focus_client variable around
This commit is contained in:
parent
ca45916f77
commit
db75d406ce
4 changed files with 36 additions and 20 deletions
|
@ -23,6 +23,9 @@
|
||||||
|
|
||||||
#define PLATE_EVENTMASK (SubstructureRedirectMask | ButtonPressMask)
|
#define PLATE_EVENTMASK (SubstructureRedirectMask | ButtonPressMask)
|
||||||
#define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask)
|
#define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask)
|
||||||
|
#define ELEMENT_EVENTMASK (ButtonPressMask | ButtonReleaseMask | \
|
||||||
|
ButtonMotionMask | ExposureMask | \
|
||||||
|
EnterWindowMask | LeaveWindowMask)
|
||||||
|
|
||||||
/* style settings - geometry */
|
/* style settings - geometry */
|
||||||
int s_bevel;
|
int s_bevel;
|
||||||
|
@ -268,8 +271,7 @@ Frame *frame_new()
|
||||||
self->frame.plate = createWindow(self->frame.window, mask, &attrib);
|
self->frame.plate = createWindow(self->frame.window, mask, &attrib);
|
||||||
|
|
||||||
mask = CWEventMask;
|
mask = CWEventMask;
|
||||||
attrib.event_mask = (ButtonPressMask | ButtonReleaseMask |
|
attrib.event_mask = ELEMENT_EVENTMASK;
|
||||||
ButtonMotionMask | ExposureMask);
|
|
||||||
self->title = createWindow(self->frame.window, mask, &attrib);
|
self->title = createWindow(self->frame.window, mask, &attrib);
|
||||||
self->label = createWindow(self->title, mask, &attrib);
|
self->label = createWindow(self->title, mask, &attrib);
|
||||||
self->max = createWindow(self->title, mask, &attrib);
|
self->max = createWindow(self->title, mask, &attrib);
|
||||||
|
@ -729,7 +731,7 @@ static void layout_title(ObFrame *self)
|
||||||
|
|
||||||
static void render(ObFrame *self)
|
static void render(ObFrame *self)
|
||||||
{
|
{
|
||||||
if (self->frame.client->focused) {
|
if (client_focused(self->frame.client)) {
|
||||||
XSetWindowBorder(ob_display, self->frame.plate,
|
XSetWindowBorder(ob_display, self->frame.plate,
|
||||||
s_cb_focused_color->pixel);
|
s_cb_focused_color->pixel);
|
||||||
} else {
|
} else {
|
||||||
|
@ -738,7 +740,7 @@ static void render(ObFrame *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->frame.client->decorations & Decor_Titlebar) {
|
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_focused_title :
|
||||||
self->a_unfocused_title),
|
self->a_unfocused_title),
|
||||||
0, 0, self->width, TITLE_HEIGHT);
|
0, 0, self->width, TITLE_HEIGHT);
|
||||||
|
@ -751,16 +753,16 @@ static void render(ObFrame *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->frame.client->decorations & Decor_Handle) {
|
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_focused_handle :
|
||||||
self->a_unfocused_handle),
|
self->a_unfocused_handle),
|
||||||
GRIP_WIDTH + self->bwidth, 0,
|
GRIP_WIDTH + self->bwidth, 0,
|
||||||
HANDLE_WIDTH(self), s_handle_height);
|
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_focused_grip :
|
||||||
a_unfocused_grip),
|
a_unfocused_grip),
|
||||||
0, 0, GRIP_WIDTH, s_handle_height);
|
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_focused_grip :
|
||||||
a_unfocused_grip),
|
a_unfocused_grip),
|
||||||
0, 0, GRIP_WIDTH, s_handle_height);
|
0, 0, GRIP_WIDTH, s_handle_height);
|
||||||
|
@ -773,7 +775,7 @@ static void render_label(ObFrame *self)
|
||||||
|
|
||||||
if (self->label_x < 0) return;
|
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);
|
self->a_focused_label : self->a_unfocused_label);
|
||||||
|
|
||||||
/* set the texture's text! */
|
/* set the texture's text! */
|
||||||
|
@ -797,7 +799,7 @@ static void render_max(ObFrame *self)
|
||||||
|
|
||||||
if (self->max_x < 0) return;
|
if (self->max_x < 0) return;
|
||||||
|
|
||||||
paint(self->max, (self->frame.client->focused ?
|
paint(self->max, (client_focused(self->frame.client) ?
|
||||||
(press ?
|
(press ?
|
||||||
a_focused_pressed_max :
|
a_focused_pressed_max :
|
||||||
a_focused_unpressed_max) :
|
a_focused_unpressed_max) :
|
||||||
|
@ -811,7 +813,7 @@ static void render_iconify(ObFrame *self)
|
||||||
{
|
{
|
||||||
if (self->iconify_x < 0) return;
|
if (self->iconify_x < 0) return;
|
||||||
|
|
||||||
paint(self->iconify, (self->frame.client->focused ?
|
paint(self->iconify, (client_focused(self->frame.client) ?
|
||||||
(self->iconify_press ?
|
(self->iconify_press ?
|
||||||
a_focused_pressed_iconify :
|
a_focused_pressed_iconify :
|
||||||
a_focused_unpressed_iconify) :
|
a_focused_unpressed_iconify) :
|
||||||
|
@ -828,7 +830,7 @@ static void render_desk(ObFrame *self)
|
||||||
|
|
||||||
if (self->desk_x < 0) return;
|
if (self->desk_x < 0) return;
|
||||||
|
|
||||||
paint(self->desk, (self->frame.client->focused ?
|
paint(self->desk, (client_focused(self->frame.client) ?
|
||||||
(press ?
|
(press ?
|
||||||
a_focused_pressed_desk :
|
a_focused_pressed_desk :
|
||||||
a_focused_unpressed_desk) :
|
a_focused_unpressed_desk) :
|
||||||
|
@ -842,7 +844,7 @@ static void render_close(ObFrame *self)
|
||||||
{
|
{
|
||||||
if (self->close_x < 0) return;
|
if (self->close_x < 0) return;
|
||||||
|
|
||||||
paint(self->close, (self->frame.client->focused ?
|
paint(self->close, (client_focused(self->frame.client) ?
|
||||||
(self->close_press ?
|
(self->close_press ?
|
||||||
a_focused_pressed_close :
|
a_focused_pressed_close :
|
||||||
a_focused_unpressed_close) :
|
a_focused_unpressed_close) :
|
||||||
|
|
|
@ -276,7 +276,7 @@ void client_unmanage(Client *client)
|
||||||
|
|
||||||
/* unfocus the client (dispatchs the focus event) (we're out of the
|
/* unfocus the client (dispatchs the focus event) (we're out of the
|
||||||
transient lists already, so being modal doesn't matter) */
|
transient lists already, so being modal doesn't matter) */
|
||||||
if (client->focused)
|
if (client_focused(client))
|
||||||
client_unfocus(client);
|
client_unfocus(client);
|
||||||
|
|
||||||
if (ob_state != State_Exiting) {
|
if (ob_state != State_Exiting) {
|
||||||
|
@ -385,7 +385,6 @@ static void client_get_all(Client *self)
|
||||||
self->title = self->icon_title = NULL;
|
self->title = self->icon_title = NULL;
|
||||||
self->res_name = self->res_class = self->role = NULL;
|
self->res_name = self->res_class = self->role = NULL;
|
||||||
self->wmstate = NormalState;
|
self->wmstate = NormalState;
|
||||||
self->focused = FALSE;
|
|
||||||
self->transient = FALSE;
|
self->transient = FALSE;
|
||||||
self->transients = NULL;
|
self->transients = NULL;
|
||||||
self->transient_for = NULL;
|
self->transient_for = NULL;
|
||||||
|
@ -1171,7 +1170,7 @@ static Client *search_focus_tree(Client *node, Client *skip)
|
||||||
Client *c = it->data;
|
Client *c = it->data;
|
||||||
if (c == skip) continue; /* circular? */
|
if (c == skip) continue; /* circular? */
|
||||||
if ((ret = search_focus_tree(c, skip))) return ret;
|
if ((ret = search_focus_tree(c, skip))) return ret;
|
||||||
if (c->focused) return c;
|
if (client_focused(c)) return c;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1899,6 +1898,11 @@ gboolean client_focus(Client *self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client_focused(self))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
g_print("Focusing: %lx\n", self->window);
|
||||||
|
|
||||||
if (self->can_focus)
|
if (self->can_focus)
|
||||||
XSetInputFocus(ob_display, self->window, RevertToNone, CurrentTime);
|
XSetInputFocus(ob_display, self->window, RevertToNone, CurrentTime);
|
||||||
|
|
||||||
|
@ -1917,12 +1921,18 @@ gboolean client_focus(Client *self)
|
||||||
XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
|
XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*XSync(ob_display, FALSE); XXX Why sync? */
|
/* XSync(ob_display, FALSE); XXX Why sync? */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_unfocus(Client *self)
|
void client_unfocus(Client *self)
|
||||||
{
|
{
|
||||||
g_assert(focus_client == self);
|
g_assert(focus_client == self);
|
||||||
|
g_print("UNFocusing: %lx\n", self->window);
|
||||||
focus_set_client(NULL);
|
focus_set_client(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean client_focused(Client *self)
|
||||||
|
{
|
||||||
|
return self == focus_client;
|
||||||
|
}
|
||||||
|
|
|
@ -217,8 +217,6 @@ typedef struct Client {
|
||||||
gboolean urgent;
|
gboolean urgent;
|
||||||
/*! Notify the window when it receives focus? */
|
/*! Notify the window when it receives focus? */
|
||||||
gboolean focus_notify;
|
gboolean focus_notify;
|
||||||
/*! Does the client window have the input focus? */
|
|
||||||
gboolean focused;
|
|
||||||
|
|
||||||
/*! The window uses shape extension to be non-rectangular? */
|
/*! The window uses shape extension to be non-rectangular? */
|
||||||
gboolean shaped;
|
gboolean shaped;
|
||||||
|
@ -319,6 +317,9 @@ gboolean client_should_show(Client *self);
|
||||||
to them in a number of places regarding focus or user interaction. */
|
to them in a number of places regarding focus or user interaction. */
|
||||||
gboolean client_normal(Client *self);
|
gboolean client_normal(Client *self);
|
||||||
|
|
||||||
|
/* Returns if the window is focused */
|
||||||
|
gboolean client_focused(Client *self);
|
||||||
|
|
||||||
/*! Move and/or resize the window.
|
/*! Move and/or resize the window.
|
||||||
This also maintains things like the client's minsize, and size increments.
|
This also maintains things like the client's minsize, and size increments.
|
||||||
@param anchor The corner to keep in the same position when resizing.
|
@param anchor The corner to keep in the same position when resizing.
|
||||||
|
|
|
@ -76,6 +76,7 @@ static void focus_fallback(gboolean switching_desks)
|
||||||
|
|
||||||
static void events(ObEvent *e, void *foo)
|
static void events(ObEvent *e, void *foo)
|
||||||
{
|
{
|
||||||
|
g_message("event %d", e->type);
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case Event_Client_Mapped:
|
case Event_Client_Mapped:
|
||||||
if (focus_new && client_normal(e->data.c.client))
|
if (focus_new && client_normal(e->data.c.client))
|
||||||
|
@ -85,7 +86,7 @@ static void events(ObEvent *e, void *foo)
|
||||||
case Event_Client_Unmapped:
|
case Event_Client_Unmapped:
|
||||||
if (ob_state == State_Exiting) break;
|
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())
|
if (!follow_mouse || !focus_under_pointer())
|
||||||
focus_fallback(FALSE);
|
focus_fallback(FALSE);
|
||||||
break;
|
break;
|
||||||
|
@ -110,8 +111,10 @@ static void events(ObEvent *e, void *foo)
|
||||||
--skip_enter;
|
--skip_enter;
|
||||||
}
|
}
|
||||||
else*/
|
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);
|
client_focus(e->data.x.client);
|
||||||
|
g_message("enter %lx", e->data.x.client->window);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue