jigish / slate

A window management application (replacement for Divvy/SizeUp/ShiftIt)
GNU General Public License v3.0
7.85k stars 510 forks source link

Unable to resize XQuartz windows #321

Open pfista opened 11 years ago

pfista commented 11 years ago

Any programs running through XQuartz dont seem to be affected by slate resize commands.

milkypostman commented 10 years ago

+1 to figure out a workaround for this.

camagu commented 10 years ago

+1 Seems XQuartz windows are not affected by slate at all.

davidhubbard commented 10 years ago

With .slate.js I can work around it. Install xdotool using MacPorts or Homebrew. I used Homebrew so it's in /usr/local/bin/xdotool.

function nudge_x11_workaround(win, x, y) {
  x *= 10;
  y *= 10;

  if (typeof win == "undefined") {
    // bug: X11 works differently somehow
    S.shell("/bin/bash -c 'export DISPLAY=:0;" +
      "/usr/local/bin/xdotool getactivewindow windowmove --relative -- " +
      x + " " + (y - 44) + "'");
  } else {
    if (x == 0) x = "+0";
    else if (x > 0) x = "+" + x + "%";
    else x = x + "%";
    if (y == 0) y = "+0";
    else if (y > 0) y = "+" + y + "%";
    else y = y + "%";
    win.doOperation(S.operation("nudge", { "x":x, "y":y }));
  }
};

S.bind("left:cmd;alt",  function(win) { nudge_x11_workaround(win, -1, 0); });
S.bind("right:cmd;alt", function(win) { nudge_x11_workaround(win,  1, 0); });
S.bind("up:cmd;alt",    function(win) { nudge_x11_workaround(win, 0, -1); });
S.bind("down:cmd;alt",  function(win) { nudge_x11_workaround(win, 0,  1); });