mirror of https://github.com/adamdruppe/arsd.git
a little bit less bad handling of the popup menus
This commit is contained in:
parent
7198a9f15e
commit
05eadcb732
6
apng.d
6
apng.d
|
@ -46,7 +46,7 @@ unittest {
|
|||
writeApngToFile(apng, "/home/me/test.apng");
|
||||
}
|
||||
|
||||
version(Demo) main(); // remove from docs
|
||||
version(Demo) main(); // exclude from docs
|
||||
}
|
||||
|
||||
/// Demo reading and rendering
|
||||
|
@ -103,8 +103,8 @@ unittest {
|
|||
// writeApngToFile(a, "/home/me/test.apng");
|
||||
}
|
||||
|
||||
version(Demo) main(["", "/home/me/test.apng"]); // remove from docs
|
||||
//version(Demo) main(["", "/home/me/small-clouds.png"]); // remove from docs
|
||||
version(Demo) main(["", "/home/me/test.apng"]); // exclude from docs
|
||||
//version(Demo) main(["", "/home/me/small-clouds.png"]); // exclude from docs
|
||||
}
|
||||
|
||||
import arsd.png;
|
||||
|
|
|
@ -331,7 +331,7 @@ abstract class ComboboxBase : Widget {
|
|||
auto coord = this.globalCoordinates();
|
||||
auto dropDown = new SimpleWindow(
|
||||
w, h,
|
||||
null, OpenGlOptions.no, Resizability.fixedSize, WindowTypes.dropdownMenu, WindowFlags.dontAutoShow/*, window*/);
|
||||
null, OpenGlOptions.no, Resizability.fixedSize, WindowTypes.dropdownMenu, WindowFlags.dontAutoShow, parentWindow ? parentWindow.win : null);
|
||||
|
||||
dropDown.move(coord.x, coord.y + this.height);
|
||||
|
||||
|
@ -5246,7 +5246,7 @@ class MainWindow : Window {
|
|||
if(menu.name in mcs) {
|
||||
mc = mcs[menu.name];
|
||||
} else {
|
||||
mc = new Menu(menu.name);
|
||||
mc = new Menu(menu.name, this);
|
||||
menuBar.addItem(mc);
|
||||
mcs[menu.name] = mc;
|
||||
}
|
||||
|
@ -6163,7 +6163,7 @@ class Menu : Window {
|
|||
}
|
||||
dropDown = new SimpleWindow(
|
||||
150, 4,
|
||||
null, OpenGlOptions.no, Resizability.fixedSize, WindowTypes.dropdownMenu, WindowFlags.dontAutoShow/*, window*/);
|
||||
null, OpenGlOptions.no, Resizability.fixedSize, WindowTypes.dropdownMenu, WindowFlags.dontAutoShow, parent ? parent.parentWindow.win : null);
|
||||
|
||||
this.label = label;
|
||||
|
||||
|
|
|
@ -8,11 +8,49 @@
|
|||
// on Mac with X11: -L-L/usr/X11/lib
|
||||
|
||||
/+
|
||||
|
||||
* I might need to set modal hints too _NET_WM_STATE_MODAL and make sure that TRANSIENT_FOR legit works
|
||||
|
||||
Progress bar in taskbar
|
||||
- i can probably just set a property on the window...
|
||||
it sets that prop to an integer 0 .. 100. Taskbar
|
||||
deletes it or window deletes it when it is handled.
|
||||
- prolly display it as a nice little line at the bottom.
|
||||
|
||||
|
||||
from gtk:
|
||||
|
||||
#define PROGRESS_HINT "_NET_WM_XAPP_PROGRESS"
|
||||
#define PROGRESS_PULSE_HINT "_NET_WM_XAPP_PROGRESS_PULSE"
|
||||
|
||||
>+ if (cardinal > 0)
|
||||
>+ {
|
||||
>+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
|
||||
>+ xid,
|
||||
>+ gdk_x11_get_xatom_by_name_for_display (display, atom_name),
|
||||
>+ XA_CARDINAL, 32,
|
||||
>+ PropModeReplace,
|
||||
>+ (guchar *) &cardinal, 1);
|
||||
>+ }
|
||||
>+ else
|
||||
>+ {
|
||||
>+ XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
|
||||
>+ xid,
|
||||
>+ gdk_x11_get_xatom_by_name_for_display (display, atom_name));
|
||||
>+ }
|
||||
|
||||
from Windows:
|
||||
|
||||
see: https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-itaskbarlist3
|
||||
|
||||
interface
|
||||
CoCreateInstance( CLSID_TaskbarList, nullptr, CLSCTX_ALL, __uuidof(ITaskbarList3), (LPVOID*)&m_pTL3 );
|
||||
auto msg = RegisterWindowMessage(TEXT(“TaskbarButtonCreated”));
|
||||
listen for msg, return TRUE
|
||||
interface->SetProgressState(hwnd, TBPF_NORMAL);
|
||||
interface->SetProgressValue(hwnd, 40, 100);
|
||||
|
||||
|
||||
My new notification system.
|
||||
- use a unix socket? or a x property? or a udp port?
|
||||
- could of course also get on the dbus train but ugh.
|
||||
|
@ -1602,12 +1640,32 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon {
|
|||
keyboard = do you want to grab keyboard input?
|
||||
mouse = grab mouse input?
|
||||
confine = confine the mouse cursor to inside this window?
|
||||
|
||||
History:
|
||||
Prior to March 11, 2021, grabbing the keyboard would always also
|
||||
set the X input focus. Now, it only focuses if it is a non-transient
|
||||
window and otherwise manages the input direction internally.
|
||||
|
||||
This means spurious focus/blur events will no longer be sent and the
|
||||
application will not steal focus from other applications (which the
|
||||
window manager may have rejected anyway).
|
||||
+/
|
||||
void grabInput(bool keyboard = true, bool mouse = true, bool confine = false) {
|
||||
static if(UsingSimpledisplayX11) {
|
||||
XSync(XDisplayConnection.get, 0);
|
||||
if(keyboard)
|
||||
XSetInputFocus(XDisplayConnection.get, this.impl.window, RevertToParent, CurrentTime);
|
||||
if(keyboard) {
|
||||
if(isTransient && _parent) {
|
||||
/*
|
||||
FIXME:
|
||||
setting the keyboard focus is not actually that helpful, what I more likely want
|
||||
is the events from the parent window to be sent over here if we're transient.
|
||||
*/
|
||||
|
||||
_parent.inputProxy = this;
|
||||
} else {
|
||||
XSetInputFocus(XDisplayConnection.get, this.impl.window, RevertToParent, CurrentTime);
|
||||
}
|
||||
}
|
||||
if(mouse) {
|
||||
if(auto res = XGrabPointer(XDisplayConnection.get, this.impl.window, false /* owner_events */,
|
||||
EventMask.PointerMotionMask // FIXME: not efficient
|
||||
|
@ -1640,12 +1698,27 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon {
|
|||
} else static assert(0);
|
||||
}
|
||||
|
||||
private bool isTransient() {
|
||||
with(WindowTypes)
|
||||
final switch(windowType) {
|
||||
case normal, undecorated, eventOnly:
|
||||
case nestedChild:
|
||||
return (customizationFlags & WindowFlags.transient) ? true : false;
|
||||
case dropdownMenu, popupMenu, notification:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private SimpleWindow inputProxy;
|
||||
|
||||
/++
|
||||
Releases the grab acquired by [grabInput].
|
||||
+/
|
||||
void releaseInputGrab() {
|
||||
static if(UsingSimpledisplayX11) {
|
||||
XUngrabPointer(XDisplayConnection.get, CurrentTime);
|
||||
if(_parent)
|
||||
_parent.inputProxy = null;
|
||||
} else version(Windows) {
|
||||
ReleaseCapture();
|
||||
ClipCursor(null);
|
||||
|
@ -12592,7 +12665,7 @@ mixin DynamicLoad!(XRender, "Xrender", 1, false, true) XRenderLibrary;
|
|||
&pid,
|
||||
1);
|
||||
|
||||
if(customizationFlags & WindowFlags.transient) {
|
||||
if(isTransient && parent) { // customizationFlags & WindowFlags.transient) {
|
||||
if(parent is null) assert(0);
|
||||
XChangeProperty(
|
||||
display,
|
||||
|
@ -13330,6 +13403,11 @@ version(X11) {
|
|||
|
||||
if (auto win = e.xkey.window in SimpleWindow.nativeMapping) {
|
||||
ke.window = *win;
|
||||
|
||||
|
||||
if(win.inputProxy)
|
||||
win = &win.inputProxy;
|
||||
|
||||
if (win.handleKeyEvent) {
|
||||
XUnlockDisplay(display);
|
||||
scope(exit) XLockDisplay(display);
|
||||
|
|
24
terminal.d
24
terminal.d
|
@ -4641,6 +4641,9 @@ class LineGetter {
|
|||
|
||||
Default is to provide recent command history as autocomplete.
|
||||
|
||||
$(WARNING Both `candidate` and `afterCursor` may have private data packed into the dchar bits
|
||||
if you enabled [enableAutoCloseBrackets]. Use `ch & ~PRIVATE_BITS_MASK` to get standard dchars.)
|
||||
|
||||
Returns:
|
||||
This function should return the full string to replace
|
||||
`candidate[tabCompleteStartPoint(args) .. $]`.
|
||||
|
@ -4681,6 +4684,9 @@ class LineGetter {
|
|||
is `0`, always completing the complete line, but you may return the index of another
|
||||
character of `candidate` to provide a new split.
|
||||
|
||||
$(WARNING Both `candidate` and `afterCursor` may have private data packed into the dchar bits
|
||||
if you enabled [enableAutoCloseBrackets]. Use `ch & ~PRIVATE_BITS_MASK` to get standard dchars.)
|
||||
|
||||
Returns:
|
||||
The index of `candidate` where we should start the slice to keep in [tabComplete].
|
||||
It must be `>= 0 && <= candidate.length`.
|
||||
|
@ -4713,7 +4719,7 @@ class LineGetter {
|
|||
|
||||
foreach(item; list) {
|
||||
import std.algorithm;
|
||||
if(startsWith(item, line[start .. cursorPosition]))
|
||||
if(startsWith(item, line[start .. cursorPosition].map!(x => x & ~PRIVATE_BITS_MASK)))
|
||||
f ~= item;
|
||||
}
|
||||
|
||||
|
@ -4820,6 +4826,9 @@ class LineGetter {
|
|||
}
|
||||
|
||||
/++
|
||||
$(WARNING `line` may have private data packed into the dchar bits
|
||||
if you enabled [enableAutoCloseBrackets]. Use `ch & ~PRIVATE_BITS_MASK` to get standard dchars.)
|
||||
|
||||
History:
|
||||
Introduced on January 30, 2020
|
||||
+/
|
||||
|
@ -5022,6 +5031,9 @@ class LineGetter {
|
|||
`currentCursorPosition` is passed in case you want to do things like highlight a matching parenthesis over
|
||||
the cursor or similar. You can also simply ignore it.
|
||||
|
||||
$(WARNING `line` may have private data packed into the dchar bits
|
||||
if you enabled [enableAutoCloseBrackets]. Use `ch & ~PRIVATE_BITS_MASK` to get standard dchars.)
|
||||
|
||||
History:
|
||||
Added January 25, 2021 (version 9.2)
|
||||
+/
|
||||
|
@ -7667,6 +7679,7 @@ version(TerminalDirectToEmulator) {
|
|||
if(atBottom) {
|
||||
tew.terminalEmulator.notifyScrollbarPosition(0, int.max);
|
||||
tew.terminalEmulator.scrollbackTo(0, int.max);
|
||||
tew.terminalEmulator.drawScrollback();
|
||||
tew.redraw();
|
||||
}
|
||||
}
|
||||
|
@ -7714,6 +7727,8 @@ version(TerminalDirectToEmulator) {
|
|||
dialog((FilterParams p) {
|
||||
auto nw = new TerminalEmulatorWindow(null, this);
|
||||
|
||||
nw.parentWindow.win.handleCharEvent = null; // kinda a hack... i just don't want it ever turning off scroll lock...
|
||||
|
||||
nw.parentFilter = (TerminalEmulator.TerminalCell[] line) {
|
||||
import std.algorithm;
|
||||
import std.uni;
|
||||
|
@ -7728,10 +7743,11 @@ version(TerminalDirectToEmulator) {
|
|||
};
|
||||
|
||||
foreach(line; tew.terminalEmulator.sbb[0 .. $]) {
|
||||
if(auto l = nw.parentFilter(line))
|
||||
if(auto l = nw.parentFilter(line)) {
|
||||
nw.tew.terminalEmulator.addScrollbackLine(l);
|
||||
}
|
||||
}
|
||||
nw.tew.terminalEmulator.toggleScrollLock();
|
||||
nw.tew.terminalEmulator.scrollLockLock();
|
||||
nw.tew.terminalEmulator.drawScrollback();
|
||||
nw.title = "Filter Display";
|
||||
nw.show();
|
||||
|
@ -7781,7 +7797,7 @@ version(TerminalDirectToEmulator) {
|
|||
|
||||
override Menu contextMenu(int x, int y) {
|
||||
if(ctx is null) {
|
||||
ctx = new Menu("");
|
||||
ctx = new Menu("", this);
|
||||
ctx.addItem(new MenuItem(new Action("Copy", 0, {
|
||||
terminalEmulator.copyToClipboard(terminalEmulator.getSelectedText());
|
||||
})));
|
||||
|
|
|
@ -1573,10 +1573,21 @@ class TerminalEmulator {
|
|||
recalculateScrollbackLength();
|
||||
}
|
||||
|
||||
private bool scrollLockLockEnabled = false;
|
||||
package void scrollLockLock() {
|
||||
scrollLockLockEnabled = true;
|
||||
if(!scrollLock)
|
||||
toggleScrollLock();
|
||||
}
|
||||
|
||||
private bool scrollLock = false;
|
||||
public void toggleScrollLock() {
|
||||
if(scrollLockLockEnabled && scrollLock)
|
||||
goto nochange;
|
||||
scrollLock = !scrollLock;
|
||||
scrollbackReflow = !scrollLock;
|
||||
|
||||
nochange:
|
||||
recalculateScrollbackLength();
|
||||
|
||||
if(scrollLock) {
|
||||
|
|
Loading…
Reference in New Issue