diff options
author | DRC <dcommander@users.sourceforge.net> | 2011-10-07 05:38:00 +0000 |
---|---|---|
committer | DRC <dcommander@users.sourceforge.net> | 2011-10-07 05:38:00 +0000 |
commit | c19ab9ec7f3ac4823802388ac953e9494c613575 (patch) | |
tree | 63513ffd7ce0b3ab3de2d9b619cc4e5b892eea31 /java/com/tigervnc/rfb/ScreenSet.java | |
parent | bba54b0b14fded1d457f426cdc8843a34d6c9dc5 (diff) | |
download | tigervnc-c19ab9ec7f3ac4823802388ac953e9494c613575.tar.gz tigervnc-c19ab9ec7f3ac4823802388ac953e9494c613575.zip |
Move Java source up one level and allow Java viewer to be built as a standalone project (per community request)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4715 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/com/tigervnc/rfb/ScreenSet.java')
-rw-r--r-- | java/com/tigervnc/rfb/ScreenSet.java | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/java/com/tigervnc/rfb/ScreenSet.java b/java/com/tigervnc/rfb/ScreenSet.java new file mode 100644 index 00000000..071282ff --- /dev/null +++ b/java/com/tigervnc/rfb/ScreenSet.java @@ -0,0 +1,89 @@ +/* Copyright 2009 Pierre Ossman for Cendio AB + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + +// Management class for the RFB virtual screens + +package com.tigervnc.rfb; + +import java.util.*; + +public class ScreenSet { + + // Represents a complete screen configuration, excluding framebuffer + // dimensions. + + public ScreenSet() { + screens = new ArrayList<Screen>(); + } + + public static final int num_screens() { return screens.size(); } + + public static final void add_screen(Screen screen) { screens.add(screen); } + public static final void remove_screen(int id) { + for (Iterator iter = screens.iterator(); iter.hasNext(); ) { + Screen refScreen = (Screen)iter.next(); + if (refScreen.id == id) + iter.remove(); + } + } + + public static final boolean validate(int fb_width, int fb_height) { + List<Integer> seen_ids = new ArrayList<Integer>(); + Rect fb_rect = new Rect(); + + if (screens.isEmpty()) + return false; + if (num_screens() > 255) + return false; + + fb_rect.setXYWH(0, 0, fb_width, fb_height); + + for (Iterator iter = screens.iterator(); iter.hasNext(); ) { + Screen refScreen = (Screen)iter.next(); + if (refScreen.dimensions.is_empty()) + return false; + if (!refScreen.dimensions.enclosed_by(fb_rect)) + return false; + //if (seen_ids.lastIndexOf(refScreen.id) != seen_ids.get(-1)) + // return false; + seen_ids.add(refScreen.id); + } + + return true; + } + + public final void debug_print() { + for (Iterator iter = screens.iterator(); iter.hasNext(); ) { + Screen refScreen = (Screen)iter.next(); + vlog.error(" "+refScreen.id+" (0x"+refScreen.id+"): "+ + refScreen.dimensions.width()+"x"+refScreen.dimensions.height()+ + "+"+refScreen.dimensions.tl.x+"+"+refScreen.dimensions.tl.y+ + " (flags 0x"+refScreen.flags+")"); + } + } + + // FIXME: List order shouldn't matter + //inline bool operator(const ScreenSet& r) const { return screens == r.screens; } + //inline bool operator(const ScreenSet& r) const { return screens != r.screens; } + + public static List<Screen> screens; + + static LogWriter vlog = new LogWriter("ScreenSet"); + +} + |