static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height, jboolean undecorated, long parent_handle, jboolean resizable) { Window parent = (Window)parent_handle; Window win; XSetWindowAttributes attribs; unsigned int attribmask; XVisualInfo vis_info; if ( !XMatchVisualInfo(disp, screen, DefaultDepth(disp, screen), TrueColor, &vis_info) ) { throwException(env, "Failed to acquire X visual."); return false; } cmap = XCreateColormap(disp, parent, vis_info.visual, AllocNone); if (!checkXError(env, disp)) { return false; } attribs.colormap = cmap; attribs.border_pixel = 0; attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; attribmask = CWColormap | CWEventMask | CWBorderPixel | CWBackPixel; if (isLegacyFullscreen(window_mode)) { attribmask |= CWOverrideRedirect; attribs.override_redirect = True; } win = XCreateWindow(disp, parent, x, y, width, height, 0, vis_info.depth, InputOutput, vis_info.visual, attribmask, &attribs); current_depth = vis_info.depth; current_visual = vis_info.visual; if (!checkXError(env, disp)) { XFreeColormap(disp, cmap); return false; } if (undecorated) { // Use Motif decoration hint property and hope the window manager respects them setDecorations(disp, win, 0); } if (RootWindow(disp, screen) == parent_handle) { // only set hints when Display.setParent isn't used updateWindowBounds(disp, win, x, y, width, height, JNI_TRUE, resizable); updateWindowHints(env, disp, win); } #define NUM_ATOMS 1 Atom protocol_atoms[NUM_ATOMS] = {XInternAtom(disp, "WM_DELETE_WINDOW", False)/*, XInternAtom(disp, "WM_TAKE_FOCUS", False)*/}; XSetWMProtocols(disp, win, protocol_atoms, NUM_ATOMS); if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False); XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False), XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1); } if (!checkXError(env, disp)) { destroyWindow(env, disp, win); return 0; } return win; }
void SplashDialog::init(unsigned int seconds) { setStyle(Motif::Style::SYSTEM); setDecorations(Motif::Decorations::NONE); setWidth(Motif::Application::getScreenWidth()); setHeight(Motif::Application::getScreenHeight()); setX(0); setY(0); //setResizable(false); //setMovable(false); setMwmFunctions(0); getContentPanel()->setShadowThickness(0); vendorLogoPanel.reset(new Motif::Panel("vendorLogoPanel", getContentPanel())); vendorLogoPanel->setTopAttachment(Motif::Attachment::FORM); vendorLogoPanel->setBottomAttachment(Motif::Attachment::FORM); vendorLogoPanel->setTopOffset((Motif::Application::getScreenHeight() / 2) - (128 / 2)); //vendorLogoPanel->setBottomOffset((Motif::Application::getScreenHeight() / 2) + (128 / 2)); vendorLogoPanel->setWidth(520); vendorLogoPanel->setShadowThickness(0); /* dialogPanel->setTopAttachment(Motif::Attachment::FORM); dialogPanel->setLeftAttachment(Motif::Attachment::FORM); dialogPanel->setRightAttachment(Motif::Attachment::FORM); dialogPanel->setBottomAttachment(Motif::Attachment::FORM); dialogPanel->setLeftOffset((totalWidth - panelWidth)/2); dialogPanel->setRightOffset((totalWidth - panelWidth)/2); dialogPanel->setBottomOffset((totalHeight - panelHeight)/2); dialogPanel->setTopOffset((totalHeight - panelHeight)/2); */ vendorLogoLabel.reset(new Motif::Label("vendorLogoLabel", vendorLogoPanel.get())); vendorLogoLabel->setPixmap(OpenCDE::Environment::getPrefix() + "/share/opencde/pixmaps/Welcome.xpm"); vendorLogoLabel->setY(4); vendorLogoLabel->setX(4); vendorLogoLabel->setWidth(512); vendorLogoLabel->setHeight(128); /* set up our timer to exit */ int ms = seconds * 1000; timer.reset(new Motif::Timer()); timer->setIntervalFunction(FUNCTION(SplashDialog::onTimerTick)); timer->start(ms); setVisible(true); }
LockDialog::LockDialog() : Motif::Dialog("lockDialog") { int totalWidth = Motif::Application::getScreenWidth(); int totalHeight = Motif::Application::getScreenHeight(); int panelWidth = 640; int panelHeight = 294; int pictureSize = 256; //if(OpenCDE::Environment::getUsername() != "root") if(geteuid() != 0) { throw OpenCDE::OpenCDEException("This application must be run as root"); } setCloseFunction(FUNCTION(LockDialog::onClose)); setShowFunction(FUNCTION(LockDialog::onShow)); setStyle(Motif::Style::SYSTEM); setDecorations(Motif::Decorations::NONE); setWidth(totalWidth); setHeight(totalHeight); setX(-1); setY(-1); //setResizable(false); //setMovable(false); setMwmFunctions(0); getContentPanel()->setShadowThickness(0); dialogPanel.reset(new Motif::Panel("dialogPanel", getContentPanel())); dialogPanel->setTopAttachment(Motif::Attachment::FORM); dialogPanel->setLeftAttachment(Motif::Attachment::FORM); dialogPanel->setRightAttachment(Motif::Attachment::FORM); dialogPanel->setBottomAttachment(Motif::Attachment::FORM); dialogPanel->setLeftOffset((totalWidth - panelWidth)/2); dialogPanel->setRightOffset((totalWidth - panelWidth)/2); dialogPanel->setBottomOffset((totalHeight - panelHeight)/2); dialogPanel->setTopOffset((totalHeight - panelHeight)/2); dialogPanel->setShadowThickness(3); vendorLogoPanel.reset(new Motif::Panel("vendorLogoPanel", dialogPanel.get())); vendorLogoPanel->setTopAttachment(Motif::Attachment::FORM); vendorLogoPanel->setRightAttachment(Motif::Attachment::FORM); vendorLogoPanel->setBottomAttachment(Motif::Attachment::FORM); vendorLogoPanel->setLeftAttachment(Motif::Attachment::FORM); vendorLogoPanel->setTopOffset(15); vendorLogoPanel->setLeftOffset(panelWidth - pictureSize - 23); vendorLogoPanel->setRightOffset(15); vendorLogoPanel->setBottomOffset(15); vendorLogoPanel->setShadowThickness(2); vendorLogoLabel.reset(new Motif::Label("vendorLogoLabel", vendorLogoPanel.get())); vendorLogoLabel->setPixmap(OpenCDE::Environment::getPrefix() + "/share/opencde/pixmaps/VendorLogo.xpm"); vendorLogoLabel->setTopAttachment(Motif::Attachment::FORM); vendorLogoLabel->setBottomAttachment(Motif::Attachment::FORM); vendorLogoLabel->setLeftAttachment(Motif::Attachment::FORM); vendorLogoLabel->setRightAttachment(Motif::Attachment::FORM); vendorLogoLabel->setTopOffset(2); vendorLogoLabel->setLeftOffset(2); vendorLogoLabel->setRightOffset(2); vendorLogoLabel->setBottomOffset(2); passwordPanel.reset(new Motif::Panel("passwordPanel", dialogPanel.get())); passwordPanel->setTopAttachment(Motif::Attachment::FORM); passwordPanel->setLeftAttachment(Motif::Attachment::FORM); passwordPanel->setRightAttachment(Motif::Attachment::FORM); passwordPanel->setBottomAttachment(Motif::Attachment::FORM); passwordPanel->setTopOffset(15); passwordPanel->setLeftOffset(15); passwordPanel->setRightOffset(pictureSize + 23); passwordPanel->setBottomOffset(15); passwordPanel->setShadowThickness(2); userInformationLabel.reset(new Motif::Label("userInformationLabel", passwordPanel.get())); userInformationLabel->setText("Display locked by user " + OpenCDE::Environment::getVariable("USER") + "."); userInformationLabel->setTopAttachment(Motif::Attachment::FORM); userInformationLabel->setLeftAttachment(Motif::Attachment::FORM); userInformationLabel->setRightAttachment(Motif::Attachment::FORM); userInformationLabel->setTopOffset(75); userInformationLabel->setLeftOffset(25); userInformationLabel->setRightOffset(25); informationLabel.reset(new Motif::Label("informationLabel", passwordPanel.get())); informationLabel->setText("Enter password to unlock."); informationLabel->setTopAttachment(Motif::Attachment::FORM); informationLabel->setLeftAttachment(Motif::Attachment::FORM); informationLabel->setRightAttachment(Motif::Attachment::FORM); informationLabel->setTopOffset(100); informationLabel->setLeftOffset(25); informationLabel->setRightOffset(25); password.reset(new Motif::Password("password", passwordPanel.get())); password->setTopAttachment(Motif::Attachment::FORM); password->setLeftAttachment(Motif::Attachment::FORM); password->setRightAttachment(Motif::Attachment::FORM); password->setTopOffset(150); password->setLeftOffset(125); password->setRightOffset(75); password->setActivateFunction(FUNCTION(LockDialog::onPasswordActivate)); password->setShadowThickness(1); password->setHighlightThickness(1); passwordLabel.reset(new Motif::Label("passwordLabel", passwordPanel.get())); passwordLabel->setHeight(password->getHeight()); passwordLabel->setNoResize(true); passwordLabel->setText("Password:"); passwordLabel->setTopAttachment(Motif::Attachment::FORM); passwordLabel->setLeftAttachment(Motif::Attachment::FORM); passwordLabel->setRightAttachment(Motif::Attachment::FORM); passwordLabel->setTopOffset(150); passwordLabel->setLeftOffset(40); passwordLabel->setRightOffset(225); setVisible(true); }
LoginWindow::LoginWindow() : Motif::Window("loginWindow") { userEntry = true; OpenCDE::Shell::execute("xsetroot -solid Black"); OpenCDE::Shell::execute("xsetroot -cursor_name left_ptr"); setCloseFunction(FUNCTION(LoginWindow::onClose)); setShowFunction(FUNCTION(LoginWindow::onShow)); setDecorations(Motif::Decorations::NONE); setWidth(Motif::Application::getScreenWidth()); setHeight(Motif::Application::getScreenHeight()); setX(0); setY(0); //setResizable(false); //setMovable(false); getContentPanel()->setShadowThickness(0); containerPanel.reset(new Motif::Panel("containerPanel", getContentPanel())); containerPanel->setWidth(800); containerPanel->setHeight(294); containerPanel->setX((Motif::Application::getScreenWidth() / 2) - (800 / 2)); containerPanel->setY((Motif::Application::getScreenHeight() / 2) - (294 / 2)); containerPanel->setShadowThickness(3); vendorLogoPanel.reset(new Motif::Panel("vendorLogoPanel", containerPanel.get())); vendorLogoPanel->setY(15); vendorLogoPanel->setX(521); vendorLogoPanel->setWidth(264); vendorLogoPanel->setHeight(264); vendorLogoPanel->setShadowThickness(2); vendorLogoLabel.reset(new Motif::Label("vendorLogoLabel", vendorLogoPanel.get())); vendorLogoLabel->setPixmap(OpenCDE::Environment::getPrefix() + "/share/opencde/pixmaps/VendorLogo.xpm"); vendorLogoLabel->setY(4); vendorLogoLabel->setX(4); vendorLogoLabel->setWidth(256); vendorLogoLabel->setHeight(256); passwordPanel.reset(new Motif::Panel("passwordPanel", containerPanel.get())); passwordPanel->setY(15); passwordPanel->setX(15); passwordPanel->setWidth(506); passwordPanel->setHeight(264); passwordPanel->setShadowThickness(2); passwordPanel->setResizable(false); userInformationLabel.reset(new Motif::Label("userInformationLabel", passwordPanel.get())); userInformationLabel->setText("Welcome to " + OpenCDE::Environment::getHostname()); userInformationLabel->setLeftAttachment(Motif::Attachment::FORM); userInformationLabel->setRightAttachment(Motif::Attachment::FORM); userInformationLabel->setY(50); userInformationLabel->setLeftOffset(25); userInformationLabel->setRightOffset(25); informationLabel.reset(new Motif::Label("informationLabel", passwordPanel.get())); informationLabel->setText("Please enter your user name"); informationLabel->setLeftAttachment(Motif::Attachment::FORM); informationLabel->setRightAttachment(Motif::Attachment::FORM); informationLabel->setLeftOffset(25); informationLabel->setRightOffset(25); informationLabel->setY(125); text.reset(new Motif::Text("usernameText", passwordPanel.get())); text->setLeftAttachment(Motif::Attachment::FORM); text->setRightAttachment(Motif::Attachment::FORM); text->setLeftOffset(150); text->setRightOffset(150); text->setY(150); text->setActivateFunction(FUNCTION(LoginWindow::onTextActivate)); text->setShadowThickness(1); text->setHighlightThickness(1); password.reset(new Motif::Password("password", passwordPanel.get())); password->setLeftAttachment(Motif::Attachment::FORM); password->setRightAttachment(Motif::Attachment::FORM); password->setLeftOffset(150); password->setRightOffset(150); password->setY(150); password->setActivateFunction(FUNCTION(LoginWindow::onPasswordActivate)); password->setShadowThickness(1); password->setHighlightThickness(1); password->setVisible(false); okButton.reset(new Motif::Button("okButton", passwordPanel.get())); okButton->setShadowThickness(1); okButton->setBottomAttachment(Motif::Attachment::FORM); okButton->setBottomOffset(10); okButton->setText("OK"); okButton->setX(10); okButton->setHeight(30); okButton->setWidth(100); okButton->setShowAsDefault(1); okButton->setActivateFunction(FUNCTION(LoginWindow::onOkButtonActivate)); startOverButton.reset(new Motif::Button("startOverButton", passwordPanel.get())); startOverButton->setShadowThickness(1); startOverButton->setBottomAttachment(Motif::Attachment::FORM); startOverButton->setBottomOffset(10); startOverButton->setText("Start Over"); startOverButton->setX(120); startOverButton->setHeight(30); startOverButton->setWidth(100); startOverButton->setShowAsDefault(1); startOverButton->setActivateFunction(FUNCTION(LoginWindow::onStartOverButtonActivate)); shutdownButton.reset(new Motif::Button("startOverButton", passwordPanel.get())); shutdownButton->setShadowThickness(1); shutdownButton->setBottomAttachment(Motif::Attachment::FORM); shutdownButton->setBottomAttachment(Motif::Attachment::FORM); shutdownButton->setRightAttachment(Motif::Attachment::FORM); shutdownButton->setBottomOffset(10); shutdownButton->setText("Shutdown"); shutdownButton->setRightOffset(10); shutdownButton->setHeight(30); shutdownButton->setWidth(100); shutdownButton->setShowAsDefault(1); shutdownButton->setActivateFunction(FUNCTION(LoginWindow::onShutdownButtonActivate)); restartButton.reset(new Motif::Button("startOverButton", passwordPanel.get())); restartButton->setShadowThickness(1); restartButton->setBottomAttachment(Motif::Attachment::FORM); restartButton->setRightAttachment(Motif::Attachment::FORM); restartButton->setBottomOffset(10); restartButton->setText("Restart"); restartButton->setRightOffset(120); restartButton->setHeight(30); restartButton->setWidth(100); restartButton->setShowAsDefault(1); restartButton->setActivateFunction(FUNCTION(LoginWindow::onRestartButtonActivate)); setVisible(true); text->setFocus(); }