Merge pull request #1097 from psychon/lazy_client_geometry_update
Lazy client geometry update
This commit is contained in:
commit
3e562dfa53
5
event.h
5
event.h
|
@ -35,8 +35,8 @@ void luaA_emit_refresh(void);
|
||||||
void drawin_refresh(void);
|
void drawin_refresh(void);
|
||||||
|
|
||||||
/* objects/client.c */
|
/* objects/client.c */
|
||||||
|
void client_refresh(void);
|
||||||
void client_focus_refresh(void);
|
void client_focus_refresh(void);
|
||||||
void client_border_refresh(void);
|
|
||||||
|
|
||||||
/* objects/screen.c */
|
/* objects/screen.c */
|
||||||
void screen_refresh(void);
|
void screen_refresh(void);
|
||||||
|
@ -49,8 +49,7 @@ awesome_refresh(void)
|
||||||
banning_refresh();
|
banning_refresh();
|
||||||
stack_refresh();
|
stack_refresh();
|
||||||
drawin_refresh();
|
drawin_refresh();
|
||||||
client_border_refresh();
|
client_refresh();
|
||||||
client_focus_refresh();
|
|
||||||
return xcb_flush(globalconf.connection);
|
return xcb_flush(globalconf.connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
117
objects/client.c
117
objects/client.c
|
@ -757,7 +757,7 @@
|
||||||
|
|
||||||
static area_t titlebar_get_area(client_t *c, client_titlebar_t bar);
|
static area_t titlebar_get_area(client_t *c, client_titlebar_t bar);
|
||||||
static drawable_t *titlebar_get_drawable(lua_State *L, client_t *c, int cl_idx, client_titlebar_t bar);
|
static drawable_t *titlebar_get_drawable(lua_State *L, client_t *c, int cl_idx, client_titlebar_t bar);
|
||||||
static void client_resize_do(client_t *c, area_t geometry, bool force_notice);
|
static void client_resize_do(client_t *c, area_t geometry);
|
||||||
|
|
||||||
/** Collect a client.
|
/** Collect a client.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
|
@ -1128,13 +1128,66 @@ client_focus_refresh(void)
|
||||||
win, globalconf.timestamp);
|
win, globalconf.timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
client_border_refresh(void)
|
client_border_refresh(void)
|
||||||
{
|
{
|
||||||
foreach(c, globalconf.clients)
|
foreach(c, globalconf.clients)
|
||||||
window_border_refresh((window_t *) *c);
|
window_border_refresh((window_t *) *c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
client_geometry_refresh(void)
|
||||||
|
{
|
||||||
|
client_ignore_enterleave_events();
|
||||||
|
foreach(_c, globalconf.clients)
|
||||||
|
{
|
||||||
|
client_t *c = *_c;
|
||||||
|
|
||||||
|
/* Compute the client window's and frame window's geometry */
|
||||||
|
area_t geometry = c->geometry;
|
||||||
|
area_t real_geometry = c->geometry;
|
||||||
|
if (!c->fullscreen)
|
||||||
|
{
|
||||||
|
real_geometry.x = c->titlebar[CLIENT_TITLEBAR_LEFT].size;
|
||||||
|
real_geometry.y = c->titlebar[CLIENT_TITLEBAR_TOP].size;
|
||||||
|
real_geometry.width -= c->titlebar[CLIENT_TITLEBAR_LEFT].size;
|
||||||
|
real_geometry.width -= c->titlebar[CLIENT_TITLEBAR_RIGHT].size;
|
||||||
|
real_geometry.height -= c->titlebar[CLIENT_TITLEBAR_TOP].size;
|
||||||
|
real_geometry.height -= c->titlebar[CLIENT_TITLEBAR_BOTTOM].size;
|
||||||
|
} else {
|
||||||
|
real_geometry.x = 0;
|
||||||
|
real_geometry.y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Is there anything to do? */
|
||||||
|
if (AREA_EQUAL(geometry, c->x11_frame_geometry)
|
||||||
|
&& AREA_EQUAL(real_geometry, c->x11_client_geometry))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
xcb_configure_window(globalconf.connection, c->frame_window,
|
||||||
|
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
|
||||||
|
(uint32_t[]) { geometry.x, geometry.y, geometry.width, geometry.height });
|
||||||
|
xcb_configure_window(globalconf.connection, c->window,
|
||||||
|
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
|
||||||
|
(uint32_t[]) { real_geometry.x, real_geometry.y, real_geometry.width, real_geometry.height });
|
||||||
|
|
||||||
|
c->x11_frame_geometry = geometry;
|
||||||
|
c->x11_client_geometry = real_geometry;
|
||||||
|
|
||||||
|
/* ICCCM 4.2.3 says something else, but Java always needs this... */
|
||||||
|
client_send_configure(c);
|
||||||
|
}
|
||||||
|
client_restore_enterleave_events();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_refresh(void)
|
||||||
|
{
|
||||||
|
client_geometry_refresh();
|
||||||
|
client_border_refresh();
|
||||||
|
client_focus_refresh();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
border_width_callback(client_t *c, uint16_t old_width, uint16_t new_width)
|
border_width_callback(client_t *c, uint16_t old_width, uint16_t new_width)
|
||||||
{
|
{
|
||||||
|
@ -1148,8 +1201,8 @@ border_width_callback(client_t *c, uint16_t old_width, uint16_t new_width)
|
||||||
&diff_x, &diff_y);
|
&diff_x, &diff_y);
|
||||||
geometry.x += diff_x;
|
geometry.x += diff_x;
|
||||||
geometry.y += diff_y;
|
geometry.y += diff_y;
|
||||||
/* force_notice = true -> inform client about changes */
|
/* inform client about changes */
|
||||||
client_resize_do(c, geometry, true);
|
client_resize_do(c, geometry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1498,59 +1551,18 @@ client_apply_size_hints(client_t *c, area_t geometry)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
client_resize_do(client_t *c, area_t geometry, bool force_notice)
|
client_resize_do(client_t *c, area_t geometry)
|
||||||
{
|
{
|
||||||
lua_State *L = globalconf_get_lua_State();
|
lua_State *L = globalconf_get_lua_State();
|
||||||
bool send_notice = force_notice;
|
|
||||||
bool hide_titlebars = c->fullscreen;
|
|
||||||
bool java_is_broken = true;
|
|
||||||
|
|
||||||
screen_t *new_screen = c->screen;
|
screen_t *new_screen = c->screen;
|
||||||
if(!screen_area_in_screen(new_screen, geometry))
|
if(!screen_area_in_screen(new_screen, geometry))
|
||||||
new_screen = screen_getbycoord(geometry.x, geometry.y);
|
new_screen = screen_getbycoord(geometry.x, geometry.y);
|
||||||
|
|
||||||
if(c->geometry.width == geometry.width
|
|
||||||
&& c->geometry.height == geometry.height)
|
|
||||||
/* We are moving without changing the size, see ICCCM 4.2.3 */
|
|
||||||
send_notice = true;
|
|
||||||
if(java_is_broken)
|
|
||||||
/* Java strong. Java Hulk. Java make own rules! */
|
|
||||||
send_notice = true;
|
|
||||||
|
|
||||||
/* Also store geometry including border */
|
/* Also store geometry including border */
|
||||||
area_t old_geometry = c->geometry;
|
area_t old_geometry = c->geometry;
|
||||||
c->geometry = geometry;
|
c->geometry = geometry;
|
||||||
|
|
||||||
/* Ignore all spurious enter/leave notify events */
|
|
||||||
client_ignore_enterleave_events();
|
|
||||||
|
|
||||||
/* Configure the client for its new size */
|
|
||||||
area_t real_geometry = geometry;
|
|
||||||
if (!hide_titlebars)
|
|
||||||
{
|
|
||||||
real_geometry.x = c->titlebar[CLIENT_TITLEBAR_LEFT].size;
|
|
||||||
real_geometry.y = c->titlebar[CLIENT_TITLEBAR_TOP].size;
|
|
||||||
real_geometry.width -= c->titlebar[CLIENT_TITLEBAR_LEFT].size;
|
|
||||||
real_geometry.width -= c->titlebar[CLIENT_TITLEBAR_RIGHT].size;
|
|
||||||
real_geometry.height -= c->titlebar[CLIENT_TITLEBAR_TOP].size;
|
|
||||||
real_geometry.height -= c->titlebar[CLIENT_TITLEBAR_BOTTOM].size;
|
|
||||||
} else {
|
|
||||||
real_geometry.x = 0;
|
|
||||||
real_geometry.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
xcb_configure_window(globalconf.connection, c->frame_window,
|
|
||||||
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
|
|
||||||
(uint32_t[]) { geometry.x, geometry.y, geometry.width, geometry.height });
|
|
||||||
xcb_configure_window(globalconf.connection, c->window,
|
|
||||||
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
|
|
||||||
(uint32_t[]) { real_geometry.x, real_geometry.y, real_geometry.width, real_geometry.height });
|
|
||||||
|
|
||||||
if(send_notice)
|
|
||||||
client_send_configure(c);
|
|
||||||
|
|
||||||
client_restore_enterleave_events();
|
|
||||||
|
|
||||||
luaA_object_push(L, c);
|
luaA_object_push(L, c);
|
||||||
if (!AREA_EQUAL(old_geometry, geometry))
|
if (!AREA_EQUAL(old_geometry, geometry))
|
||||||
luaA_object_emit_signal(L, -1, "property::geometry", 0);
|
luaA_object_emit_signal(L, -1, "property::geometry", 0);
|
||||||
|
@ -1580,7 +1592,7 @@ client_resize_do(client_t *c, area_t geometry, bool force_notice)
|
||||||
/* Convert to global coordinates */
|
/* Convert to global coordinates */
|
||||||
area.x += geometry.x;
|
area.x += geometry.x;
|
||||||
area.y += geometry.y;
|
area.y += geometry.y;
|
||||||
if (hide_titlebars)
|
if (c->fullscreen)
|
||||||
area.width = area.height = 0;
|
area.width = area.height = 0;
|
||||||
drawable_set_geometry(L, -1, area);
|
drawable_set_geometry(L, -1, area);
|
||||||
|
|
||||||
|
@ -1624,12 +1636,9 @@ client_resize(client_t *c, area_t geometry, bool honor_hints)
|
||||||
if (honor_hints)
|
if (honor_hints)
|
||||||
geometry = client_apply_size_hints(c, geometry);
|
geometry = client_apply_size_hints(c, geometry);
|
||||||
|
|
||||||
if(c->geometry.x != geometry.x
|
if(!AREA_EQUAL(c->geometry, geometry))
|
||||||
|| c->geometry.y != geometry.y
|
|
||||||
|| c->geometry.width != geometry.width
|
|
||||||
|| c->geometry.height != geometry.height)
|
|
||||||
{
|
{
|
||||||
client_resize_do(c, geometry, false);
|
client_resize_do(c, geometry);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1799,7 +1808,7 @@ client_set_fullscreen(lua_State *L, int cidx, bool s)
|
||||||
luaA_object_emit_signal(L, abs_cidx, "request::geometry", 1);
|
luaA_object_emit_signal(L, abs_cidx, "request::geometry", 1);
|
||||||
luaA_object_emit_signal(L, abs_cidx, "property::fullscreen", 0);
|
luaA_object_emit_signal(L, abs_cidx, "property::fullscreen", 0);
|
||||||
/* Force a client resize, so that titlebars get shown/hidden */
|
/* Force a client resize, so that titlebars get shown/hidden */
|
||||||
client_resize_do(c, c->geometry, true);
|
client_resize_do(c, c->geometry);
|
||||||
stack_windows();
|
stack_windows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2631,7 +2640,7 @@ titlebar_resize(lua_State *L, int cidx, client_t *c, client_titlebar_t bar, int
|
||||||
}
|
}
|
||||||
|
|
||||||
c->titlebar[bar].size = size;
|
c->titlebar[bar].size = size;
|
||||||
client_resize_do(c, geometry, true);
|
client_resize_do(c, geometry);
|
||||||
|
|
||||||
luaA_object_emit_signal(L, cidx, property_name, 0);
|
luaA_object_emit_signal(L, cidx, property_name, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,9 @@ struct client_t
|
||||||
char *class, *instance;
|
char *class, *instance;
|
||||||
/** Window geometry */
|
/** Window geometry */
|
||||||
area_t geometry;
|
area_t geometry;
|
||||||
|
/** Old window geometry currently configured in X11 */
|
||||||
|
area_t x11_client_geometry;
|
||||||
|
area_t x11_frame_geometry;
|
||||||
/** Startup ID */
|
/** Startup ID */
|
||||||
char *startup_id;
|
char *startup_id;
|
||||||
/** True if the client is sticky */
|
/** True if the client is sticky */
|
||||||
|
|
Loading…
Reference in New Issue