|
|
Home » U++ Library support » TopWindow&PopUp, TrayIcon » [FEATURE] Setting TopWindow to urgent/flashing state
[FEATURE] Setting TopWindow to urgent/flashing state [message #30883] |
Thu, 27 January 2011 16:50 |
|
Hi everyone
Today I realized that U++ provides no way how to set the window into the "flashing state" that is often used in applications (e.g. IM apps) to attract user attention in an unobtrusive manner (certainly less disturbing than bringing the window to foreground ).
So I propose to add methods Urgent(bool b = true) and IsUrgent() to TopWindow. The code is fairly simple:
In TopWindow.h:class TopWindow : public Ctrl {
// ...
bool frameless:1;
bool urgent:1; // added
byte state;
// ...
TopWindow& FrameLess(bool b = true) { frameless = b; return *this; }
bool IsFrameLess() const { return frameless; }
TopWindow& Urgent(bool b = true); // added
bool IsUrgent() const { return urgent; } // added
TopWindow& NoAccessKeysDistribution() { dokeys = false; return *this; }
TopWindow& NoCloseBox(bool b = true) { noclosebox = b; return *this; }
// ...
}
In TopWindow.cpp:TopWindow& TopWindow::Urgent(bool b)
{
GuiLock __;
urgent = b;
SyncCaption();
return *this;
}
In ToWinX11.cpp:void TopWindow::SyncCaption0()
{
// ...
wm_hints->flags = InputHint|WindowGroupHint|StateHint;
if(IsTopMost()) urgent = false; // added
if(urgent) wm_hints->flags |= XUrgencyHint; // added
wm_hints->initial_state = NormalState;
wm_hints->input = XTrue;
// ...
}
In TopWin32.cppvoid TopWindow::SyncCaption0()
{
// ...
if(hwnd) {
::SetWindowLong(hwnd, GWL_STYLE, style);
::SetWindowLong(hwnd, GWL_EXSTYLE, exstyle);
SyncTitle();
// added:
if(IsTopMost()) urgent = false;
FLASHWINFO fi;
fi.cbSize = sizeof(fi);
fi.hwnd = GetHWND();
fi.dwFlags = urgent?FLASHW_TIMERNOFG|FLASHW_ALL:FLASHW_STOP;
fi.uCount = 0;
fi.dwTimeout = 0;
FlashWindowEx(&fi);
}
// ...
}
The behavior should be fairly standard: If you call Urgent(true); then the window title and item in taskbar are flashing until either Urgent(false); is called or the window is taken to foreground. If Urgent(true); is called on active window then it has no effect. The win32 implementation might have some bugs, I didn't test it on windows (and it is not implemented correctly in wine ).
If you are wandering why I stumbled upon this, it is because it would be nice if theide would use it instead of popping up on finished builds and when breakpoint is hit when debugging.
Best regards,
Honza
[Updated on: Thu, 27 January 2011 17:12] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue May 07 17:17:45 CEST 2024
Total time taken to generate the page: 0.02292 seconds
|
|
|