summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions.c1
-rw-r--r--src/data.h5
-rw-r--r--src/events.c60
-rw-r--r--src/window.c6
-rw-r--r--src/window.h3
5 files changed, 51 insertions, 24 deletions
diff --git a/src/actions.c b/src/actions.c
index 15372be..741b69c 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -2494,6 +2494,7 @@ spawn(char *cmd, int raw)
child->frame = current_frame();
child->group = rp_current_group;
child->screen = current_screen();
+ child->window_mapped = 0;
list_add (&child->node, &rp_children);
diff --git a/src/data.h b/src/data.h
index 638697b..f2ca8eb 100644
--- a/src/data.h
+++ b/src/data.h
@@ -270,6 +270,11 @@ struct rp_child_info
rp_frame *frame;
rp_screen *screen;
+ /* Non-zero when the pid has mapped a window. This is to prevent
+ every window the program opens from getting mapped in the frame
+ it was launched from. Only the first window should do this. */
+ int window_mapped;
+
/* This structure can exist in a list. */
struct list_head node;
};
diff --git a/src/events.c b/src/events.c
index 8508af2..ded7698 100644
--- a/src/events.c
+++ b/src/events.c
@@ -597,30 +597,46 @@ property_notify (XEvent *ev)
if (win)
{
- switch (ev->xproperty.atom)
+ if (ev->xproperty.atom == _net_wm_pid)
{
- case XA_WM_NAME:
- PRINT_DEBUG (("updating window name\n"));
- update_window_name (win);
- update_window_names (win->scr);
- break;
-
- case XA_WM_NORMAL_HINTS:
- PRINT_DEBUG (("updating window normal hints\n"));
- update_normal_hints (win);
- if (win->state == NormalState)
- maximize (win);
- break;
+ struct rp_child_info *child_info;
- case XA_WM_TRANSIENT_FOR:
- PRINT_DEBUG (("Transient for\n"));
- win->transient = XGetTransientForHint (dpy, win->w, &win->transient_for);
- break;
-
- default:
- PRINT_DEBUG (("Unhandled property notify event: %ld\n", ev->xproperty.atom));
- break;
- }
+ PRINT_DEBUG (("updating _NET_WM_PID\n"));
+ child_info = get_child_info(win->w);
+ if (child_info)
+ {
+ if (child_info->frame)
+ {
+ PRINT_DEBUG (("frame=%p\n", child_info->frame));
+ win->intended_frame_number = child_info->frame->number;
+ }
+ /* TODO: also adopt group information? */
+ }
+ } else
+ switch (ev->xproperty.atom)
+ {
+ case XA_WM_NAME:
+ PRINT_DEBUG (("updating window name\n"));
+ update_window_name (win);
+ update_window_names (win->scr);
+ break;
+
+ case XA_WM_NORMAL_HINTS:
+ PRINT_DEBUG (("updating window normal hints\n"));
+ update_normal_hints (win);
+ if (win->state == NormalState)
+ maximize (win);
+ break;
+
+ case XA_WM_TRANSIENT_FOR:
+ PRINT_DEBUG (("Transient for\n"));
+ win->transient = XGetTransientForHint (dpy, win->w, &win->transient_for);
+ break;
+
+ default:
+ PRINT_DEBUG (("Unhandled property notify event: %ld\n", ev->xproperty.atom));
+ break;
+ }
}
}
diff --git a/src/window.c b/src/window.c
index 0936999..ad926f4 100644
--- a/src/window.c
+++ b/src/window.c
@@ -108,7 +108,7 @@ window_name (rp_window *win)
/* FIXME: we need to verify that the window is running on the same
host as something. otherwise there could be overlapping PIDs. */
-static struct rp_child_info *
+struct rp_child_info *
get_child_info (Window w)
{
rp_child_info *cur;
@@ -204,13 +204,15 @@ add_to_window_list (rp_screen *s, Window w)
child_info = get_child_info (w);
- if (child_info) {
+ if (child_info && !child_info->window_mapped) {
rp_frame *frame = screen_find_frame_by_frame (child_info->screen, child_info->frame);
PRINT_DEBUG(("frame=%p\n", frame));
group = groups_find_group_by_group (child_info->group);
if (frame)
frame_num = frame->number;
+ /* Only map the first window in the launch frame. */
+ child_info->window_mapped = 1;
}
/* Add the window to the group it's pid was launched in or the
diff --git a/src/window.h b/src/window.h
index 650ade1..3b51316 100644
--- a/src/window.h
+++ b/src/window.h
@@ -67,4 +67,7 @@ rp_frame *win_get_frame (rp_window *win);
void set_active_window_force (rp_window *win);
void set_active_window_body (rp_window *win, int force);
+
+struct rp_child_info *get_child_info (Window w);
+
#endif /* ! _RATPOISON_LIST_H */