*
* The MIT License (MIT)
*
- * Copyright (C) 2017 Kevin Lamonte
+ * Copyright (C) 2019 Kevin Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
*/
public class MultiBackend implements Backend {
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* The screen to use.
*/
*/
private List<Backend> backends = new LinkedList<Backend>();
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Public constructor requires one backend. Note that this backend's
* screen will be replaced with a MultiScreen.
}
}
- /**
- * Add a backend to the list.
- *
- * @param backend the backend to add
- */
- public void addBackend(final Backend backend) {
- backends.add(backend);
- if (backend instanceof TWindowBackend) {
- multiScreen.addScreen(((TWindowBackend) backend).getOtherScreen());
- } else {
- multiScreen.addScreen(backend.getScreen());
- }
- }
-
- /**
- * Remove a backend from the list.
- *
- * @param backend the backend to remove
- */
- public void removeBackend(final Backend backend) {
- if (backends.size() > 1) {
- if (backend instanceof TWindowBackend) {
- multiScreen.removeScreen(((TWindowBackend) backend).getOtherScreen());
- } else {
- multiScreen.removeScreen(backend.getScreen());
- }
- backends.remove(backend);
- }
- }
+ // ------------------------------------------------------------------------
+ // Backend ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
* Getter for sessionInfo.
}
}
+ /**
+ * Check if there are events in the queue.
+ *
+ * @return if true, getEvents() has something to return to the application
+ */
+ public boolean hasEvents() {
+ for (Backend backend: backends) {
+ if (backend.hasEvents()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Subclasses must provide an implementation to get keyboard, mouse, and
* screen resize events.
}
}
+ /**
+ * Reload backend options from System properties.
+ */
+ public void reloadOptions() {
+ for (Backend backend: backends) {
+ backend.reloadOptions();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // MultiBackend -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Add a backend to the list.
+ *
+ * @param backend the backend to add
+ */
+ public void addBackend(final Backend backend) {
+ backends.add(backend);
+ if (backend instanceof TWindowBackend) {
+ multiScreen.addScreen(((TWindowBackend) backend).getOtherScreen());
+ } else {
+ multiScreen.addScreen(backend.getScreen());
+ }
+ }
+
+ /**
+ * Remove a backend from the list.
+ *
+ * @param backend the backend to remove
+ */
+ public void removeBackend(final Backend backend) {
+ if (backends.size() > 1) {
+ if (backend instanceof TWindowBackend) {
+ multiScreen.removeScreen(((TWindowBackend) backend).getOtherScreen());
+ } else {
+ multiScreen.removeScreen(backend.getScreen());
+ }
+ backends.remove(backend);
+ }
+ }
+
}