Skip to content

Commit f33322a

Browse files
committed
rework logic for default display; store -1 to mean "default" b/c of renumbering
1 parent 4830465 commit f33322a

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

app/src/processing/app/ui/PreferencesFrame.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public class PreferencesFrame {
7777
JComboBox<String> languageSelectionBox;
7878

7979
int displayCount;
80+
int defaultDisplayNum;
8081

8182
String[] monoFontFamilies;
8283
JComboBox<String> fontSelectionBox;
@@ -620,13 +621,19 @@ protected void applyFrame() {
620621
// The preference will have already been reset when the window was created
621622
if (displaySelectionBox.isEnabled()) {
622623
int oldDisplayNum = Preferences.getInteger("run.display");
623-
int displayNum = -1;
624+
int displayNum = -1; // use the default display
624625
for (int d = 0; d < displaySelectionBox.getItemCount(); d++) {
625626
if (displaySelectionBox.getSelectedIndex() == d) {
626-
displayNum = d + 1;
627+
if (d == defaultDisplayNum-1) {
628+
// if it's the default display, store -1 instead of its index,
629+
// because displays can get renumbered when others are attached
630+
displayNum = -1;
631+
} else {
632+
displayNum = d + 1;
633+
}
627634
}
628635
}
629-
if ((displayNum != -1) && (displayNum != oldDisplayNum)) {
636+
if (displayNum != oldDisplayNum) {
630637
Preferences.setInteger("run.display", displayNum); //$NON-NLS-1$
631638
// Reset the location of the sketch, the window has changed
632639
for (Editor editor : base.getEditors()) {
@@ -719,12 +726,12 @@ public void showFrame() {
719726
sketchbookLocationField.setText(Preferences.getSketchbookPath());
720727
checkUpdatesBox.setSelected(Preferences.getBoolean("update.check")); //$NON-NLS-1$
721728

722-
int defaultDisplayNum = updateDisplayList();
729+
defaultDisplayNum = updateDisplayList();
723730
int displayNum = Preferences.getInteger("run.display"); //$NON-NLS-1$
724-
//if (displayNum > 0 && displayNum <= displayCount) {
725731
if (displayNum < 1 || displayNum > displayCount) {
732+
// set the display on close instead; too much weird logic here
733+
//Preferences.setInteger("run.display", displayNum);
726734
displayNum = defaultDisplayNum;
727-
Preferences.setInteger("run.display", displayNum);
728735
}
729736
displaySelectionBox.setSelectedIndex(displayNum-1);
730737

core/todo.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ X two simple examples added to the issue that can be used for tests
3232
X copy() not working correctly
3333
X https://github.com/processing/processing4/issues/169
3434

35+
false alarm
36+
X setting which display to use does not work
37+
X https://github.com/processing/processing4/issues/187
38+
X working, though display numbers might be weird
39+
3540

3641
regressions
37-
_ (unconfirmed) setting which display to use does not work
38-
_ https://github.com/processing/processing4/issues/187
3942
_ mouseButton not set correctly on mouseReleased() with Java2D
4043
_ https://github.com/processing/processing4/issues/181
4144
_ https://github.com/processing/processing4/pull/188
@@ -62,8 +65,6 @@ X https://github.com/processing/processing/issues/5880
6265
X Export Application broken in Processing 3.5.4 when using P2D or P3D renderers
6366
X may be a JOGL bug, fixed by the 2.4 RC (therefore fixed in 4.x already?)
6467
_ https://github.com/processing/processing/issues/5983
65-
_ Profile GL3bc is not available on X11GraphicsDevice
66-
_ https://github.com/processing/processing/issues/5476
6768
X Cannot run rotateZ() within the PShape class
6869
_ https://github.com/processing/processing/issues/5770
6970
_ Profile GL4bc is not available on X11GraphicsDevice

todo.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ X seems that --external not getting passed
2828
X https://github.com/processing/processing4/issues/158
2929
X https://github.com/processing/processing/issues/5843
3030
X https://github.com/processing/processing/issues/5781
31+
X store -1 as display number when using the default
32+
X ran into weird situation where '1' was renumbered by adding a screen
33+
X so the default was now the external display
3134

3235
earlier
3336
o further streamline the downloader
@@ -45,6 +48,10 @@ X https://github.com/processing/processing4/issues/201
4548
X https://github.com/processing/processing/pull/4097
4649

4750

51+
_ editor windows always open on display 1
52+
_ https://github.com/processing/processing/issues/1566
53+
54+
4855
may be fixed
4956
_ Undo feature may have undesired results (4.0a4)
5057
_ https://github.com/processing/processing/issues/4775
@@ -330,9 +337,6 @@ _ library compilations not ordered properly w/ sorting
330337
_ do we still support library compilations? that was from 2016
331338
_ https://github.com/processing/processing/issues/4630
332339

333-
_ editor windows always open on display 1
334-
_ https://github.com/processing/processing/issues/1566
335-
336340

337341
needs review
338342
_ createPreprocessor() added to JavaEditor, creating a mess

0 commit comments

Comments
 (0)