mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-25 18:05:20 +02:00
Moved console bind+activate code into Launcher
This way, we can launch console applications from the Explorer.
This commit is contained in:
parent
dc23718f7f
commit
303ecf298a
@ -6,21 +6,59 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
// Bind and activate the framebuffer console on selected platforms.
|
||||||
|
#define BIND_CONSOLE \
|
||||||
|
defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
|
||||||
|
|
||||||
|
#if BIND_CONSOLE
|
||||||
|
#include <linux/vt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
Launcher::Launcher(vector<string> const& commandLine)
|
Launcher::Launcher(vector<string> const& commandLine, bool consoleApp)
|
||||||
: commandLine(commandLine)
|
: commandLine(commandLine)
|
||||||
|
, consoleApp(consoleApp)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Launcher::Launcher(vector<string> && commandLine)
|
Launcher::Launcher(vector<string> && commandLine, bool consoleApp)
|
||||||
: commandLine(commandLine)
|
: commandLine(commandLine)
|
||||||
|
, consoleApp(consoleApp)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::exec()
|
void Launcher::exec()
|
||||||
{
|
{
|
||||||
|
if (consoleApp) {
|
||||||
|
#if BIND_CONSOLE
|
||||||
|
/* Enable the framebuffer console */
|
||||||
|
char c = '1';
|
||||||
|
int fd = open("/sys/devices/virtual/vtconsole/vtcon1/bind", O_WRONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
WARNING("Unable to open fbcon handle\n");
|
||||||
|
} else {
|
||||||
|
write(fd, &c, 1);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = open("/dev/tty1", O_RDWR);
|
||||||
|
if (fd < 0) {
|
||||||
|
WARNING("Unable to open tty1 handle\n");
|
||||||
|
} else {
|
||||||
|
if (ioctl(fd, VT_ACTIVATE, 1) < 0)
|
||||||
|
WARNING("Unable to activate tty1\n");
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
vector<const char *> args;
|
vector<const char *> args;
|
||||||
args.reserve(commandLine.size() + 1);
|
args.reserve(commandLine.size() + 1);
|
||||||
for (auto arg : commandLine) {
|
for (auto arg : commandLine) {
|
||||||
|
@ -8,13 +8,16 @@
|
|||||||
class Launcher
|
class Launcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Launcher(std::vector<std::string> const& commandLine);
|
Launcher(std::vector<std::string> const& commandLine,
|
||||||
Launcher(std::vector<std::string> && commandLine);
|
bool consoleApp = true);
|
||||||
|
Launcher(std::vector<std::string> && commandLine,
|
||||||
|
bool consoleApp = true);
|
||||||
|
|
||||||
void exec();
|
void exec();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> commandLine;
|
std::vector<std::string> commandLine;
|
||||||
|
bool consoleApp;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAUNCHER_H
|
#endif // LAUNCHER_H
|
||||||
|
@ -43,14 +43,6 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
// Bind and activate the framebuffer console on selected platforms.
|
|
||||||
#define BIND_CONSOLE \
|
|
||||||
defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
|
|
||||||
|
|
||||||
#if BIND_CONSOLE
|
|
||||||
#include <linux/vt.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBOPK
|
#ifdef HAVE_LIBOPK
|
||||||
#include <opk.h>
|
#include <opk.h>
|
||||||
#endif
|
#endif
|
||||||
@ -578,29 +570,6 @@ void LinkApp::launch(const string &selectedFile) {
|
|||||||
#endif
|
#endif
|
||||||
gmenu2x->quit();
|
gmenu2x->quit();
|
||||||
|
|
||||||
if (consoleApp) {
|
|
||||||
#if BIND_CONSOLE
|
|
||||||
/* Enable the framebuffer console */
|
|
||||||
char c = '1';
|
|
||||||
int fd = open("/sys/devices/virtual/vtconsole/vtcon1/bind", O_WRONLY);
|
|
||||||
if (fd < 0) {
|
|
||||||
WARNING("Unable to open fbcon handle\n");
|
|
||||||
} else {
|
|
||||||
write(fd, &c, 1);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = open("/dev/tty1", O_RDWR);
|
|
||||||
if (fd < 0) {
|
|
||||||
WARNING("Unable to open tty1 handle\n");
|
|
||||||
} else {
|
|
||||||
if (ioctl(fd, VT_ACTIVATE, 1) < 0)
|
|
||||||
WARNING("Unable to activate tty1\n");
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<string> commandLine;
|
vector<string> commandLine;
|
||||||
if (isOpk()) {
|
if (isOpk()) {
|
||||||
#ifdef HAVE_LIBOPK
|
#ifdef HAVE_LIBOPK
|
||||||
@ -613,7 +582,7 @@ void LinkApp::launch(const string &selectedFile) {
|
|||||||
commandLine = { "/bin/sh", "-c", exec + " " + params };
|
commandLine = { "/bin/sh", "-c", exec + " " + params };
|
||||||
}
|
}
|
||||||
|
|
||||||
Launcher launcher(move(commandLine));
|
Launcher launcher(move(commandLine), consoleApp);
|
||||||
launcher.exec();
|
launcher.exec();
|
||||||
|
|
||||||
//if execution continues then something went wrong and as we already called SDL_Quit we cannot continue
|
//if execution continues then something went wrong and as we already called SDL_Quit we cannot continue
|
||||||
|
Loading…
Reference in New Issue
Block a user