How to tell dwm to launch an app on the secondary screen - x11

I have the following rule in my dwm config file:
{ "Quodlibet", NULL, NULL, 1 << 4, False, -1 },
If instructs dwm to always launch an app titled Quodlibet on the fifth tag, a tag being the equivalent of a virtual desktop.
What if I wanted to have this app launched on a secondary screen?

The last element of the array determines which screen is used. Now, number the windows such the the primary monitor (the one sitting on the left) is 0. In effect, the line above would then be:
{ "Quodlibet", NULL, NULL, 1 << 4, False, 1 },

Related

How can I load the same icon as used by MessageBox on Windows 10?

On Windows 10 calling LoadIcon asking for the standard icon IDI_INFORMATION yields this icon:
On the other hand, calling MessageBox passing IDI_INFORMATION produces a dialog that uses this icon:
How can I obtain the second icon, if the obvious call to LoadIcon does not do so?
This feels like a bug in user32.dll but Windows 8 has the same issue so I guess Microsoft doesn't care.
You can get the flat icon used by MessageBox by calling SHGetStockIconInfo:
SHSTOCKICONINFO sii;
sii.cbSize = sizeof(sii);
if (SUCCEEDED(SHGetStockIconInfo(SIID_INFO, SHGSI_ICON|SHGSI_LARGEICON, &sii)))
{
// Use sii.hIcon here...
DestroyIcon(sii.hIcon);
}
SHGetStockIconInfo is the documented way to get icons used in the Windows UI on Vista and later. Most of the icons come from imageres.dll but you should not assume that this is the case...
we can try next code for test/demo
MSGBOXPARAMSW mbi = {
sizeof(mbi),
HWND_DESKTOP,
NULL,
L"lpszText",
L"lpszCaption",
MB_USERICON,
IDI_INFORMATION
};
MessageBoxIndirectW(&mbi);
if (HMODULE hmodImageRes = LoadLibraryEx(L"imageres", 0, LOAD_LIBRARY_AS_DATAFILE))
{
mbi.hInstance = hmodImageRes;
mbi.lpszIcon = MAKEINTRESOURCE(81);
MessageBoxIndirectW(&mbi);
FreeLibrary(hmodImageRes);
}
first message box use standard IDI_INFORMATION icon
when second the same icon on windows 7, and on windows 8.1 and windows 10.
are MAKEINTRESOURCE(81) from imageres.dll somehow documented and be stable - i doubt
so obtain the second icon you can by LoadIcon(hmodImageRes, MAKEINTRESOURCE(81)) where HMODULE hmodImageRes = LoadLibraryEx(L"imageres", 0, LOAD_LIBRARY_AS_DATAFILE) or simply LoadLibrary(L"imageres")

Set browserWindow Always on top, even other app is in fullscreen [Electron, MAC OS]

it's possible to use custom window level in Electron Framework, for make window always on top, even other apps is in fullscreen ?
For native MacOS apps i found this: https://stackoverflow.com/a/27397096/5838242
Where he saying:
window.level = Int(CGWindowLevelForKey(kCGMaximumWindowLevelKey))
On electron, i have a browser window:
mainWindow = new BrowserWindow({width: 1400, height: 50, resizable: false, alwaysOnTop: true, y: 0, x: 0, minimizable: false, title: 'CD App', frame: false, titleBarStyle: 'hidden', type: 'desktop' });
I know the 'type' parameter is the POINT, but this parameter have just two options:
On macOS, possible types are desktop, textured.
The textured type adds metal gradient appearance (NSTexturedBackgroundWindowMask).
The desktop type places the window at the desktop background window level (kCGDesktopWindowLevel - 1). Note that desktop window will not receive focus, keyboard or mouse events, but you can use globalShortcut to receive input sparingly.
So, any possibilities to do this thing ?
As of Electron 1.4.2 the setAlwaysOnTop() API takes an optional level parameter to adjust the window level, you'd use it like so:
mainWindow = new BrowserWindow({ ... });
mainWindow.setAlwaysOnTop(true, 'screen');
See the docs for all the possible values of the optional parameter, I'm not sure screen is the one you want in this case, you'll need to experiment.

How to detect if logon screen or UAC is active

