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;
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ class EvokeService {
|
||||
bool setup_logging(const char* file);
|
||||
bool setup_pid(const char* file, const char* lock);
|
||||
void setup_atoms(Display* d);
|
||||
|
||||
bool init_splash(const char* config, bool no_splash, bool dry_run);
|
||||
void init_autostart(void);
|
||||
|
||||
int handle(const XEvent* ev);
|
||||
|
||||
@ -67,6 +67,8 @@ class EvokeService {
|
||||
|
||||
void register_top(Fl_Double_Window* win) { top_win = win; }
|
||||
void unregister_top(void) { top_win = NULL; }
|
||||
|
||||
void quit_x11(void);
|
||||
};
|
||||
|
||||
#define EVOKE_LOG EvokeService::instance()->log()->printf
|
||||
|
@ -10,8 +10,9 @@
|
||||
|
||||
SubDir TOP evoke ;
|
||||
|
||||
SOURCE = evoke.cpp EvokeService.cpp Spawn.cpp Splash.cpp Log.cpp ;
|
||||
SOURCE = evoke.cpp EvokeService.cpp Spawn.cpp Splash.cpp Log.cpp Logout.cpp ;
|
||||
|
||||
EdeProgram evoke : $(SOURCE) ;
|
||||
FltkProgramBare test/evoke_test : test/evoke_test.cpp ;
|
||||
#TranslationStrings locale : $(SOURCE) ;
|
||||
EdeManual doc/evoke.txt ;
|
||||
|
470
evoke/Logout.cpp
Normal file
470
evoke/Logout.cpp
Normal file
@ -0,0 +1,470 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Evoke, head honcho of everything
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2000-2007 EDE Authors.
|
||||
*
|
||||
* This program is licensed under terms of the
|
||||
* GNU General Public License version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#include "Logout.h"
|
||||
#include <edelib/Nls.h>
|
||||
|
||||
#include <FL/Fl_Double_Window.h>
|
||||
#include <FL/Fl_Box.h>
|
||||
#include <FL/Fl_Button.h>
|
||||
#include <FL/Fl_Round_Button.h>
|
||||
#include <FL/Fl_RGB_Image.h>
|
||||
#include <FL/Fl.h>
|
||||
#include <FL/x.h>
|
||||
#include <string.h> // memset
|
||||
|
||||
static int logout_ret;
|
||||
static Fl_Double_Window* win;
|
||||
static Fl_Round_Button* rb1;
|
||||
static Fl_Round_Button* rb2;
|
||||
static Fl_Round_Button* rb3;
|
||||
|
||||
unsigned char* take_x11_screenshot(unsigned char *p, int X, int Y, int w, int h, int alpha);
|
||||
unsigned char* make_darker(unsigned char *p, int X, int Y, int w, int h);
|
||||
|
||||
void rb_cb(Fl_Widget*, void* r) {
|
||||
Fl_Round_Button* rb = (Fl_Round_Button*)r;
|
||||
if(rb == rb2) {
|
||||
rb1->value(0);
|
||||
rb3->value(0);
|
||||
} else if(rb == rb3) {
|
||||
rb1->value(0);
|
||||
rb2->value(0);
|
||||
} else {
|
||||
rb2->value(0);
|
||||
rb3->value(0);
|
||||
}
|
||||
|
||||
rb->value(1);
|
||||
}
|
||||
|
||||
void ok_cb(Fl_Widget*, void*) {
|
||||
if(rb1->value())
|
||||
logout_ret = LOGOUT_LOGOUT;
|
||||
else if(rb2->value())
|
||||
logout_ret = LOGOUT_RESTART;
|
||||
else
|
||||
logout_ret = LOGOUT_SHUTDOWN;
|
||||
win->hide();
|
||||
}
|
||||
|
||||
void cancel_cb(Fl_Widget*, void*) {
|
||||
logout_ret = LOGOUT_CANCEL;
|
||||
win->hide();
|
||||
}
|
||||
|
||||
int logout_dialog(int screen_w, int screen_h, bool disable_restart, bool disable_shutdown) {
|
||||
logout_ret = 0;
|
||||
unsigned char* imgdata = NULL;
|
||||
imgdata = take_x11_screenshot(imgdata, 0, 0, screen_w, screen_h, 0);
|
||||
if(imgdata)
|
||||
imgdata = make_darker(imgdata, 0, 0, screen_w, screen_h);
|
||||
|
||||
//win = new Fl_Double_Window(365, 265, 325, 185, _("Logout, restart or shutdown"));
|
||||
win = new Fl_Double_Window(0, 0, screen_w, screen_h, _("Logout, restart or shutdown"));
|
||||
win->begin();
|
||||
Fl_Box* bb = new Fl_Box(0, 0, win->w(), win->h());
|
||||
Fl_RGB_Image* img = new Fl_RGB_Image(imgdata, 1024, 768);
|
||||
img->alloc_array = 1;
|
||||
bb->image(img);
|
||||
|
||||
//Fl_Group* g = new Fl_Group(365, 265, 325, 185);
|
||||
Fl_Group* g = new Fl_Group(0, 0, 325, 185);
|
||||
g->box(FL_THIN_UP_BOX);
|
||||
g->begin();
|
||||
Fl_Box* b = new Fl_Box(10, 9, 305, 39, _("Logout, restart or shut down the computer ?"));
|
||||
b->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_WRAP);
|
||||
b->labelfont(FL_HELVETICA_BOLD);
|
||||
|
||||
rb1 = new Fl_Round_Button(25, 60, 275, 20, _("Logout from the current session"));
|
||||
rb1->down_box(FL_ROUND_DOWN_BOX);
|
||||
rb1->value(1);
|
||||
rb1->callback(rb_cb, rb1);
|
||||
|
||||
rb2 = new Fl_Round_Button(25, 85, 275, 20, _("Restart the computer"));
|
||||
rb2->down_box(FL_ROUND_DOWN_BOX);
|
||||
rb2->value(0);
|
||||
rb2->callback(rb_cb, rb2);
|
||||
if(disable_restart)
|
||||
rb2->deactivate();
|
||||
|
||||
rb3 = new Fl_Round_Button(25, 110, 275, 20, _("Shut down the computer"));
|
||||
rb3->down_box(FL_ROUND_DOWN_BOX);
|
||||
rb3->value(0);
|
||||
rb3->callback(rb_cb, rb3);
|
||||
if(disable_shutdown)
|
||||
rb3->deactivate();
|
||||
|
||||
Fl_Button* ok = new Fl_Button(130, 150, 90, 25, _("&OK"));
|
||||
ok->callback(ok_cb);
|
||||
|
||||
Fl_Button* cancel = new Fl_Button(225, 150, 90, 25, _("&Cancel"));
|
||||
cancel->callback(cancel_cb);
|
||||
g->end();
|
||||
|
||||
|
||||
g->position(screen_w/2 - g->w()/2, screen_h/2 - g->h()/2);
|
||||
|
||||
win->end();
|
||||
win->clear_border();
|
||||
win->set_override();
|
||||
win->show();
|
||||
|
||||
while(win->shown())
|
||||
Fl::wait();
|
||||
|
||||
return logout_ret;
|
||||
}
|
||||
|
||||
unsigned char* make_darker(unsigned char *p, int X, int Y, int w, int h) {
|
||||
if(!p)
|
||||
return 0;
|
||||
unsigned char* pdata = p;
|
||||
int step = 100;
|
||||
|
||||
for(int j = 0; j < h; j++) {
|
||||
for(int i = 0; i < w; i++) {
|
||||
// red
|
||||
if(*pdata > step) *pdata -= step; pdata++;
|
||||
// green
|
||||
if(*pdata > step) *pdata -= step; pdata++;
|
||||
// blue
|
||||
if(*pdata > step) *pdata -= step; pdata++;
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
// stolen from fl_read_image.cxx
|
||||
unsigned char* take_x11_screenshot(unsigned char *p, int X, int Y, int w, int h, int alpha) {
|
||||
XImage *image;
|
||||
int i, maxindex;
|
||||
int x, y; // Current X & Y in image
|
||||
int d; // Depth of image
|
||||
unsigned char *line, // Array to hold image row
|
||||
*line_ptr; // Pointer to current line image
|
||||
unsigned char *pixel; // Current color value
|
||||
XColor colors[4096]; // Colors from the colormap...
|
||||
unsigned char cvals[4096][3]; // Color values from the colormap...
|
||||
unsigned index_mask,
|
||||
index_shift,
|
||||
red_mask,
|
||||
red_shift,
|
||||
green_mask,
|
||||
green_shift,
|
||||
blue_mask,
|
||||
blue_shift;
|
||||
|
||||
|
||||
//
|
||||
// Under X11 we have the option of the XGetImage() interface or SGI's
|
||||
// ReadDisplay extension which does all of the really hard work for
|
||||
// us...
|
||||
//
|
||||
|
||||
image = 0;
|
||||
|
||||
if (!image) {
|
||||
image = XGetImage(fl_display, RootWindow(fl_display, fl_screen), X, Y, w, h, AllPlanes, ZPixmap);
|
||||
}
|
||||
|
||||
if (!image) return 0;
|
||||
|
||||
d = alpha ? 4 : 3;
|
||||
|
||||
// Allocate the image data array as needed...
|
||||
if (!p) p = new unsigned char[w * h * d];
|
||||
|
||||
// Initialize the default colors/alpha in the whole image...
|
||||
memset(p, alpha, w * h * d);
|
||||
|
||||
// Check that we have valid mask/shift values...
|
||||
if (!image->red_mask && image->bits_per_pixel > 12) {
|
||||
// Greater than 12 bits must be TrueColor...
|
||||
image->red_mask = fl_visual->visual->red_mask;
|
||||
image->green_mask = fl_visual->visual->green_mask;
|
||||
image->blue_mask = fl_visual->visual->blue_mask;
|
||||
}
|
||||
|
||||
// Check if we have colormap image...
|
||||
if (!image->red_mask) {
|
||||
// Get the colormap entries for this window...
|
||||
maxindex = fl_visual->visual->map_entries;
|
||||
|
||||
for (i = 0; i < maxindex; i ++) colors[i].pixel = i;
|
||||
|
||||
XQueryColors(fl_display, fl_colormap, colors, maxindex);
|
||||
|
||||
for (i = 0; i < maxindex; i ++) {
|
||||
cvals[i][0] = colors[i].red >> 8;
|
||||
cvals[i][1] = colors[i].green >> 8;
|
||||
cvals[i][2] = colors[i].blue >> 8;
|
||||
}
|
||||
|
||||
// Read the pixels and output an RGB image...
|
||||
for (y = 0; y < image->height; y ++) {
|
||||
pixel = (unsigned char *)(image->data + y * image->bytes_per_line);
|
||||
line = p + y * w * d;
|
||||
|
||||
switch (image->bits_per_pixel) {
|
||||
case 1 :
|
||||
for (x = image->width, line_ptr = line, index_mask = 128;
|
||||
x > 0;
|
||||
x --, line_ptr += d) {
|
||||
if (*pixel & index_mask) {
|
||||
line_ptr[0] = cvals[1][0];
|
||||
line_ptr[1] = cvals[1][1];
|
||||
line_ptr[2] = cvals[1][2];
|
||||
} else {
|
||||
line_ptr[0] = cvals[0][0];
|
||||
line_ptr[1] = cvals[0][1];
|
||||
line_ptr[2] = cvals[0][2];
|
||||
}
|
||||
|
||||
if (index_mask > 1) {
|
||||
index_mask >>= 1;
|
||||
} else {
|
||||
index_mask = 128;
|
||||
pixel ++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
for (x = image->width, line_ptr = line, index_shift = 6;
|
||||
x > 0;
|
||||
x --, line_ptr += d) {
|
||||
i = (*pixel >> index_shift) & 3;
|
||||
|
||||
line_ptr[0] = cvals[i][0];
|
||||
line_ptr[1] = cvals[i][1];
|
||||
line_ptr[2] = cvals[i][2];
|
||||
|
||||
if (index_shift > 0) {
|
||||
index_mask >>= 2;
|
||||
index_shift -= 2;
|
||||
} else {
|
||||
index_mask = 192;
|
||||
index_shift = 6;
|
||||
pixel ++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4 :
|
||||
for (x = image->width, line_ptr = line, index_shift = 4;
|
||||
x > 0;
|
||||
x --, line_ptr += d) {
|
||||
if (index_shift == 4) i = (*pixel >> 4) & 15;
|
||||
else i = *pixel & 15;
|
||||
|
||||
line_ptr[0] = cvals[i][0];
|
||||
line_ptr[1] = cvals[i][1];
|
||||
line_ptr[2] = cvals[i][2];
|
||||
|
||||
if (index_shift > 0) {
|
||||
index_shift = 0;
|
||||
} else {
|
||||
index_shift = 4;
|
||||
pixel ++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 8 :
|
||||
for (x = image->width, line_ptr = line;
|
||||
x > 0;
|
||||
x --, line_ptr += d, pixel ++) {
|
||||
line_ptr[0] = cvals[*pixel][0];
|
||||
line_ptr[1] = cvals[*pixel][1];
|
||||
line_ptr[2] = cvals[*pixel][2];
|
||||
}
|
||||
break;
|
||||
|
||||
case 12 :
|
||||
for (x = image->width, line_ptr = line, index_shift = 0;
|
||||
x > 0;
|
||||
x --, line_ptr += d) {
|
||||
if (index_shift == 0) {
|
||||
i = ((pixel[0] << 4) | (pixel[1] >> 4)) & 4095;
|
||||
} else {
|
||||
i = ((pixel[1] << 8) | pixel[2]) & 4095;
|
||||
}
|
||||
|
||||
line_ptr[0] = cvals[i][0];
|
||||
line_ptr[1] = cvals[i][1];
|
||||
line_ptr[2] = cvals[i][2];
|
||||
|
||||
if (index_shift == 0) {
|
||||
index_shift = 4;
|
||||
} else {
|
||||
index_shift = 0;
|
||||
pixel += 3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// RGB(A) image, so figure out the shifts & masks...
|
||||
red_mask = image->red_mask;
|
||||
red_shift = 0;
|
||||
|
||||
while ((red_mask & 1) == 0) {
|
||||
red_mask >>= 1;
|
||||
red_shift ++;
|
||||
}
|
||||
|
||||
green_mask = image->green_mask;
|
||||
green_shift = 0;
|
||||
|
||||
while ((green_mask & 1) == 0) {
|
||||
green_mask >>= 1;
|
||||
green_shift ++;
|
||||
}
|
||||
|
||||
blue_mask = image->blue_mask;
|
||||
blue_shift = 0;
|
||||
|
||||
while ((blue_mask & 1) == 0) {
|
||||
blue_mask >>= 1;
|
||||
blue_shift ++;
|
||||
}
|
||||
|
||||
// Read the pixels and output an RGB image...
|
||||
for (y = 0; y < image->height; y ++) {
|
||||
pixel = (unsigned char *)(image->data + y * image->bytes_per_line);
|
||||
line = p + y * w * d;
|
||||
|
||||
switch (image->bits_per_pixel) {
|
||||
case 8 :
|
||||
for (x = image->width, line_ptr = line;
|
||||
x > 0;
|
||||
x --, line_ptr += d, pixel ++) {
|
||||
i = *pixel;
|
||||
|
||||
line_ptr[0] = 255 * ((i >> red_shift) & red_mask) / red_mask;
|
||||
line_ptr[1] = 255 * ((i >> green_shift) & green_mask) / green_mask;
|
||||
line_ptr[2] = 255 * ((i >> blue_shift) & blue_mask) / blue_mask;
|
||||
}
|
||||
break;
|
||||
|
||||
case 12 :
|
||||
for (x = image->width, line_ptr = line, index_shift = 0;
|
||||
x > 0;
|
||||
x --, line_ptr += d) {
|
||||
if (index_shift == 0) {
|
||||
i = ((pixel[0] << 4) | (pixel[1] >> 4)) & 4095;
|
||||
} else {
|
||||
i = ((pixel[1] << 8) | pixel[2]) & 4095;
|
||||
}
|
||||
|
||||
line_ptr[0] = 255 * ((i >> red_shift) & red_mask) / red_mask;
|
||||
line_ptr[1] = 255 * ((i >> green_shift) & green_mask) / green_mask;
|
||||
line_ptr[2] = 255 * ((i >> blue_shift) & blue_mask) / blue_mask;
|
||||
|
||||
if (index_shift == 0) {
|
||||
index_shift = 4;
|
||||
} else {
|
||||
index_shift = 0;
|
||||
pixel += 3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 16 :
|
||||
if (image->byte_order == LSBFirst) {
|
||||
// Little-endian...
|
||||
for (x = image->width, line_ptr = line;
|
||||
x > 0;
|
||||
x --, line_ptr += d, pixel += 2) {
|
||||
i = (pixel[1] << 8) | pixel[0];
|
||||
|
||||
line_ptr[0] = 255 * ((i >> red_shift) & red_mask) / red_mask;
|
||||
line_ptr[1] = 255 * ((i >> green_shift) & green_mask) / green_mask;
|
||||
line_ptr[2] = 255 * ((i >> blue_shift) & blue_mask) / blue_mask;
|
||||
}
|
||||
} else {
|
||||
// Big-endian...
|
||||
for (x = image->width, line_ptr = line;
|
||||
x > 0;
|
||||
x --, line_ptr += d, pixel += 2) {
|
||||
i = (pixel[0] << 8) | pixel[1];
|
||||
|
||||
line_ptr[0] = 255 * ((i >> red_shift) & red_mask) / red_mask;
|
||||
line_ptr[1] = 255 * ((i >> green_shift) & green_mask) / green_mask;
|
||||
line_ptr[2] = 255 * ((i >> blue_shift) & blue_mask) / blue_mask;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 24 :
|
||||
if (image->byte_order == LSBFirst) {
|
||||
// Little-endian...
|
||||
for (x = image->width, line_ptr = line;
|
||||
x > 0;
|
||||
x --, line_ptr += d, pixel += 3) {
|
||||
i = (((pixel[2] << 8) | pixel[1]) << 8) | pixel[0];
|
||||
|
||||
line_ptr[0] = 255 * ((i >> red_shift) & red_mask) / red_mask;
|
||||
line_ptr[1] = 255 * ((i >> green_shift) & green_mask) / green_mask;
|
||||
line_ptr[2] = 255 * ((i >> blue_shift) & blue_mask) / blue_mask;
|
||||
}
|
||||
} else {
|
||||
// Big-endian...
|
||||
for (x = image->width, line_ptr = line;
|
||||
x > 0;
|
||||
x --, line_ptr += d, pixel += 3) {
|
||||
i = (((pixel[0] << 8) | pixel[1]) << 8) | pixel[2];
|
||||
|
||||
line_ptr[0] = 255 * ((i >> red_shift) & red_mask) / red_mask;
|
||||
line_ptr[1] = 255 * ((i >> green_shift) & green_mask) / green_mask;
|
||||
line_ptr[2] = 255 * ((i >> blue_shift) & blue_mask) / blue_mask;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 32 :
|
||||
if (image->byte_order == LSBFirst) {
|
||||
// Little-endian...
|
||||
for (x = image->width, line_ptr = line;
|
||||
x > 0;
|
||||
x --, line_ptr += d, pixel += 4) {
|
||||
i = (((((pixel[3] << 8) | pixel[2]) << 8) | pixel[1]) << 8) | pixel[0];
|
||||
|
||||
line_ptr[0] = 255 * ((i >> red_shift) & red_mask) / red_mask;
|
||||
line_ptr[1] = 255 * ((i >> green_shift) & green_mask) / green_mask;
|
||||
line_ptr[2] = 255 * ((i >> blue_shift) & blue_mask) / blue_mask;
|
||||
}
|
||||
} else {
|
||||
// Big-endian...
|
||||
for (x = image->width, line_ptr = line;
|
||||
x > 0;
|
||||
x --, line_ptr += d, pixel += 4) {
|
||||
i = (((((pixel[0] << 8) | pixel[1]) << 8) | pixel[2]) << 8) | pixel[3];
|
||||
|
||||
line_ptr[0] = 255 * ((i >> red_shift) & red_mask) / red_mask;
|
||||
line_ptr[1] = 255 * ((i >> green_shift) & green_mask) / green_mask;
|
||||
line_ptr[2] = 255 * ((i >> blue_shift) & blue_mask) / blue_mask;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy the X image we've read and return the RGB(A) image...
|
||||
XDestroyImage(image);
|
||||
|
||||
return p;
|
||||
}
|
23
evoke/Logout.h
Normal file
23
evoke/Logout.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Evoke, head honcho of everything
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2000-2007 EDE Authors.
|
||||
*
|
||||
* This program is licensed under terms of the
|
||||
* GNU General Public License version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#ifndef __LOGOUT_H__
|
||||
#define __LOGOUT_H__
|
||||
|
||||
#define LOGOUT_CANCEL 0
|
||||
#define LOGOUT_LOGOUT 1
|
||||
#define LOGOUT_RESTART 2
|
||||
#define LOGOUT_SHUTDOWN 3
|
||||
|
||||
int logout_dialog(int screen_w, int screen_h, bool disable_restart = 0, bool disable_shutdown = 0);
|
||||
|
||||
#endif
|
5
evoke/doc/evoke.txt
Normal file
5
evoke/doc/evoke.txt
Normal file
@ -0,0 +1,5 @@
|
||||
Evoke documentation
|
||||
===================
|
||||
|
||||
Evoke is EDE head service responsible for starting environment, running
|
||||
requested applications and shutting down environment respectively.
|
@ -3,24 +3,29 @@
|
||||
[evoke]
|
||||
Startup = edewm,eiconman,eworkpanel,xscreensaver
|
||||
ImagesDirectory = images
|
||||
# ImagesDirectory = /home/sanel/blentavo/EDE/ede2/evoke/images
|
||||
Splash = splash-alpha1.png
|
||||
|
||||
[edewm]
|
||||
Icon = edewm.png
|
||||
Exec = gvim
|
||||
# Exec = edewm
|
||||
Description = window manager
|
||||
|
||||
[eiconman]
|
||||
Icon = eiconman.png
|
||||
Exec = mozilla
|
||||
# Exec = /home/sanel/blentavo/EDE/ede2/eiconman/eiconman
|
||||
Description = desktop
|
||||
|
||||
[eworkpanel]
|
||||
Icon = eworkpanel.png
|
||||
Exec = mrxvt -bg black
|
||||
# Exec = eworkpanel
|
||||
Description = panel
|
||||
|
||||
[xscreensaver]
|
||||
Icon = xscreensaver.png
|
||||
Exec = rxvt
|
||||
# Exec = xscreensaver -nosplash
|
||||
Description = screensaver
|
||||
|
@ -63,6 +63,7 @@ void help(void) {
|
||||
puts(" -s, --startup run in starup mode");
|
||||
puts(" -n, --no-splash do not show splash screen in starup mode");
|
||||
puts(" -d, --dry-run run in starup mode, but don't execute anything");
|
||||
puts(" -a, --autostart read autostart directory");
|
||||
puts(" -c, --config [FILE] use FILE as config file");
|
||||
puts(" -p, --pid [FILE] use FILE to store PID number");
|
||||
puts(" -l, --log [FILE] log traffic to FILE (FILE can be stdout/stderr for console output)\n");
|
||||
@ -73,9 +74,10 @@ int main(int argc, char** argv) {
|
||||
const char* pid_file = NULL;
|
||||
const char* log_file = NULL;
|
||||
|
||||
bool do_startup = 0;
|
||||
bool do_dryrun = 0;
|
||||
bool no_splash = 0;
|
||||
bool do_startup = 0;
|
||||
bool do_dryrun = 0;
|
||||
bool no_splash = 0;
|
||||
bool do_autostart = 0;
|
||||
|
||||
if(argc > 1) {
|
||||
const char* a;
|
||||
@ -112,6 +114,8 @@ int main(int argc, char** argv) {
|
||||
do_dryrun = 1;
|
||||
else if(CHECK_ARGV(a, "-n", "--no-splash"))
|
||||
no_splash = 1;
|
||||
else if(CHECK_ARGV(a, "-a", "--autostart"))
|
||||
do_autostart = 1;
|
||||
else {
|
||||
printf("Unknown parameter '%s'. Run '"APPNAME" -h' for options\n", a);
|
||||
return 1;
|
||||
@ -152,6 +156,10 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if(do_autostart) {
|
||||
service->init_autostart();
|
||||
}
|
||||
|
||||
service->setup_atoms(fl_display);
|
||||
|
||||
signal(SIGINT, quit_signal);
|
||||
|
35
evoke/logout.fl
Normal file
35
evoke/logout.fl
Normal file
@ -0,0 +1,35 @@
|
||||
# data file for the Fltk User Interface Designer (fluid)
|
||||
version 1.0108
|
||||
header_name {.h}
|
||||
code_name {.cxx}
|
||||
Function {} {open selected
|
||||
} {
|
||||
Fl_Window {} {open
|
||||
xywh {365 265 325 185} type Double visible
|
||||
} {
|
||||
Fl_Box {} {
|
||||
label {Logout, restart or shut down the computer ?}
|
||||
xywh {10 9 305 39} labelfont 1 align 148
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {&Cancel}
|
||||
xywh {225 150 90 25}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {&OK}
|
||||
xywh {130 150 90 25}
|
||||
}
|
||||
Fl_Round_Button {} {
|
||||
label {Logout from the current session}
|
||||
xywh {25 60 275 20} down_box ROUND_DOWN_BOX
|
||||
}
|
||||
Fl_Round_Button {} {
|
||||
label {Restart the computer}
|
||||
xywh {25 85 215 20} down_box ROUND_DOWN_BOX
|
||||
}
|
||||
Fl_Round_Button {} {
|
||||
label {Shut down the computer}
|
||||
xywh {25 110 215 20} down_box ROUND_DOWN_BOX
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
# data file for the Fltk User Interface Designer (fluid)
|
||||
version 1.0108
|
||||
header_name {.h}
|
||||
code_name {.cxx}
|
||||
Function {} {open selected
|
||||
} {
|
||||
Fl_Window {} {open
|
||||
xywh {365 175 480 365} type Double visible
|
||||
} {
|
||||
Fl_Box {} {
|
||||
image {splash-alpha1.png} xywh {0 0 480 364} labelsize 14
|
||||
}
|
||||
Fl_Box {} {
|
||||
label {Starting window manager...}
|
||||
xywh {20 322 440 23} labelsize 14 align 16
|
||||
}
|
||||
Fl_Box {} {
|
||||
image {../../../../.icons/edeneu/32x32/actions/address-book-new.png} xywh {135 259 60 53} labelsize 14
|
||||
}
|
||||
Fl_Box {} {
|
||||
image {../../../../.icons/edeneu/32x32/actions/appointment-new.png} xywh {200 259 60 53} labelsize 14
|
||||
}
|
||||
Fl_Box {} {
|
||||
image {../../../../.icons/edeneu/32x32/apps/evolution.png} xywh {265 259 60 53} labelsize 14
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user