Window element to appear on a given monitor

Hy guys,
Lets say that I have a windows PC connected to two monitors.

I would like for the SuperCollider GUI windows I’ve created with my code to appear on the second monitor instead of the primary one.

Initially I thought to write a sort of translation in Rect bounds coordinates but, from the moment I should place negative coords for the x coord (secondary monitor is indeed on the left of the primary) it seems not to work for me.

  • Is there a way to tell SuperCollider Windows to appear on a specific monitor?
  • Is there a way to make the window be created but not to be shown in front but to stay in background? I’ve tested the alwaysOnTop_(false) method but it doesn’t work the way I want.
  • Alternatively, is there a way to place the window outside the screen borders?

here’s just a boiled code I’ve prepared with a couple of comments:

(
var win;
win = Window("test", Rect(-50,0,100, 100)); // negative values fox x seems not to work
win.alwaysOnTop_(false); // this doesn't seem to place the window on background
win.front;
win.minimize; // seems not to work if uses just after .front method.
)

If the windows variable had been an environment variable I could have called .minimize after a certain interval to make it work (and correctly minimize the window). But that’s not my use case.

~win = nil;
(
~win = Window("test", Rect(0,0,100, 100)); // negative values fox x seems not to work
~win.front;
)

~win.minimize; // evaluate this line after a little time delay

Thank you guys.

if you omit win.front the window should stay in the background.

Over on mac I did have success with negative left: param for Rect - Of course this depends on the second monitor being to the left of the first one!

It would be wonderful to be able to specify monitors directly however, or at least for SC to be able to access the current available monitor bounds - I was only able to do this with annoying external tools.

I’ve never found good ways to intelligently lay out window positions, so I tend to use this quark (GitHub - scztt/WindowViewRecall.quark) which automatically remembers the position of a window and recalls it the next time you show it. That way, you place it where you want by hand and it shows up there next time.

~view = View(bounds:100@100).front;
~view.autoRememberPosition(\nameOfMyWindow);

Also, there are some methods on QWidget (the underlying component of View) that are not exposed in SuperCollider, but you can call them anyway.

View().methods(true, true, true).do {
	|m|
	m.postln
};

v = View(bounds:100@100).front;
v.invokeMethod(\hide)
v.invokeMethod(\show)
v.invokeMethod(\raise)
v.invokeMethod(\lower)
v.invokeMethod(\showMinimized)
v.invokeMethod(\showMaximized)
v.invokeMethod(\showNormal)

1 Like