mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Added logout dialog, bone documentation, more cmd options... forgot the rest
This commit is contained in:
@@ -11,22 +11,26 @@
|
||||
*/
|
||||
|
||||
#include "Log.h"
|
||||
#include "Logout.h"
|
||||
#include "EvokeService.h"
|
||||
#include "Splash.h"
|
||||
#include "Spawn.h"
|
||||
|
||||
#include <edelib/File.h>
|
||||
#include <edelib/Config.h>
|
||||
#include <edelib/DesktopFile.h>
|
||||
#include <edelib/Directory.h>
|
||||
#include <edelib/StrUtil.h>
|
||||
#include <edelib/Util.h>
|
||||
#include <edelib/Debug.h>
|
||||
#include <edelib/Nls.h>
|
||||
|
||||
#include <FL/fl_ask.h>
|
||||
|
||||
#include <sys/types.h> // getpid
|
||||
#include <unistd.h> //
|
||||
#include <stdlib.h> // free
|
||||
#include <string.h> // strdup
|
||||
#include <string.h> // strdup, memset
|
||||
|
||||
void resolve_path(const edelib::String& imgdir, edelib::String& img, bool have_imgdir) {
|
||||
if(img.empty())
|
||||
@@ -218,6 +222,29 @@ bool EvokeService::init_splash(const char* config, bool no_splash, bool dry_run)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is implementation of Autostart Spec (http://standards.freedesktop.org/autostart-spec/autostart-spec-0.5.html).
|
||||
* The Autostart Directories are $XDG_CONFIG_DIRS/autostart.
|
||||
* If the same filename is located under multiple Autostart Directories
|
||||
* only the file under the most important directory should be used.
|
||||
* Example: If $XDG_CONFIG_HOME is not set the Autostart Directory in the user's home
|
||||
* directory is ~/.config/autostart/
|
||||
* Example: If $XDG_CONFIG_DIRS is not set the system wide Autostart Directory
|
||||
* is /etc/xdg/autostart/
|
||||
* Example: If $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS are not set and the two
|
||||
* files /etc/xdg/autostart/foo.desktop and ~/.config/autostart/foo.desktop exist
|
||||
* then only the file ~/.config/autostart/foo.desktop will be used because ~/.config/autostart/
|
||||
* is more important than /etc/xdg/autostart/
|
||||
* If Hidden key is set true in .desktop file, file MUST be ignored.
|
||||
* OnlyShowIn and NotShowIn (list of strings identifying desktop environments) if (or if not)
|
||||
* contains environment name, MUST not be started/not started.
|
||||
* TryExec is same as for .desktop spec.
|
||||
*/
|
||||
void EvokeService::init_autostart(void) {
|
||||
edelib::String home = edelib::user_config_dir();
|
||||
home += "/autostart/";
|
||||
}
|
||||
|
||||
void EvokeService::setup_atoms(Display* d) {
|
||||
// with them must be send '1' or property will be ignored (except _EDE_EVOKE_SPAWN)
|
||||
_ede_shutdown_all = XInternAtom(d, "_EDE_EVOKE_SHUTDOWN_ALL", False);
|
||||
@@ -226,6 +253,68 @@ void EvokeService::setup_atoms(Display* d) {
|
||||
_ede_spawn = XInternAtom(d, "_EDE_EVOKE_SPAWN", False);
|
||||
}
|
||||
|
||||
void EvokeService::quit_x11(void) {
|
||||
int ret = fl_ask(_("Nice quitting is not implemented yet and this will forcefully kill\nall running applications. Make sure to save what needs to be saved.\nSo, would you like to continue ?"));
|
||||
if(ret)
|
||||
stop();
|
||||
#if 0
|
||||
/*
|
||||
* This code is working, but not as I would like to see.
|
||||
* It will (mostly) call XKillClient() for _every_ window
|
||||
* (including i.e. buttons in some app), and that is not
|
||||
* nice way to say good bye. This must be implemented in
|
||||
* wm since it only knows what is actuall window and what not.
|
||||
* For now quit_x11() will simply quit itself, quitting X11
|
||||
* session (if it holds it), which will in turn forcefully kill
|
||||
* all windows.
|
||||
*/
|
||||
Window dummy, *wins;
|
||||
Window root = RootWindow(fl_display, fl_screen);
|
||||
unsigned int n;
|
||||
|
||||
if(!XQueryTree(fl_display, root, &dummy, &dummy, &wins, &n))
|
||||
return;
|
||||
|
||||
Atom _wm_protocols = XInternAtom(fl_display, "WM_PROTOCOLS", False);
|
||||
Atom _wm_delete_window = XInternAtom(fl_display, "WM_DELETE_WINDOW", False);
|
||||
Atom* protocols;
|
||||
int np;
|
||||
XEvent ev;
|
||||
bool have_quit = 0;
|
||||
|
||||
for(unsigned int i = 0; i < n; i++) {
|
||||
if(wins[i] == root)
|
||||
continue;
|
||||
|
||||
have_quit = 0;
|
||||
if(XGetWMProtocols(fl_display, wins[i], &protocols, &np)) {
|
||||
for(int j = 0; j < np; j++) {
|
||||
if(protocols[j] == _wm_delete_window) {
|
||||
have_quit = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(have_quit) {
|
||||
memset(&ev, 0, sizeof(ev));
|
||||
ev.xclient.type = ClientMessage;
|
||||
ev.xclient.window = wins[i];
|
||||
ev.xclient.message_type = _wm_protocols;
|
||||
ev.xclient.format = 32;
|
||||
ev.xclient.data.l[0] = (long)_wm_delete_window;
|
||||
ev.xclient.data.l[1] = (long)fl_event_time;
|
||||
XSendEvent(fl_display, wins[i], False, 0L, &ev);
|
||||
} else {
|
||||
XKillClient(fl_display, wins[i]);
|
||||
}
|
||||
}
|
||||
|
||||
XFree((void*)wins);
|
||||
stop();
|
||||
#endif
|
||||
}
|
||||
|
||||
int EvokeService::handle(const XEvent* ev) {
|
||||
logfile->printf("Got event %i\n", ev->type);
|
||||
|
||||
@@ -269,9 +358,15 @@ int EvokeService::handle(const XEvent* ev) {
|
||||
|
||||
if(ev->xproperty.atom == _ede_shutdown_all) {
|
||||
int val = get_int_property_value(_ede_shutdown_all);
|
||||
if(val == 1)
|
||||
if(val == 1) {
|
||||
logfile->printf("Got accepted _EDE_EVOKE_SHUTDOWN_ALL\n");
|
||||
else
|
||||
|
||||
int dw = DisplayWidth(fl_display, fl_screen);
|
||||
int dh = DisplayHeight(fl_display, fl_screen);
|
||||
|
||||
printf("got %i\n", logout_dialog(dw, dh));
|
||||
//quit_x11();
|
||||
} else
|
||||
logfile->printf("Got _EDE_EVOKE_SHUTDOWN_ALL with bad code (%i). Ignoring...\n", val);
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user