예제 #1
0
파일: nDesk.cpp 프로젝트: alur/nModules
LRESULT WINAPI MessageHandlerProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) {
  switch (message) {
  case LM_GETREVID:
    return HandleGetRevId(gModule.name, gModule.version, lParam);

  case LM_REFRESH:
    LoadWorkareas();
    return 0;

  case LM_WALLPAPERCHANGE:
    sDesktopPane->UpdateWallpapers();
    return 0;

  case NCORE_DISPLAYS_CHANGED:
    sDesktopPane->UpdateWallpapers();
    LoadWorkareas();
    return 0;

  case WM_CREATE:
    SendMessage(GetLitestepWnd(), LM_REGISTERMESSAGE, WPARAM(window), LPARAM(sLsMessages));
    nCore::RegisterForMessages(window, sCoreMessages);
    sDesktopPane = new DesktopPane();
    LoadWorkareas();
    return 0;

  case WM_DESTROY:
    ClearWorkareas();
    SAFEDELETE(sDesktopPane);
    nCore::UnregisterForMessages(window, sCoreMessages);
    SendMessage(GetLitestepWnd(), LM_UNREGISTERMESSAGE, WPARAM(window), LPARAM(sLsMessages));
    return 0;
  }

  return DefWindowProc(window, message, wParam, lParam);
}
예제 #2
0
파일: lsapi.cpp 프로젝트: Vyrolan/litestep
//
// EnumLSData
//
// Return values:
//   E_INVALIDARG - Invalid value for uInfo
//   E_POINTER    - Invalid callback
//   E_FAIL       - Unspecified error
//   E_UNEXPECTED - Callback crashed or other catastrophic failure
//   S_OK         - Enumeration successful, callback always returned TRUE
//   S_FALSE      - Enumeration successful, but cancelled by callback
//
HRESULT EnumLSData(UINT uInfo, FARPROC pfnCallback, LPARAM lParam)
{
    HRESULT hr = E_INVALIDARG;
    
    if (NULL != pfnCallback)
    {
        switch (uInfo)
        {
        case ELD_BANGS:
            {
                //
                // Call EnumLSData recursively and let a small thunk handle
                // the translation from ELD_BANGS_V2 to ELD_BANGS
                //
                ENUMBANG_DATA data = { 0 };
                data.fnCallback = (LSENUMBANGSPROC)pfnCallback;
                data.lParam = lParam;
                
                hr = EnumLSData(ELD_BANGS_V2,
                    (FARPROC)EnumBangsThunk, (LPARAM)&data);
            }
            break;
            
        case ELD_BANGS_V2:
            {
                hr = g_LSAPIManager.GetBangManager()->
                    EnumBangs((LSENUMBANGSV2PROC)pfnCallback, lParam);
            }
            break;
            
        case ELD_REVIDS:
            {
                hr = (HRESULT)SendMessage(GetLitestepWnd(), LM_ENUMREVIDS,
                    (WPARAM)pfnCallback, lParam);
            }
            break;
            
        case ELD_MODULES:
            {
                hr = (HRESULT)SendMessage(GetLitestepWnd(), LM_ENUMMODULES,
                    (WPARAM)pfnCallback, lParam);
            }
            break;
            
        default:
            {
                // do nothing
            }
            break;
        }
    }
    else
    {
        hr = E_POINTER;
    }
    
    return hr;
}
예제 #3
0
void quitModule(HINSTANCE hInstance)
{
	RemoveBangCommand("!LabelCreate");
	RemoveBangCommand("!LabelDebug");
	RemoveBangCommand("!LabelLsBoxHook");

	for(LabelListIterator it = labelList.begin(); it != labelList.end(); it++)
		delete *it;

	labelList.clear();
	
	SendMessage(GetLitestepWnd(),
		LM_UNREGISTERMESSAGE,
		(WPARAM) messageHandler,
		(LPARAM) lsMessages);

	DestroyWindow(messageHandler);

	UnregisterClass("LabelLS", hInstance);
	UnregisterClass("LabelMessageHandlerLS", hInstance);

	delete systemInfo;
	delete defaultSettings;

	hbmDesktop = (HBITMAP) SelectObject(hdcDesktop, hbmDesktop);
	DeleteDC(hdcDesktop);
	DeleteObject(hbmDesktop);
}
예제 #4
0
bool LabelManager::Create(HINSTANCE hInstance)
{
    // Save the DLL instance handle since we'll need it later
    mInstance = hInstance;
    
    // Create the window
    mWindow = CreateWindowEx(WS_EX_TOOLWINDOW,
        WINDOW_CLASS, NULL,
        WS_POPUP,
        0, 0,
        0, 0,
        NULL, NULL,
        hInstance, this);
    
    if (!mWindow)
    {
        TRACE2("%s: CreateWindowEx failed, GetLastError returns %d", MODULE_NAME, GetLastError());
        return false;
    }
    
    // Register for Litestep messages that we're interested in
    SendMessage(GetLitestepWnd(), LM_REGISTERMESSAGE, (WPARAM) mWindow, (LPARAM) gMessages);
    
    // Create the labels
    CreateLabels();
    
    return true;
}
//
// HideModules
//
void FullscreenMonitor::HideModules(HMONITOR hMonitor, HWND hWnd)
{
    if (m_bAutoHideModules)
    {
        ParseBangCommandW((HWND)hMonitor, L"!HideModules", nullptr);
    }
    PostMessage(GetLitestepWnd(), LM_FULLSCREENACTIVATED, (WPARAM) hMonitor, (LPARAM) hWnd);
}
예제 #6
0
void WindowMonitor::Stop() {
  sInitThread.join();
  SendMessage(GetLitestepWnd(), LM_UNREGISTERMESSAGE, (WPARAM)gWindow, (LPARAM)sWMMessages);
  KillTimer(gWindow, NCORE_TIMER_WINDOW_MAINTENANCE);
  sWindowData.clear();
  DestroyIcon(sDefaultIcon);
  sDefaultIcon = nullptr;
}
예제 #7
0
void WindowMonitor::Start() {
  sDefaultIcon = LoadIcon(nullptr, IDI_APPLICATION);
  SendMessage(GetLitestepWnd(), LM_REGISTERMESSAGE, (WPARAM)gWindow, (LPARAM)sWMMessages);
  SetTimer(gWindow, NCORE_TIMER_WINDOW_MAINTENANCE, 250, nullptr);

  sInitThread = std::thread([] () -> void {
    EnumDesktopWindows(nullptr, (WNDENUMPROC) [] (HWND window, LPARAM) -> BOOL {
      if (IsTaskbarWindow(window)) {
        PostMessage(gWindow, LM_WINDOWCREATED, (WPARAM)window, 0);
      }
      return TRUE;
    }, 0);
  });
}
예제 #8
0
/*
	Wrapper around the standard ls createWindow to get the parent
	and style right for ontop/desktop etc.
*/
BOOL GuiWindow::CreateWnd(LPCSTR szWCName)
{
	HWND desktop = WinUtils::GetDesktopHWND();
	HWND liteStep = GetLitestepWnd();
	BOOL ok;

	_LSLogPrintf(LOG_DEBUG, szLogName, "ontop: %d, visible: %d, wharf: %d, boxed: %d", bOnTop, bVisible, bInWharf, bLsBoxed);

	ok = createWindow(WS_EX_TOOLWINDOW, szWCName, bInWharf ? WS_CHILD : WS_POPUP,
		nXPos, nYPos, nWidth, nHeight, bInWharf ? hwndParent : (bOnTop ? NULL : desktop));

	FixVisibility();

	return ok;
}
예제 #9
0
extern "C" int __cdecl initModuleEx(HWND parentWnd, HINSTANCE dllInst, LPCSTR szPath)
{
	hInstance = dllInst;

	WNDCLASSEX wcex;
	ZeroMemory(&wcex, sizeof(wcex));
	wcex.cbSize = sizeof(WNDCLASSEX);
	wcex.style = CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc = (WNDPROC)PlainWndProc;
	wcex.cbClsExtra = 0;
	wcex.cbWndExtra = 0;
	wcex.hInstance = hInstance;
	wcex.hIcon = NULL;
	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground = NULL;
	wcex.lpszMenuName = NULL;
	wcex.lpszClassName = className;
	wcex.hIconSm = NULL;

	if (!RegisterClassEx(&wcex)) {
		reportError("Error registering LSActiveDesktop window class");
		return 1;
	}

	readSettings();

	hMain = CreateWindowEx(0, className, _T("WindowLSActiveDesktop"), 0, 0, 0,
		0, 0, HWND_MESSAGE, NULL, hInstance, NULL);

	if (hMain == NULL) {
		reportError("Error creating LSActiveDesktop window");
		UnregisterClass(className, dllInst);
		return 1;
	}

	// Register message for version info
	UINT msgs[] = {LM_GETREVID, LM_REFRESH, 0};
	SendMessage(GetLitestepWnd(), LM_REGISTERMESSAGE, (WPARAM)hMain, (LPARAM)msgs);

	lsad = new LSAD(hInstance, hMain, &settings);

	DWORD tID;
	HANDLE hThread = CreateThread(NULL, 0, LSAD::ThreadEntry, lsad, 0, &tID);

	return 0;
}
예제 #10
0
//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
extern "C" int initModuleEx(HWND hwndParent, HINSTANCE hInstance, const char *path) {
	WNDCLASSEX wc;

	wc.cbSize        = sizeof(WNDCLASSEX);
	wc.style         = 0;
	wc.lpfnWndProc   = WndProc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = hInstance;
	wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = className;
	wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

	if(!RegisterClassEx(&wc)) {
		MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
		return 0;
	}

	hwnd = CreateWindowEx(
		WS_EX_TOOLWINDOW,
		className,
		"bbPlugLdr", //Window title
		WS_OVERLAPPEDWINDOW | WS_VISIBLE,
		CW_USEDEFAULT, CW_USEDEFAULT, 240, 140,
		NULL, NULL, hInstance, NULL);

	if(hwnd == NULL) {
		UnregisterClass(className, hInstance);
		MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
		return 0;
	}

	//ShowWindow(hwnd, true);

	// Register for Litestep messages that we're interested in
	SendMessage(GetLitestepWnd(), LM_REGISTERMESSAGE, reinterpret_cast<WPARAM>(hwnd), reinterpret_cast<LPARAM>(lsMessages));

	//Only needed for "stickyness"
	//SetWindowLongPtr(hwnd, GWLP_USERDATA, magicDWord);

	return 0;
}
예제 #11
0
extern "C" void __cdecl quitModule(HINSTANCE dllInst)
{
	RemoveBangCommand("!LSActiveDesktopNavigate");
	RemoveBangCommand("!LSActiveDesktopRunJSFunction");
	RemoveBangCommand("!LSActiveDesktopBack");
	RemoveBangCommand("!LSActiveDesktopForward");
	RemoveBangCommand("!LSActiveDesktopRefresh");
	RemoveBangCommand("!LSActiveDesktopRefreshCache");

	UINT msgs[] = {LM_GETREVID, LM_REFRESH, 0};
	SendMessage(GetLitestepWnd(), LM_UNREGISTERMESSAGE, (WPARAM)hMain, (LPARAM)msgs);

	delete lsad;

	if (hMain != NULL)
	{
		DestroyWindow(hMain);
		hMain = NULL;
	}

	UnregisterClass(className, dllInst);
}
//
// Start
//
HRESULT TaskbarListHandler::Start(HWND hWndTray) {
    HRESULT hr = E_FAIL;
    
    m_hLiteStep = GetLitestepWnd();
    GetWindowThreadProcessId(m_hLiteStep, &m_dwLiteStepProc);
    m_hInstance = GetModuleHandle(NULL);

    WNDCLASSEX wndClass;
    ZeroMemory(&wndClass, sizeof(WNDCLASSEX));
    wndClass.cbSize = sizeof(WNDCLASSEX);
    wndClass.cbWndExtra = sizeof(TaskbarListHandler*);
    wndClass.lpszClassName = _T("taskbandHWNDClass");
    wndClass.lpfnWndProc = &TaskbarListHandler::WindowProcedureInit;
    wndClass.hInstance = m_hInstance;
    wndClass.style = CS_NOCLOSE;

    m_aWndClass = RegisterClassEx(&wndClass);
    if (m_aWndClass == 0)
    {
        hr = HrGetLastError();
    }
    else
    {
        m_hWndTaskband = CreateWindowEx(WS_EX_TOOLWINDOW, (LPCTSTR)m_aWndClass, _T("taskbandHWND"), WS_CHILD, 0, 0, 100, 100, hWndTray, nullptr, m_hInstance, this);
        if (m_hWndTaskband == nullptr)
        {
            hr = HrGetLastError();
        }
        else
        {
            WM_ShellHook = RegisterWindowMessage(_T("SHELLHOOK"));
            SetProp(hWndTray, _T("TaskbandHWND"), m_hWndTaskband);
            hr = S_OK;
        }
    }

    return hr;
}
예제 #13
0
void LabelManager::Destroy()
{
    // Destroy all the labels
    for (int i = 0; i < mNumLabels; i++)
    {
        if (mLabels[i])
        {
            mLabels[i]->Destroy();
            delete mLabels[i];
            mLabels[i] = NULL;
        }
    }
    
    mNumLabels = 0;
    
    if (mWindow)
    {
        // Unregister Litestep messages
        SendMessage(GetLitestepWnd(), LM_UNREGISTERMESSAGE, (WPARAM) mWindow, (LPARAM) gMessages);
        
        // Destroy the window
        DestroyWindow(mWindow);
    }
}
//
// ThreadProc
//
void FullscreenMonitor::ThreadProc()
{
    
#if defined(_DEBUG)
    DbgSetCurrentThreadName("LS FullscreenMonitor Service");
#endif

    //
    struct FSWindow {
        FSWindow(HWND hWnd, HMONITOR hMonitor) {
            this->hWnd = hWnd;
            this->hMonitor = hMonitor;
        }
        HWND hWnd;
        HMONITOR hMonitor;
    };

    // List of all currently living known fullscreen windows
    std::list<FSWindow> fullscreenWindows;

    // The monitors which currently have modules hidden
    std::unordered_multiset<HMONITOR> hiddenMonitors;

    DWORD dwLiteStepProcID;
    GetWindowThreadProcessId(GetLitestepWnd(), &dwLiteStepProcID);

    // On startup, find any existing fullscreen windows.
    EnumDesktopWindows(nullptr, [] (HWND hWnd, LPARAM lParam) -> BOOL
    {
        HMONITOR hMonitor = IsFullscreenWindow(hWnd);
        std::list<FSWindow> *fullscreenWindows = (std::list<FSWindow>*)lParam;
        if (hMonitor)
        {
            // And add it to the list of fullscreen windows.
            fullscreenWindows->push_back(FSWindow(hWnd, hMonitor));
        }
        return TRUE;
    }, (LPARAM)&fullscreenWindows);

    // Hide modules on any monitor we found
    for (FSWindow window : fullscreenWindows)
    {
        hiddenMonitors.insert(window.hMonitor);
        if (hiddenMonitors.count(window.hMonitor) == 1)
        {
            HideModules(window.hMonitor, window.hWnd);
        }
    }

    // Main Loop
    while (m_bRun.load())
    {
        HWND hwndForeGround = GetForegroundWindow();
        bool bCheckedForeGround = false;

        // Re-Hide modules on all monitors
        if (m_bReHide.load())
        {
            hiddenMonitors.clear();
            for (FSWindow window : fullscreenWindows)
            {
                hiddenMonitors.insert(window.hMonitor);
                if (hiddenMonitors.count(window.hMonitor) == 1)
                {
                    HideModules(window.hMonitor, window.hWnd);
                }
            }
        }

        // Verify that all currently known fullscreen windows are still fullscreen.
        std::list<FSWindow>::iterator iter = fullscreenWindows.begin();
        while (iter != fullscreenWindows.end())
        {
            HMONITOR hNewMonitor = IsFullscreenWindow(iter->hWnd);

            // If we already checked the foreground window, don't bother doing it again.
            if (iter->hWnd == hwndForeGround)
            {
                bCheckedForeGround = true;
            }

            // 
            if (hNewMonitor != iter->hMonitor)
            {
                hiddenMonitors.erase(iter->hMonitor);

                // If there are no fullscreen windows left on the monitor, show the modules
                if (hiddenMonitors.count(iter->hMonitor) == 0)
                {
                    ShowModules(iter->hMonitor);
                }

                // Check if the window moved to another monitor (and stayed fullscreen)
                if (hNewMonitor)
                {
                    iter->hMonitor = hNewMonitor;
                    hiddenMonitors.insert(hNewMonitor);
                    if (hiddenMonitors.count(hNewMonitor) == 1)
                    {
                        HideModules(hNewMonitor, iter->hWnd);
                    }
                }
                else
                {
                    iter = fullscreenWindows.erase(iter);
                    continue;
                }
            }

            ++iter;
        }

        // Check if the currently active window is a fullscreen window.
        if (!bCheckedForeGround)
        {
            // If the currently active window belongs to litestep, show all modules.
            DWORD dwProcID;
            GetWindowThreadProcessId(hwndForeGround, &dwProcID);
            if (dwProcID == dwLiteStepProcID)
            {
                if (!hiddenMonitors.empty())
                {
                    for (HMONITOR hMonitor : hiddenMonitors)
                    {
                        ShowModules(hMonitor);
                    }
                    hiddenMonitors.clear();
                    fullscreenWindows.clear();
                }
            }
            else
            {
                HMONITOR hMonitor = IsFullscreenWindow(hwndForeGround);
                if (hMonitor)
                {
                    // Add the window to the list of known foreground windows.
                    fullscreenWindows.push_back(FSWindow(hwndForeGround, hMonitor));
                    hiddenMonitors.insert(hMonitor);

                    // If we didn't know about any fullscreen windows on this monitor before, hide the modules on it.
                    if (hiddenMonitors.count(hMonitor) == 1)
                    {
                        HideModules(hMonitor, hwndForeGround);
                    }
                }
            }
        }

        // Avoid using excesive amounts of CPU time
        std::this_thread::sleep_for(m_workerSleepDuration);
    }
}
예제 #15
0
int initModuleEx(HWND hParent, HINSTANCE hInstance, const char *lsPath)
{
	WNDCLASSEX wc;

	wc.cbSize = sizeof(WNDCLASSEX);
	wc.style = CS_GLOBALCLASS | CS_DBLCLKS;
	wc.lpfnWndProc = Label::windowProcedure;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = sizeof(Label *);
	wc.hInstance = hInstance;
	wc.hbrBackground = 0;
	wc.hCursor = LoadCursor(0, IDC_ARROW);
	wc.hIcon = 0;
	wc.lpszMenuName = 0;
	wc.lpszClassName = "LabelLS";
	wc.hIconSm = 0;

	RegisterClassEx(&wc);

	wc.cbSize = sizeof(WNDCLASSEX);
	wc.style = CS_GLOBALCLASS;
	wc.lpfnWndProc = MessageHandlerProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hbrBackground = 0;
	wc.hCursor = 0;
	wc.hIcon = 0;
	wc.lpszMenuName = 0;
	wc.lpszClassName = "LabelMessageHandlerLS";
	wc.hIconSm = 0;

	RegisterClassEx(&wc);

	messageHandler = CreateWindowEx(WS_EX_TOOLWINDOW,
		"LabelMessageHandlerLS",
		0,
		WS_POPUP,
		0, 0, 0, 0, 
		0,
		0,
		hInstance,
		0);

	if (!messageHandler)
		return 1;
	
	SendMessage(GetLitestepWnd(),
		LM_REGISTERMESSAGE,
		(WPARAM) messageHandler,
		(LPARAM) lsMessages);

	::hInstance = hInstance;
	defaultSettings = new LabelSettings();
	systemInfo = new SystemInfo();

	StringList labelNames = GetRCNameList("Labels");
	labelNames.merge(GetRCNameList("Label"));
//	if(labelNames.empty()) labelNames.insert(labelNames.end(), "Label");

	for(StringListIterator it = labelNames.begin(); it != labelNames.end(); it++)
	{
		if(GetRCBoolean(*it, "LSBoxName"))
			continue;

		Label *label = new Label(*it);
		label->load(hInstance);
		labelList.insert(labelList.end(), label);
	}

	AddBangCommand("!LabelCreate", CreateLabelBangCommand);
	AddBangCommand("!LabelDebug", DebugBangCommand);
	//LsBox Support - blkhawk
	AddBangCommand("!LabelLsBoxHook", LsBoxHookBangCommand);

	return 0;
}
HRESULT TShellDesktopTray::GetTrayWindow(HWND *hTrayWnd)
{
    *hTrayWnd = GetLitestepWnd();
    return S_OK;
}