From 0f73bce47e8ed1bcaccce3d5f2259d47dede4c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=BCller?= Date: Tue, 24 Jan 2017 01:44:26 +0100 Subject: [PATCH] prepare searching and highlighting a pid --- src/process-tree-view.c | 5 +++++ src/process-tree-view.h | 1 + src/process-window.c | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/process-tree-view.c b/src/process-tree-view.c index eb7007d..24d936d 100644 --- a/src/process-tree-view.c +++ b/src/process-tree-view.c @@ -769,3 +769,8 @@ xtm_process_tree_view_get_model (XtmProcessTreeView *treeview) { return GTK_TREE_MODEL (treeview->model); } + +void +xtm_process_tree_view_highlight_pid(XtmProcessTreeView *treeview, guint pid) { +//TBD: search and highlight the given pid +} diff --git a/src/process-tree-view.h b/src/process-tree-view.h index 3f1b5dc..b9f093f 100644 --- a/src/process-tree-view.h +++ b/src/process-tree-view.h @@ -54,5 +54,6 @@ GtkWidget * xtm_process_tree_view_new (void); void xtm_process_tree_view_get_sort_column_id (XtmProcessTreeView *treeview, gint *sort_column_id, GtkSortType *sort_type); void xtm_process_tree_view_set_filter (XtmProcessTreeView *treeview, const gchar *cmd_filter); GtkTreeModel * xtm_process_tree_view_get_model (XtmProcessTreeView *treeview); +void xtm_process_tree_view_highlight_pid (XtmProcessTreeView *treeview, guint pid); #endif /* !PROCESS_TREE_VIEW_H */ diff --git a/src/process-window.c b/src/process-window.c index 99dbc68..fe31518 100644 --- a/src/process-window.c +++ b/src/process-window.c @@ -138,7 +138,8 @@ Select_Window (Display *dpy, int screen) static void xwininfo_clicked_cb (GtkButton *button, gpointer user_data) { - Window window; + XtmProcessWindow *window = (XtmProcessWindow *) user_data; + Window selected_window; Display *dpy = NULL; XID id = None; @@ -151,28 +152,29 @@ xwininfo_clicked_cb (GtkButton *button, gpointer user_data) { int status; unsigned long bytes_after; - int pid = -1; + guint pid = 0; dpy = XOpenDisplay (NULL); - window = Select_Window (dpy, 0); - if (window) { - window = XmuClientWindow (dpy, window); + selected_window = Select_Window (dpy, 0); + if (selected_window) { + selected_window = XmuClientWindow (dpy, selected_window); } atom_NET_WM_PID = XInternAtom(dpy, "_NET_WM_PID", False); - status = XGetWindowProperty(dpy, window, atom_NET_WM_PID, 0, (~0L), + status = XGetWindowProperty(dpy, selected_window, atom_NET_WM_PID, 0, (~0L), False, AnyPropertyType, &actual_type, &actual_format, &_nitems, &bytes_after, &prop); if (status == BadWindow) { - g_warning("window id # 0x%lx does not exists!", window); + g_warning("window id # 0x%lx does not exists!", selected_window); } if (status != Success) { g_warning("XGetWindowProperty failed!"); } else { if (_nitems > 0) { - pid = (int) *((unsigned long*)prop); + pid = (guint) *((unsigned long*)prop); g_warning("PID: %d", pid); + xtm_process_tree_view_highlight_pid(XTM_PROCESS_TREE_VIEW (window->treeview), pid); } else { g_warning("No Pid found"); }