# How to detect display configuration?

**URL:** <https://discourse.processing.org/t/how-to-detect-display-configuration/9169>\
**Category:** Beginners\
**Created:** [March 10, 2019, 9:31am UTC](https://discourse.processing.org/t/how-to-detect-display-configuration/9169 "2019-03-10T09:31:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![xtupof](https://avatars.discourse-cdn.com/v4/letter/x/94ad74/32.png) [@xtupof](https://discourse.processing.org/u/xtupof)\
**Post date:** [March 10, 2019, 9:31am UTC](https://discourse.processing.org/t/how-to-detect-display-configuration/9169/1 "2019-03-10T09:31:45Z")

</div>

Hi there,

I’m switching again and again from my home station with multiple screens to my laptop… At home, I use the `fullScreen(3)` option, but working on my laptop screen I mostly use `size(640,360)`.  
Rather than always comment/uncomment lines, I’d like to add a statement in `setup()` —or maybe `settings()` — to decide by itself…

How could I get informations on the display configuration to do this ?  
It’s a really small issue, I know, but it bother me anyway…

Thanks for reading.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 10, 2019, 1:37pm UTC](https://discourse.processing.org/t/how-to-detect-display-configuration/9169/2 "2019-03-10T13:37:02Z")

</div>

> [@xtupof](#):
>
> How could I get informations on the display configuration to do this?

You can check out _displayWidth_ for example: 📺  
[Processing.GitHub.io/processing-javadocs/core/processing/core/PApplet.html#displayWidth](http://Processing.GitHub.io/processing-javadocs/core/processing/core/PApplet.html#displayWidth)

---

<div class="post-metadata">

**Author:** ![Nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@Nathan](https://discourse.processing.org/u/Nathan)\
**Post date:** [March 10, 2019, 9:02pm UTC](https://discourse.processing.org/t/how-to-detect-display-configuration/9169/3 "2019-03-10T21:02:59Z")

</div>

Are you using the Processing IDE or some other tool?

The problem with looking at displayWidth/displayHeight is that fullScreen(…) / size(…) must be the **first** line in setup(). So you can’t do much there unless you evaluate a function or variable in there. You can’t pass width, height parameters to fullScreen and unless you want not to use fullScreen you shouldn’t use size(…) in Processing 3.x apparently.

You might be better off just leaving the fullScreen call the same and just changing which display to use in preferences. I don’t know how else Processing would have any idea which of the displays you want to run the sketch on at the moment.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 10, 2019, 9:30pm UTC](https://discourse.processing.org/t/how-to-detect-display-configuration/9169/4 "2019-03-10T21:30:55Z")

</div>

- [Forum.Processing.org/two/discussion/14151/how-to-set-window-size-slightly-smaller-than-display-resolution-size#Item\_1](http://Forum.Processing.org/two/discussion/14151/how-to-set-window-size-slightly-smaller-than-display-resolution-size#Item_1)

---

<div class="post-metadata">

**Author:** ![xtupof](https://avatars.discourse-cdn.com/v4/letter/x/94ad74/32.png) [@xtupof](https://discourse.processing.org/u/xtupof)\
**Post date:** [March 11, 2019, 9:36am UTC](https://discourse.processing.org/t/how-to-detect-display-configuration/9169/5 "2019-03-11T09:36:16Z")

</div>

Well, thanks for your answers.

To answer questions, yes I’m using Processing IDE.  
I’m running P 3.5.3 on OSX — I know, but it made sense to me once…

Indeed, `displayWidth` does the job with this little statement in settings() :

```auto
  if (displayWidth==1920) fullScreen(3);
   else size(displayWidth/2, displayHeight/2);

```

Doing my researches, I found this post about `surfaceLocation()`, thanks to you GoToLoop :

[https://forum.processing.org/two/discussion/14138/how-to-set-the-initial-location-of-the-canva-relative-to-screen-display](https://forum.processing.org/two/discussion/14138/how-to-set-the-initial-location-of-the-canva-relative-to-screen-display)

Using this, I’m able to set the location of the draw window in laptop only mode, so that it doesn’t overlap the editor and then, my issue is fixed…

… BUT there’s still things I don’t understand. Unplugging my third screen, I got these lines in my console :

```auto
Display 3 does not exist, using the default display instead.
Display 1 is sun.awt.CGraphicsDevice@5649fd9b
Display 2 is sun.awt.CGraphicsDevice@6adede5

```

It looks to me that if Processing can retrieve these informations, there should be a way for me to get and use them, no ?

---

<div class="post-metadata">

**Author:** ![Nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@Nathan](https://discourse.processing.org/u/Nathan)\
**Post date:** [May 14, 2019, 8:51pm UTC](https://discourse.processing.org/t/how-to-detect-display-configuration/9169/6 "2019-05-14T20:51:12Z")

</div>

There’s a difference between Java (and indirectly, Processing) knowing what displays exist and knowing which one _you_ want to use. It might be possible to call a function inside size() or fullScreen() if you could work out what that function should do, but it needs to be able to do so without any input.

E.g.

```auto
void setup() {
    size( getDisplay(parameter).getWidth(), getDisplay(parameter).getHeight() );
}

```

or

```auto
void setup() {
    fullScreen( getDisplay(parameter).getId() );
}

```

Not sure if stuff in setup can safely use pre-defined variables, but if you always use the same screens you could create some kind of mapping from pre-defined sizes to the display you think it. That would be useless for production, so to speak, but fine for development purposes.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 14, 2019, 9:52pm UTC](https://discourse.processing.org/t/how-to-detect-display-configuration/9169/7 "2019-05-14T21:52:20Z")

</div>

> [@Nathan](#):
>
> Not sure if stuff in setup can safely use pre-defined variables

It can’t – at least, `size()` in `setup()` can’t – but that is what `settings()` is for.

> The **settings()** function is new with Processing 3.0. It’s not needed in most sketches. It’s only useful when it’s absolutely necessary to define the parameters to **size()** with a variable. [settings() / Reference / Processing.org](https://processing.org/reference/settings_.html)
