DrewNaylor / Retiled

An attempt at creating a "desktop" environment mainly for Linux phones and tablets that's similar in function to some parts of Microsoft's Windows Phone 8.x, primarily the Start screen, Search app, navigation bar, Action Center, and the status bar. Development is mainly being done using the PinePhone, so that'll be the main supported device.
https://codeberg.org/DrewNaylor/Retiled
Apache License 2.0
69 stars 3 forks source link

If apps are designed to go back, they'll listen for the "Escape" key, since pressing "Escape" goes back in the WP emulator. They'll also have the option to use an enhanced Back button functionality via D-Bus, as well as checking if the navbar is running. #4

Open DrewNaylor opened 3 years ago

DrewNaylor commented 3 years ago

This one seems pretty good: https://nicolasdeory.medium.com/simple-ipc-using-named-pipes-in-net-core-7cb1b29f6dab

Here's the GitHub page for it: https://github.com/RandomEngy/PipeMethodCalls

Not entirely sure how different applications would connect to the same named pipe as what the navigation bar would use to allow for navigating back if possible or closing the program, though. Stuff like Firefox wouldn't work with it and I'd need to figure out a way to send backward navigation commands to everything that can use them, unless it would just detect if a program can use the back button to go back and not do anything if that's not possible.

Edit: see the latest reply here on how the Back button is basically the Escape key, so we'll use that: https://github.com/DrewNaylor/Retiled/issues/4#issuecomment-846894839

Edit 2: D-Bus will allow for the enhanced Back button functionality in apps that support it, as well as a way to check if the navigation bar is currently running and display an emergency Back button if it's not, as described in this comment: https://github.com/DrewNaylor/Retiled/issues/4#issuecomment-1285952455

DrewNaylor commented 3 years ago

Might be easier to just have a back button in the bottom-left corner of each app for Avalonia-based apps I develop for use with it and move the "titlebar" for stuff like GNOME apps to the bottom so it kinda works like Windows Phone. Actually, maybe I could see if Phosh's window manager would work well if I change the theme to a Windows Phone-like one. The hamburger menu would be changed to the "More" button and the arrow would be made thinner, for example. Probably will still have to write my own window manager for moving the CSD bar around, but this should be a lot easier for now even though it's not "pure" Windows Phone-style interaction. Moving the back button into the app itself would allow replacing the spot it would be with a multitasking button, kinda like Android but on the left with Search on the right, as it should be. If I ever figure out how to put the back button back where it came from, or so help me (so help me!), I'll do it, but moving the "title bar" down to where the bottom buttons are on Windows Phone would be more consistent. Not every app can do this if they draw their own stuff like I think Chrome does (tabs are above the navigation buttons), but most apps should allow this and Firefox might be able to be modified with custom user chrome/CSS.

DrewNaylor commented 3 years ago

Actually, Plasma Mobile apps appear to have most of their controls near the bottom, so I probably won't bother too much with trying to get GTK apps to have their stuff near the bottom (which probably won't work anyway due to CSD).

DrewNaylor commented 3 years ago

Found out that the Windows Phone 8.1 emulator image uses the Esc (Escape) key as a substitute for the Back button when messing around with it in Hyper-V. That may be a solution, but I'll just have to figure out how to hook that up. Much simpler and solves a lot of issues like what to do with popups in programs like Firefox and everything else. Third-party apps may even be able to hook into it and listen for Escape to go back if Retiled becomes popular enough.

DrewNaylor commented 3 years ago

Just found out that the Maliit keyboard is actually a framework, and you can make plugins for it and use it to send stuff. Maybe it would be possible to use it to send the escape key. Here's a sample of sending some text, though I don't know if I need to use C++ or if I can just use QML: https://github.com/maliit/framework/blob/master/examples/plugins/qml/helloworld/helloworld.qml

I'll probably use the Maliit keyboard if I can ever figure out how to create my own theme for it (example themes here, but I can't find the Ubuntu component files that they refer to: https://github.com/maliit/keyboard/tree/master/data/themes) and build my own Manjaro ARM respin while including packages that aren't in the main repos (probably will have to either host them through GitHub or rent hosting space through Linnode).

Additionally, I just remembered that pressing and holding escape goes into multitasking, but pressing it once goes back. I may have to change things so pressing the Back button sends Escape, but holding it sends Alt+Tab or whatever Plasma Mobile listens for (I need to check). That'll simplify things, because generally apps don't listen for Alt+Tab.

DrewNaylor commented 3 years ago

Not sure where I should put this, but after some experimenting with Escape key shortcuts in QML, I discovered that it's possible for it to interfere with other "Shortcut" items. However, QML allows you to override the shortcuts when something is focused, which should allow people to use the Back button to close popup dialogs and context menus, at least in apps designed with the Back button in mind.

Not all apps will support the Back button, so if those don't work with it, they won't work with it. On the other hand, apps that are designed with the Back button in mind need to have a way to let the user go back without the Retiled Back button, perhaps with one in the same place with the same appearance, but without anything else on the bar. Maybe there can be a way to squeeze the Back button into the bottom-left in the App Bar, like I'm doing in the Search app right now. This will require some sort of code to check if the navigation bar is running, and show the emergency Back button if it's not. Of course, this emergency Back button won't work in every situation, but navigating to a previous page in an app (or any other basic functionality the Back button would be frequently used for) should be possible at minimum.

Documentation for shortcut-overriding here: https://doc.qt.io/qt-6/qml-qtquick-keys.html#shortcutOverride-signal

DrewNaylor commented 2 years ago

Perhaps another option would be using evscript to send the "Escape" key press when using the Back button, and long-pressing it gives a different command, likely whatever will open the window switcher plugin in Wayfire, as that's probably what I'll use to put everything together into a DE: https://github.com/unrelentingtech/evscript

DrewNaylor commented 2 years ago

Update: I recently found out that Qt can apparently handle sensing keyboard input via QWaylandSeat::sendKeyEvent: https://doc.qt.io/qt-6/qwaylandseat.html#sendKeyEvent

I'll probably have to send a press then a release immediately after. Hopefully it doesn't count as multiple presses. If this works, this should make things very simple, and I can probably implement this into the compositor soon since this function can be used in QML.

Here's a whole list of keys in the Keys enum: https://doc.qt.io/qt-6/qt.html#Key-enum

DrewNaylor commented 2 years ago

Actually, an even better idea is to check with the focused app to see if it supports enhanced Back button functionality via D-Bus, and if so, don't send it Escape but instead use X-Retiled-BackButtonPressed and have it pick up on that to do whatever it needs to do. This also solves the problem of not knowing if the navigation bar is running and needing an "emergency Back button" to be displayed, by having the app check for X-Retiled-IsNavBarRunning, which will always return True if it's running.

Going back with Escape will still have to be supported, mainly for apps that don't support enhanced Back button functionality. There's also a need to have the navigation bar take over the Escape key when it's pressed so that the focused app will get either Escape if it doesn't support the enhanced functionality, or it'll get the enhanced functionality. There additionally needs to be a way for the app to interpret the signal of the Back button being pressed as a simple Escape key press at runtime, such as when a dialog box is open, even if it has previously signaled support for enhanced Back button functionality.

DrewNaylor commented 1 year ago

Interestingly, the Back button was discussed for Plasma Mobile a few years back: https://phabricator.kde.org/T13815

Edit: Ok so good news: someone was working on Back button support for Plasma Mobile in place of the close button. Bad news: it only uses alt+left instead of Escape, so it's still not easily universal (doesn't close dialogs, where mine does). Here's the branch: https://github.com/KDE/plasma-mobile/compare/master...work/devinlin/back-button