summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-02-28 11:16:54 +0100
committerDave Davenport <qball@gmpclient.org>2016-02-28 11:16:54 +0100
commit91ad94aef3005d143fa7c554aa3cdece9aa5f9e3 (patch)
treea7f11c2ecd4dbb36c06eb20d047f2ffe181439b6 /source
parent4cd76a6d8edf168857bd5a3f4d4e48d034c11661 (diff)
Free right memory, get right window class name.
Diffstat (limited to 'source')
-rw-r--r--source/dialogs/window.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index 2ae9b86d..319b1a2c 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -267,34 +267,27 @@ static client* window_client ( xcb_connection_t *xcb_connection, xcb_window_t wi
if(xcb_ewmh_get_wm_state_reply( &xcb_ewmh, cky, &states, NULL)){
c->states = MIN(CLIENTSTATE,states.atoms_len);
memcpy(c->state, states.atoms, MIN(CLIENTSTATE, states.atoms_len));
+ xcb_ewmh_get_atoms_reply_wipe(&states);
}
cky = xcb_ewmh_get_wm_window_type(&xcb_ewmh, win);
if(xcb_ewmh_get_wm_window_type_reply( &xcb_ewmh, cky, &states, NULL)){
c->window_types= MIN(CLIENTWINDOWTYPE,states.atoms_len);
memcpy(c->window_type, states.atoms, MIN(CLIENTWINDOWTYPE, states.atoms_len));
+ xcb_ewmh_get_atoms_reply_wipe(&states);
}
- char *name;
- if ( ( name = window_get_text_prop ( xcb_connection, c->window, xcb_ewmh._NET_WM_NAME ) ) && name ) {
- c->title = name;
- name = NULL;
+ c->title = window_get_text_prop ( xcb_connection, c->window, xcb_ewmh._NET_WM_NAME );
+ if ( c->title == NULL ) {
+ c->title = window_get_text_prop ( xcb_connection, c->window, XCB_ATOM_WM_NAME);
}
- else if ( (name = window_get_text_prop ( xcb_connection, c->window, XCB_ATOM_WM_NAME)) && name) {
- c->title = name;
- name = NULL;
- }
-
- name = window_get_text_prop ( xcb_connection, c->window, netatoms[WM_WINDOW_ROLE] );
- if ( name != NULL ) {
- c->role = name;
- name = NULL;
- }
+ c->role = window_get_text_prop ( xcb_connection, c->window, netatoms[WM_WINDOW_ROLE] );
- name = window_get_text_prop ( xcb_connection, c->window, XCB_ATOM_WM_CLASS );
- if ( name != NULL ){
- c->class = name;
- name = NULL;
+ cky = xcb_icccm_get_wm_class ( xcb_connection, c->window );
+ xcb_icccm_get_wm_class_reply_t wcr;
+ if ( xcb_icccm_get_wm_class_reply (xcb_connection, cky, &wcr, NULL)) {
+ c->class = g_strdup(wcr.class_name);
+ xcb_icccm_get_wm_class_reply_wipe (&wcr);
}
xcb_get_property_cookie_t cc = xcb_icccm_get_wm_hints ( xcb_connection, c->window);
@@ -382,30 +375,31 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
x11_cache_create ();
// Check for i3
pd->config_i3_mode = i3_support_initialize ( xcb_connection );
-
- if ( !xcb_ewmh_get_active_window_reply ( &xcb_ewmh,
- xcb_ewmh_get_active_window( &xcb_ewmh, xcb_screen_nbr), &curr_win_id, NULL )) {
+ xcb_get_property_cookie_t c =xcb_ewmh_get_active_window( &xcb_ewmh, xcb_screen_nbr);
+ if ( !xcb_ewmh_get_active_window_reply ( &xcb_ewmh, c, &curr_win_id, NULL )) {
curr_win_id = 0;
}
// Get the current desktop.
unsigned int current_desktop = 0;
- xcb_get_property_cookie_t c = xcb_ewmh_get_current_desktop( &xcb_ewmh, xcb_screen_nbr);
+ c = xcb_ewmh_get_current_desktop( &xcb_ewmh, xcb_screen_nbr);
if ( !xcb_ewmh_get_current_desktop_reply ( &xcb_ewmh, c, &current_desktop, NULL )){
current_desktop = 0;
}
- xcb_get_property_cookie_t cc = xcb_ewmh_get_client_list_stacking ( &xcb_ewmh, 0);
+ c = xcb_ewmh_get_client_list_stacking ( &xcb_ewmh, 0);
xcb_ewmh_get_windows_reply_t clients;
- if ( xcb_ewmh_get_client_list_stacking_reply ( &xcb_ewmh, cc, &clients, NULL)){
+ if ( xcb_ewmh_get_client_list_stacking_reply ( &xcb_ewmh, c, &clients, NULL)){
nwins = MIN ( 100, clients.windows_len);
- memcpy(wins, clients.windows, nwins*sizeof(xcb_window_t) );
+ memcpy(wins, clients.windows, nwins*sizeof(xcb_window_t) );
+ xcb_ewmh_get_windows_reply_wipe(&clients);
}
else {
- cc = xcb_ewmh_get_client_list ( &xcb_ewmh, xcb_screen_nbr);
- if ( xcb_ewmh_get_client_list_reply ( &xcb_ewmh, cc, &clients, NULL)) {
+ c = xcb_ewmh_get_client_list ( &xcb_ewmh, xcb_screen_nbr);
+ if ( xcb_ewmh_get_client_list_reply ( &xcb_ewmh, c, &clients, NULL)) {
nwins = MIN ( 100, clients.windows_len);
- memcpy(wins, clients.windows, nwins*sizeof(xcb_window_t) );
+ memcpy(wins, clients.windows, nwins*sizeof(xcb_window_t) );
+ xcb_ewmh_get_windows_reply_wipe(&clients);
}
}
if ( nwins > 0 ) {
@@ -547,7 +541,7 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i
xcb_ewmh_request_change_active_window ( &xcb_ewmh, xcb_screen_nbr, rmpd->ids->array[selected_line],
XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER ,
XCB_CURRENT_TIME, None);
- xcb_flush(xcb_connection);
+ xcb_flush(xcb_connection);
}
}
return retv;