/*
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 */

package com.sun.glass.ui.x11;

import com.sun.glass.ui.Application;
import com.sun.glass.ui.Screen;

import java.util.Vector;

/**
 *
 * @author ddhill
 */
public class X11Screen extends Screen {
    static {
        X11Application.initLibrary();
    }

    native private static Screen _getDeepestScreen(Screen screen);
    native private static Screen _getMainScreen(Screen screen);
    native private static Screen _getScreenForLocation(Screen screen, int x, int y);
    native private static Screen _getScreenForPtr(Screen screen, long screenPtr);
    native private static Vector<Screen> _getScreens(Vector<Screen> screens);

    static Screen getDeepestScreen_impl() {
        return _getDeepestScreen(new Screen());
    }

    private static Screen mainScreen = null;

    static Screen getMainScreen_impl() {
        if (mainScreen == null)
            mainScreen =  _getMainScreen(new Screen());
        return mainScreen;
    }

    static Screen getScreenForLocation_impl(int x, int y) {
        return _getScreenForLocation(new Screen(), x, y);
    }

    static Screen getScreenForPtr_impl(long screenPtr) {
        return _getScreenForPtr(new Screen(), screenPtr);
    }

    private static Vector<Screen> screens = null;
    static Vector<Screen> getScreens_impl() {
        if (screens == null)
            screens =  _getScreens(new Vector<Screen>());
        return screens;
    }

}
