mirror of https://github.com/adamdruppe/arsd.git
really crappy balloon notification impl for X
This commit is contained in:
parent
5704e0f08a
commit
c058c5fb99
|
@ -920,11 +920,12 @@ enum WindowTypes : int {
|
||||||
dropdownMenu,
|
dropdownMenu,
|
||||||
/// A popup menu, such as from a right click
|
/// A popup menu, such as from a right click
|
||||||
popupMenu,
|
popupMenu,
|
||||||
|
/// A popup bubble notification
|
||||||
|
notification,
|
||||||
/*
|
/*
|
||||||
menu, /// a tearable menu bar
|
menu, /// a tearable menu bar
|
||||||
splashScreen, /// a loading splash screen for your application
|
splashScreen, /// a loading splash screen for your application
|
||||||
tooltip, /// A tiny window showing temporary help text or something.
|
tooltip, /// A tiny window showing temporary help text or something.
|
||||||
notification, /// A popup bubble notification
|
|
||||||
comboBoxDropdown,
|
comboBoxDropdown,
|
||||||
dialog,
|
dialog,
|
||||||
toolbar
|
toolbar
|
||||||
|
@ -2479,6 +2480,45 @@ version(X11) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SimpleWindow balloon;
|
||||||
|
private Timer timer;
|
||||||
|
|
||||||
|
void showBalloon(string title, string message, MemoryImage icon = null) {
|
||||||
|
|
||||||
|
if(balloon) {
|
||||||
|
hideBalloon();
|
||||||
|
}
|
||||||
|
balloon = new SimpleWindow(180, 120, null, OpenGlOptions.no, Resizability.fixedSize, WindowTypes.notification, WindowFlags.dontAutoShow/*, window*/);
|
||||||
|
|
||||||
|
int x, y, width, height;
|
||||||
|
getWindowRect(x, y, width, height);
|
||||||
|
|
||||||
|
balloon.move(x - balloon.width, y - balloon.height);
|
||||||
|
auto painter = balloon.draw();
|
||||||
|
painter.fillColor = Color(220, 220, 220);
|
||||||
|
painter.outlineColor = Color.black;
|
||||||
|
painter.drawRectangle(Point(0, 0), balloon.width, balloon.height);
|
||||||
|
painter.drawText(Point(4, 4), title);
|
||||||
|
painter.drawText(Point(4, 4 + painter.fontHeight * 2), message);
|
||||||
|
balloon.setEventHandlers(
|
||||||
|
(MouseEvent ev) {
|
||||||
|
if(ev.type == MouseEventType.buttonPressed) {
|
||||||
|
hideBalloon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
balloon.show();
|
||||||
|
|
||||||
|
timer = new Timer(10_000, &hideBalloon);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hideBalloon() {
|
||||||
|
balloon.close();
|
||||||
|
timer.destroy();
|
||||||
|
balloon = null;
|
||||||
|
timer = null;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
void redraw() {
|
void redraw() {
|
||||||
if (!active) return;
|
if (!active) return;
|
||||||
|
@ -2846,17 +2886,8 @@ version(X11) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
version(D_Ddoc) {
|
|
||||||
/// Platform-specific for Windows. Sends a string as key press and release events to the actively focused window (not necessarily your application)
|
|
||||||
void sendSyntheticInput(wstring s);
|
|
||||||
/// Platform-specific for Windows. Registers a global hotkey. Returns a registration ID.
|
|
||||||
int registerHotKey(SimpleWindow window, uint modifiers, uint vk, void delegate() handler);
|
|
||||||
/// Platform-specific for Windows. Unregisters a key. The id is the value returned by registerHotKey.
|
|
||||||
void unregisterHotKey(SimpleWindow window, int id);
|
|
||||||
}
|
|
||||||
|
|
||||||
version(Windows) {
|
version(Windows) {
|
||||||
/// Platform-specific
|
/// Platform-specific for Windows. Sends a string as key press and release events to the actively focused window (not necessarily your application)
|
||||||
void sendSyntheticInput(wstring s) {
|
void sendSyntheticInput(wstring s) {
|
||||||
INPUT[] inputs;
|
INPUT[] inputs;
|
||||||
inputs.reserve(s.length * 2);
|
inputs.reserve(s.length * 2);
|
||||||
|
@ -3078,7 +3109,7 @@ version(Windows) {
|
||||||
|
|
||||||
// global hotkey helper function
|
// global hotkey helper function
|
||||||
|
|
||||||
/// Platform-specific for Windows
|
/// Platform-specific for Windows. Registers a global hotkey. Returns a registration ID.
|
||||||
int registerHotKey(SimpleWindow window, UINT modifiers, UINT vk, void delegate() handler) {
|
int registerHotKey(SimpleWindow window, UINT modifiers, UINT vk, void delegate() handler) {
|
||||||
__gshared int hotkeyId = 0;
|
__gshared int hotkeyId = 0;
|
||||||
int id = ++hotkeyId;
|
int id = ++hotkeyId;
|
||||||
|
@ -3117,7 +3148,7 @@ version(Windows) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Platform-specific for Windows
|
/// Platform-specific for Windows. Unregisters a key. The id is the value returned by registerHotKey.
|
||||||
void unregisterHotKey(SimpleWindow window, int id) {
|
void unregisterHotKey(SimpleWindow window, int id) {
|
||||||
if(!UnregisterHotKey(window.impl.hwnd, id))
|
if(!UnregisterHotKey(window.impl.hwnd, id))
|
||||||
throw new Exception("UnregisterHotKey");
|
throw new Exception("UnregisterHotKey");
|
||||||
|
@ -5173,6 +5204,7 @@ version(Windows) {
|
||||||
break;
|
break;
|
||||||
case WindowTypes.dropdownMenu:
|
case WindowTypes.dropdownMenu:
|
||||||
case WindowTypes.popupMenu:
|
case WindowTypes.popupMenu:
|
||||||
|
case WindowTypes.notification:
|
||||||
style = WS_POPUP | WS_SYSMENU | WS_BORDER;
|
style = WS_POPUP | WS_SYSMENU | WS_BORDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6623,7 +6655,7 @@ version(X11) {
|
||||||
if(opengl == OpenGlOptions.no) {
|
if(opengl == OpenGlOptions.no) {
|
||||||
|
|
||||||
bool overrideRedirect = false;
|
bool overrideRedirect = false;
|
||||||
if(windowType == WindowTypes.dropdownMenu || windowType == WindowTypes.popupMenu)
|
if(windowType == WindowTypes.dropdownMenu || windowType == WindowTypes.popupMenu || windowType == WindowTypes.notification)
|
||||||
overrideRedirect = true;
|
overrideRedirect = true;
|
||||||
|
|
||||||
XSetWindowAttributes swa;
|
XSetWindowAttributes swa;
|
||||||
|
@ -6729,6 +6761,11 @@ version(X11) {
|
||||||
setNetWMWindowType(GetAtom!"_NET_WM_WINDOW_TYPE_POPUP_MENU"(display));
|
setNetWMWindowType(GetAtom!"_NET_WM_WINDOW_TYPE_POPUP_MENU"(display));
|
||||||
customizationFlags |= WindowFlags.skipTaskbar | WindowFlags.alwaysOnTop;
|
customizationFlags |= WindowFlags.skipTaskbar | WindowFlags.alwaysOnTop;
|
||||||
break;
|
break;
|
||||||
|
case WindowTypes.notification:
|
||||||
|
motifHideDecorations();
|
||||||
|
setNetWMWindowType(GetAtom!"_NET_WM_WINDOW_TYPE_NOTIFICATION"(display));
|
||||||
|
customizationFlags |= WindowFlags.skipTaskbar | WindowFlags.alwaysOnTop;
|
||||||
|
break;
|
||||||
/+
|
/+
|
||||||
case WindowTypes.menu:
|
case WindowTypes.menu:
|
||||||
atoms[0] = GetAtom!"_NET_WM_WINDOW_TYPE_MENU"(display);
|
atoms[0] = GetAtom!"_NET_WM_WINDOW_TYPE_MENU"(display);
|
||||||
|
|
Loading…
Reference in New Issue