Example #1
0
File: Ini.cpp Project: Ailick/rpcs3
static WindowInfo StringToWindowInfo(const wxString str)
{
	WindowInfo ret = WindowInfo(wxDefaultSize, wxDefaultPosition);

	wxString s[4] = {wxEmptyString};

	for(uint i=0, a=0; i<str.Length(); ++i)
	{
		if(!str(i, 1).CmpNoCase("x") || !str(i, 1).CmpNoCase(":"))
		{
			if(++a >= 4) return WindowInfo::GetDefault();
			continue;
		}

		s[a] += str(i, 1);
	}
	
	if(s[0].IsEmpty() || s[1].IsEmpty() || s[2].IsEmpty() || s[3].IsEmpty())
	{
		return WindowInfo::GetDefault();
	}

	s[0].ToLong((long*)&ret.size.x);
	s[1].ToLong((long*)&ret.size.y);
	s[2].ToLong((long*)&ret.position.x);
	s[3].ToLong((long*)&ret.position.y);

	if(ret.size.x <= 0 || ret.size.y <= 0)
	{
		return WindowInfo::GetDefault();
	}

	return ret;
}
  void CrossDelegate::run(int width, int height, int aaSamples, int depthBits)
  {
    initInfo.windowInfo = WindowInfo(width, height, aaSamples, depthBits);

    performInit(); // TODO: HANDLE FAILURES
    performSetup();
    performResize(setupInfo.windowInfo.size);

    sketch->performStart(CrossSketch::START_REASON_VIEW_SHOWN);

    while (!glfwWindowShouldClose(window))
    {
      intern::instance->processMouseEvents();
      intern::instance->processKeyEvents();
      intern::instance->processWheelEvents();

      performUpdate();
      performDraw();

      glfwSwapBuffers(window);

      intern::instance->clearMouseEvents();
      intern::instance->clearKeyEvents();
      intern::instance->clearWheelEvents();
      glfwPollEvents();
    }

    sketch->performStop(CrossSketch::STOP_REASON_VIEW_HIDDEN);

    performShutdown();
    performUninit();
  }
Example #3
0
/*static*/ WindowInfo WindowInfo::about (int64_t wid){
	HWND win = (HWND) (wid);
	WINDOWINFO info;
	GetWindowInfo(win, &info);

	bool isVisible = (info.dwStyle & WS_VISIBLE) != 0;

	if (isVisible) {
		char title [512] = "";
		GetWindowText (win, title, (sizeof title) - 1);

		DWORD process;
		GetWindowThreadProcessId (win, &process);


		WindowInfo dst;
		dst.title = title;
		dst.id    = (int64_t) win; // At least in Win7 Window Handles seem unique and could also be interpreted as IDs
		dst.pid   = process;
		dst.area  = dz::Rect(info.rcWindow.left, info.rcWindow.top, info.rcWindow.right - info.rcWindow.left, info.rcWindow.bottom - info.rcWindow.top);
		return dst;
	} else {
		// do not count invisible windows
		return WindowInfo ();
	}
}
Example #4
0
File: Ini.cpp Project: Bigpet/rpcs3
static WindowInfo StringToWindowInfo(const std::string& str)
{
	std::size_t start = 0, found;
	std::vector<int> vec;
	for (int i = 0; i < 4 && (found = str.find_first_of("x:", start)); i++) {
		try {
			vec.push_back(std::stoi(str.substr(start, found == std::string::npos ? found : found - start)));
		}
		catch (const std::invalid_argument& e) {
			return WindowInfo();
		}
		if (found == std::string::npos)
			break;
		start = found + 1;
	}
	if (vec.size() < 4 || vec[0] <= 0 || vec[1] <= 0 || vec[2] < 0 || vec[3] < 0)
		return WindowInfo();

	return WindowInfo(std::make_pair(vec[0], vec[1]), std::make_pair(vec[2], vec[3]));
}
Example #5
0
static WindowInfo StringToWindowInfo(const std::string& str)
{
	WindowInfo ret = WindowInfo(rDefaultSize, rDefaultSize);

	std::string s[4] = { "", "", "", "" };

	for (uint i = 0, a = 0; i<str.size(); ++i)
	{
		if (!fmt::CmpNoCase(str.substr(i, 1), "x") || !fmt::CmpNoCase(str.substr(i, 1), ":"))
		{
			if (++a >= 4) return WindowInfo::GetDefault();
			continue;
		}

		s[a] += str.substr(i, 1);
	}

	if (s[0].empty() || s[1].empty() || s[2].empty() || s[3].empty())
	{
		return WindowInfo::GetDefault();
	}

	try{
		ret.size.first = std::stoi(s[0]);
		ret.size.second = std::stoi(s[1]);
		ret.position.first = std::stoi(s[2]);
		ret.position.second = std::stoi(s[3]);
	}
	catch (const std::invalid_argument &e)
	{
		return WindowInfo::GetDefault();
	}
	if (ret.size.first <= 0 || ret.size.second <= 0)
	{
		return WindowInfo::GetDefault();
	}

	return ret;
}
  bool CrossDelegate::performInit()
  {
    if (!initialized_)
    {
      if (glfwInit())
      {
        glfwWindowHint(GLFW_SAMPLES, initInfo.windowInfo.aaSamples);
        glfwWindowHint(GLFW_DEPTH_BITS, initInfo.windowInfo.depthBits);
        glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
        glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);

        // ---

        int targetWidth;
        int targetHeight;

        if (initInfo.windowInfo.size.x * initInfo.windowInfo.size.y == 0)
        {
          GLFWmonitor* monitor = glfwGetPrimaryMonitor();

          if (monitor)
          {
            const GLFWvidmode *mode = glfwGetVideoMode(monitor);

            targetWidth = mode->width;
            targetHeight = mode->height;

            glfwWindowHint(GLFW_RED_BITS, mode->redBits);
            glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
            glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
            glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);

            window = glfwCreateWindow(targetWidth, targetHeight, "", monitor, NULL);
          }
        }
        else
        {
          targetWidth = initInfo.windowInfo.width;
          targetHeight = initInfo.windowInfo.height;

          window = glfwCreateWindow(targetWidth, targetHeight, "", NULL, NULL);
        }

        if (window)
        {
          setupInfo.windowInfo = WindowInfo(targetWidth, targetHeight, initInfo.windowInfo.aaSamples, initInfo.windowInfo.depthBits);

          glfwSetCursorPosCallback(window, cursorPosCallback);
          glfwSetMouseButtonCallback(window, mouseButtonCallback);
          glfwSetKeyCallback(window, keyCallback);
          glfwSetCharCallback(window, characterCallback);
          glfwSetScrollCallback(window, scrollCallback);

          glfwSwapInterval(1);
          glfwMakeContextCurrent(window);
          gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);

          // ---

          intern::instance = this;
          initialized_ = _init();
        }
      }
    }

    return initialized_;
  }
 foreach (Window window, g_windows) {
     newInfoWindowList.append(WindowInfo(window));
 }
 void WindowResource::doPOST(Descriptor& socket, HttpMessage& request, const char* remainingPath)
 {
     std::lock_guard<std::shared_mutex> lock(mutex);
     WindowInfo(window).raiseAndFocus();
     return sendStatus(socket, HttpCode::Http204);
 }