void redecorateVolumes() { ASVolumeCanvasPlacement placement; int width, height; placement.vertical = get_flags(Config->flags, ASMOUNT_Vertical); placement.tileWidth = DEFAULT_TILE_WIDTH; placement.tileHeight = DEFAULT_TILE_HEIGHT; placement.currPos = 0; iterate_asbidirlist (AppState.volumes, redecorateVolume, &placement, NULL, False); XMapSubwindows (dpy, AppState.mainCanvas->w); width = placement.tileWidth; height = placement.tileHeight; if (placement.vertical) height = placement.currPos; else width = placement.currPos; setHints (width, height); /* setHints must happen first */ show_progress ( "resizing main canvas to %dx%d", width, height); resize_canvas (AppState.mainCanvas, width, height); ASSync (False); }
int getServSocket(const char *port) { struct addrinfo hints, *localhosts; int serverSocket; setHints(&hints); run(getaddrinfo(NULL, port, &hints, &localhosts)); run(serverSocket = setUpSocket(localhosts)); freeaddrinfo(localhosts); return serverSocket; }
PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const String &label, uint labelWidth) : Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(labelWidth) { handleScreenChanged(); _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS; setHints(THEME_HINT_SAVE_BACKGROUND); _type = kPopUpWidget; _selectedItem = -1; if (!_label.empty() && _labelWidth == 0) _labelWidth = g_gui.getStringWidth(_label); }
void createMainWindow() { XSetWindowAttributes attr; int width = DEFAULT_TILE_WIDTH; int height = DEFAULT_TILE_HEIGHT; attr.event_mask = StructureNotifyMask|ButtonPressMask|ButtonReleaseMask ; AppState.mainWindow = create_visual_window( Scr.asv, Scr.Root, 0, 0, width, height, 0, InputOutput, CWEventMask, &attr); set_client_names( AppState.mainWindow, MyName, MyName, CLASS_ASMOUNT, CLASS_ASMOUNT ); setHints (width, height); set_client_cmd (AppState.mainWindow); /* showing window to let user see that we are doing something */ XMapRaised (dpy, AppState.mainWindow); // { XEvent e; do { XNextEvent(dpy, &e); } while (e.type != MapNotify); } AppState.mainCanvas = create_ascanvas (AppState.mainWindow); }
/* Parse the buffered image. All of the raster information is returned in the * imagePP structure. * * The handleCustom parameter specifies whether or not the caller * can use custom channels. If it is false and a custom channel * is encountered, the returned value will be 0 and all structures * will be deallocated. * * Return value: * -1: Exception * 0: Can't do it. * 1: Success */ int awt_parseImage(JNIEnv *env, jobject jimage, BufImageS_t **imagePP, int handleCustom) { BufImageS_t *imageP; int status; jobject jraster; jobject jcmodel; /* Make sure the image exists */ if (JNU_IsNull(env, jimage)) { JNU_ThrowNullPointerException(env, "null BufferedImage object"); return -1; } if ((imageP = (BufImageS_t *) calloc(1, sizeof(BufImageS_t))) == NULL) { JNU_ThrowOutOfMemoryError(env, "Out of memory"); return -1; } imageP->jimage = jimage; /* Retrieve the raster */ if ((jraster = (*env)->GetObjectField(env, jimage, g_BImgRasterID)) == NULL) { free((void *) imageP); JNU_ThrowNullPointerException(env, "null Raster object"); return 0; } /* Retrieve the image type */ imageP->imageType = (*env)->GetIntField(env, jimage, g_BImgTypeID); /* Parse the raster */ if ((status = awt_parseRaster(env, jraster, &imageP->raster)) <= 0) { free((void *)imageP); return status; } /* Retrieve the color model */ if ((jcmodel = (*env)->GetObjectField(env, jimage, g_BImgCMID)) == NULL) { free((void *) imageP); JNU_ThrowNullPointerException(env, "null Raster object"); return 0; } /* Parse the color model */ if ((status = awt_parseColorModel(env, jcmodel, imageP->imageType, &imageP->cmodel)) <= 0) { awt_freeParsedRaster(&imageP->raster, FALSE); free((void *)imageP); return 0; } /* Set hints */ if ((status = setHints(env, imageP)) <= 0) { awt_freeParsedImage(imageP, TRUE); return 0; } *imagePP = imageP; return status; }
int SDLFrontend::init (int width, int height, bool fullscreen, EventHandler &eventHandler) { if (width == -1 && height == -1) fullscreen = true; info(LOG_CLIENT, String::format("initializing: %i:%i - fullscreen: %s", width, height, fullscreen ? "true" : "false")); INIT_Subsystem(SDL_INIT_VIDEO, true); INIT_Subsystem(SDL_INIT_JOYSTICK, false); INIT_Subsystem(SDL_INIT_GAMECONTROLLER, false); INIT_Subsystem(SDL_INIT_HAPTIC, false); initJoystickAndHaptic(); SDL_DisplayMode displayMode; SDL_GetDesktopDisplayMode(0, &displayMode); const char *name = SDL_GetPixelFormatName(displayMode.format); info(LOG_CLIENT, String::format("current desktop mode: %dx%d@%dHz (%s)", displayMode.w, displayMode.h, displayMode.refresh_rate, name)); if (width == -1) width = 800;//displayMode.w; if (height == -1) height = 480; //displayMode.h; setGLAttributes(); setHints(); int doubleBuffered = 0; SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doubleBuffered); info(LOG_CLIENT, String::format("doublebuffer: %s", doubleBuffered ? "activated" : "disabled")); int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN; #ifdef __IPHONEOS__ flags |= SDL_WINDOW_RESIZABLE; #endif #if 1 //defined __IPHONEOS__ || defined __ANDROID__ if (fullscreen) flags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS; #else if (fullscreen) flags |= SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_BORDERLESS; #endif const int videoDrivers = SDL_GetNumVideoDrivers(); for (int i = 0; i < videoDrivers; ++i) { info(LOG_CLIENT, String::format("available driver: %s", SDL_GetVideoDriver(i))); } info(LOG_CLIENT, String::format("driver: %s", SDL_GetCurrentVideoDriver())); const int displays = SDL_GetNumVideoDisplays(); info(LOG_CLIENT, String::format("found %i display(s)", displays)); if (fullscreen && displays > 1) { width = displayMode.w; height = displayMode.h; info(LOG_CLIENT, String::format("use fake fullscreen for the first display: %i:%i", width, height)); } _window = SDL_CreateWindow(Singleton<Application>::getInstance().getName().c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, flags); if (!_window) { sdlCheckError(); return -1; } SDL_DisableScreenSaver(); initRenderer(); resetColor(); GLContext::get().init(); if (SDL_SetWindowBrightness(_window, 1.0f) == -1) sdlCheckError(); if (Config.isGrabMouse() && (!fullscreen || displays > 1)) { SDL_SetWindowGrab(_window, SDL_TRUE); } int screen = 0; int modes = SDL_GetNumDisplayModes(screen); info(LOG_CLIENT, "possible display modes:"); for (int i = 0; i < modes; i++) { SDL_GetDisplayMode(screen, i, &displayMode); name = SDL_GetPixelFormatName(displayMode.format); info(LOG_CLIENT, String::format("%dx%d@%dHz %s", displayMode.w, displayMode.h, displayMode.refresh_rate, name)); } // some platforms may override or hardcode the resolution - so // we have to query it here to get the actual resolution SDL_GetWindowSize(_window, &width, &height); if (SDL_SetRelativeMouseMode(SDL_TRUE) == -1) error(LOG_CLIENT, "no relative mouse mode support"); SDL_ShowCursor(0); info(LOG_CLIENT, String::format("actual resolution: %dx%d", width, height)); setVSync(ConfigManager::get().isVSync()); const int initState = IMG_Init(IMG_INIT_PNG); if (!(initState & IMG_INIT_PNG)) { sdlCheckError(); System.exit("No png support", 1); } _width = width; _height = height; updateViewport(0, 0, getWidth(), getHeight()); onInit(); _eventHandler = &eventHandler; _eventHandler->registerObserver(_console.get()); _eventHandler->registerObserver(this); info(LOG_CLIENT, "init the shader manager"); ShaderManager::get().init(); if (!Config.isSoundEnabled()) { info(LOG_CLIENT, "sound disabled"); } else if (!SoundControl.init(true)) { error(LOG_CLIENT, "sound initialization failed"); } return 0; }
// Open the X window to sample from bool InputWindowXWin::openLocalWindow() { int i; mXDisplay = XOpenDisplay(mXDisplayString.c_str()); // Open display on given XDisplay if (NULL == mXDisplay) { vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED, "ERROR") << ": [gadget::InputWindowXWin::openTheWindow()] " << "Failed to open display '" << mXDisplayString << "'" << std::endl << vprDEBUG_FLUSH; return 0; } mScreen = DefaultScreen(mXDisplay); XVisualInfo vTemplate, *vis_infos; long vMask = VisualScreenMask; vTemplate.screen = mScreen; int nVisuals; vis_infos = XGetVisualInfo(mXDisplay, vMask, &vTemplate, &nVisuals); // Verify that we got at least one visual from XGetVisualInfo(3). if ( vis_infos != NULL && nVisuals >= 1 ) { XVisualInfo* p_visinfo; // Try to find a visual with color depth of at least 8 bits. Having // such a visual ensures that the input windows at least have a // black background. for ( i = 0, p_visinfo = vis_infos; i < nVisuals; i++, p_visinfo++ ) { if ( p_visinfo->depth >= 8 ) { mVisual = p_visinfo; break; } } // If we couldn't find a visual with at least 8-bit color, just use the // first one in the list. if ( i == nVisuals ) { mVisual = vis_infos; } } // If we didn't get a matching visual, we're in trouble. else { vprDEBUG(vprDBG_ERROR,vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED,"ERROR") << ": [gadget::InputWindowXWin::openTheWindow()] find visual failed" << std::endl << vprDEBUG_FLUSH; return 0; } mSWA.colormap = XCreateColormap(mXDisplay, RootWindow(mXDisplay, mVisual->screen), mVisual->visual, AllocNone); mSWA.background_pixel = BlackPixel(mXDisplay, mScreen); mSWA.border_pixel = WhitePixel(mXDisplay, mScreen); const unsigned int event_mask = ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PointerMotionMask | StructureNotifyMask; mSWA.event_mask = event_mask; mXWindow = createWindow(DefaultRootWindow(mXDisplay), 1); createEmptyCursor(mXDisplay, mXWindow); setHints(mXWindow, const_cast<char*>(mInstName.c_str()), const_cast<char*>(mInstName.c_str()) , "VRJInputWindow", "VRJ Input Windows"); XSelectInput(mXDisplay, mXWindow, event_mask); XMapWindow(mXDisplay, mXWindow); XFlush(mXDisplay); XRaiseWindow(mXDisplay, mXWindow); XClearWindow(mXDisplay, mXWindow); // Try to clear the background vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL) << "[gadget::InputWindowXWin::openTheWindow()] done." << std::endl << vprDEBUG_FLUSH; XFree(vis_infos); return 1; }
QString FileLocationInfo::hint(FileType fileType) { if (hints.isEmpty()) setHints(); return hints[fileType]; }