Superswitcher 0.3 and libwnck



Not finding a libwnck-devel-list, I'm asking metacity-devel-list.

Superswitcher [1] is built on top of libwnck.  For example, it allows
one to "delete" a workspace, so that if I had six windows A, B, C, D,
E and F in four workspaces like

Workspace 1: A, B, C
Workspace 2: [empty]
Workspace 3: D
Workspace 4: E, F

then "deleting" workspace 2 would result in

Workspace 1: A, B, C
Workspace 2: D
Workspace 3: E, F

Currently, this is implemented somewhat hackily by first moving
windows D, E and F to their respective new workspaces, and then
setting the number of workspaces to 3.  This is not atomic, however,
which might lead to subtle bugs.

My first question is - if I converted my application code to a libwnck
patch (that declares new API), would the libwnck maintainers be
interested at all in this?

My second question is - in order to move windows from one Xinerama
screen to the next, I have to find out the x/y/width/height of
metacity's framing window (sorry but I don't know the right name to
call it - the surrounding window that the window manager adds that has
e.g. the titlebar), but libwnck doesn't give me that, since my
understanding is that libwnck is window-manager agnostic.

Right now, I am doing the chunk of code below (from
superswitcher/src/xinerama.c), but it seems rather hacky and fragile,
and I am asking if there is a better way to do this.

-----------------------------------------------
static Window get_x_parent_window (Display *x_display, Window x_window)
{
  Window root, parent;
  Window *children;
  unsigned int num_children;

  XQueryTree (x_display, x_window, &root, &parent, &children, &num_children);
  XFree (children);
  return parent;
}

void ss_xinerama_move_to_next_screen (SSXinerama *xinerama, SSWindow *window)
{
...
  // libwnck doesn't have a set_geometry function, nor does it give the
  // geometry of the window manager's frame, so we do this with X calls.
  x_window = wnck_window_get_xid (window->wnck_window);
  x_parent_window = get_x_parent_window (xinerama->x_display, x_window);
  XGetGeometry (xinerama->x_display, x_parent_window,
    &root, &x, &y, &width, &height, &border_width, &depth);

  // now move to the next screen.
  xs = &xinerama->screens[best_screen];
  dx = x - xs->x;
  dy = y - xs->y;
  best_screen = (best_screen + 1) % xinerama->num_screens;
  xs = &xinerama->screens[best_screen];

  // Yuck.  So, I move the window to the desired x,y of its PARENT window on
  // the other (Xinerama) screen.  This seems unintuitive, but it's what works
  // with metacity.  This may be totally broken on other window managers.
  XMoveWindow (xinerama->x_display, x_window, xs->x + dx, xs->y + dy);
}
-----------------------------------------------

thanks,
Nigel.

[1] http://www.gnomefiles.org/app.php?soft_id=1231



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]