I want to find a way to detect if logon screen or UAC is active within my service process. For example:
the screen on which a user needs to choose account and type in password to log on.
the screen on which a user needs to type in password after screensaver (locked screen?).
when a UAC pops up.
Right now I look through the session 1 and examine all the processes, if I could find logonui.exe, I thought either of the first two scenarios should happen. But in fact, this method can only detect
scenario 1.
winlogon.exe still exists after logon screen. So I can't use winlogon.exe as a search target.
According to this link, I think if I can find the current active (input) desktop name, default, screensaver or winlogon, I would be able to solve my question. So I followed swatkat's answer, and my code is like this
HWINSTA hs = GetProcessWindowStation();
HWINSTA hwinsta = OpenWindowStation("winsta0", FALSE, READ_CONTROL | WRITE_DAC);
SetProcessWindowStation(hwinsta);
HDESK hd = OpenInputDesktop(0, TRUE, GENERIC_READ | DESKTOP_READOBJECTS);
if (hd != NULL) {
DWORD size;
GetUserObjectInformation(hd, UOI_NAME, NULL, 0, &size);
TCHAR* name = (TCHAR*)alloca(size + sizeof(TCHAR));
GetUserObjectInformation(hd, UOI_NAME, name, size, &size);
CString result(name);
LOG((CLOG_DEBUG "input desktop name: %s %d", result.c_str(), size));
CloseDesktop(hd);
}
else {
LOG((CLOG_DEBUG "failed to call OpenInputDesktop"));
}
CloseWindowStation(hwinsta);
SetProcessWindowStation(hs);
This seems to always return "default" no matter which screen it's on.
I'm not really familiar with windows desktop and station, so if I did something wrong please let me know.
Thanks in advance.
Jerry

Showing a windows with XCB / Strange Behaviour

I'm trying to show a window in xcb, inside the main window, but actually without luck.
The idea is that when the user press a button (in that case the X button) a small white window is shown (just for test).
But actually i'm stuck on that step. I watched the example code here:
http://en.wikibooks.org/wiki/X_Window_Programming/XCB
And tried to do the same in my application.
[EDIT 28/10/2013] Now with that code i can show a window, but if i try to add other variable like int i=0, or whatever, the window doesn't appear, and no expose events were raised (all events that were raised are or 0 or 2 (even if i add the variables inside other events). Any idea?
This is the XCB_KEY_PRESS event handler code:
Edit (with the new code)
case XCB_KEY_PRESS:{
xcb_key_press_event_t *kp = (xcb_key_press_event_t *)ev;
if(kp->detail==53){
printf("X pressed\n");
uint32_t vals[2];
mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
vals[0]=screen->white_pixel;
vals[1]=XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS;
win = xcb_generate_id(connection);
xcb_create_window(
connection,
XCB_COPY_FROM_PARENT,
win,
root,
80,80,
150,150,
10,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
screen->root_visual,
mask, values);
mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
vals[0]=screen->white_pixel;
vals[1]=0;
background=xcb_generate_id(connection);
xcb_create_gc(connection, background, win, mask, vals);
xcb_map_window(connection,win);
xcb_flush(connection);
printf("finished\n");
}
printf("KEY_PRESS - Pressed: %d\n", kp->detail);
}
root is the root window obtained from xcb_screen_t variable.
The definition of background and win are the following:
xcb_window_t win;
xcb_gcontext_t background;
And i added even a XCB_EXPOSE event handler:
case XCB_EXPOSE:{
printf("EXPOSE NEW WINDOW CREATED\n");
xcb_poly_fill_rectangle(connection, win, background,1,&rectangle);
xcb_flush(connection);
}
What is wrong with that code? What am i missing? (I'm trying to develop a very basic window manager, just for fun)
(My idea for that program is that when x is pressed an input box is shown, do you have any suggestion on how to do that?)

my PROGRESS BAR redraws not all, WINAPI

in my application I am entering a loop of unknown number of elements,
so I am showing a progress bar to inform that application is running,
and this code works FINE, progres bar is refreshing independly:
do
{
...
SendMessage(hPBLoading, PBM_STEPIT, 0, 0);
...
} while(true);
but unfortunately the rest of window doesn't refresh (which is obvious due to the loop)
and in Windows 7 after a few seconds Windows treat my app like it break down, and it back and refresh after ending the loop,
so I figured out that I need to dispatch the message queue and I changed my code to this:
do
{
...
SendMessage(hPBLoading, PBM_STEPIT, 0, 0);
...
us_tmpBreakCounter++;
...
if (us_tmpBreakCounter >= 10)
{
us_tmpBreakCounter = 0;
UpdateSomeOtherElementsinWindow();
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) == TRUE)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
} while(true);
It works fine, the applcation is updated and refreshed after ex. 10 counts so its never break down,
but unfortunately another problem occured, now the PROGRESS BAR doesn't redraw fully - the beveled frame dissapears after a few seconds, check this image below:
http://mstanisz.website.pl/temp/progressbar_01.jpg
Thanks For Your Help!
m.
Seems like you're using a GUI thread to do some long task. That's not a good practice. When you want to perform long tasks, use a worker thread for that, and let the GUI thread handle the GUI while the worker works. You'll have to do some extra work taking care of synchronization between the two threads (stop the worker if the GUI is closed, avoid starting a task before the current one has ended and so on), but that's the way it works.

Resources