Removed leftovers from sound stuff.

Replaced hardcoded values for screen sizes used by logout dialog with passed values.
Removed spawn_backtrace() function; not used any more.
Some code reordering
This commit is contained in:
Sanel Zukan 2008-09-08 11:09:37 +00:00
parent 12174af67d
commit 65492f45b7
11 changed files with 78 additions and 136 deletions

View File

@ -10,12 +10,13 @@
* See COPYING for details. * See COPYING for details.
*/ */
#include "Log.h" #include <sys/types.h> // getpid
#include "Logout.h" #include <unistd.h> // pipe
#include "EvokeService.h" #include <fcntl.h> // fcntl
#include "Splash.h" #include <stdlib.h> // free
#include "Spawn.h" #include <string.h> // strdup, memset
#include "Autostart.h" #include <errno.h>
#include <signal.h>
#include <edelib/File.h> #include <edelib/File.h>
#include <edelib/Config.h> #include <edelib/Config.h>
@ -27,15 +28,14 @@
#include <edelib/MessageBox.h> #include <edelib/MessageBox.h>
#include <edelib/Nls.h> #include <edelib/Nls.h>
#include <sys/types.h> // getpid #include "Log.h"
#include <unistd.h> // pipe #include "Logout.h"
#include <fcntl.h> // fcntl #include "EvokeService.h"
#include <stdlib.h> // free #include "Splash.h"
#include <string.h> // strdup, memset #include "Spawn.h"
#include <errno.h> #include "Autostart.h"
#include <signal.h>
void resolve_path(const edelib::String& datadir, edelib::String& item, bool have_datadir) { static void resolve_path(const edelib::String& datadir, edelib::String& item, bool have_datadir) {
if(item.empty()) if(item.empty())
return; return;
@ -51,7 +51,7 @@ void resolve_path(const edelib::String& datadir, edelib::String& item, bool have
} }
} }
char* get_basename(const char* path) { static char* get_basename(const char* path) {
char* p = strrchr(path, '/'); char* p = strrchr(path, '/');
if(p) if(p)
return (p + 1); return (p + 1);
@ -72,7 +72,7 @@ char* get_basename(const char* path) {
* Alternative would be to sort items (by their basename) and apply consecutive unique on * Alternative would be to sort items (by their basename) and apply consecutive unique on
* them, but... is it worth ? * them, but... is it worth ?
*/ */
void basename_unique(StringList& lst) { static void basename_unique(StringList& lst) {
if(lst.empty()) if(lst.empty())
return; return;
@ -95,7 +95,7 @@ void basename_unique(StringList& lst) {
} }
} }
int get_int_property_value(Atom at) { static int get_int_property_value(Atom at) {
Atom real; Atom real;
int format; int format;
unsigned long n, extra; unsigned long n, extra;
@ -112,7 +112,7 @@ int get_int_property_value(Atom at) {
return ret; return ret;
} }
int get_string_property_value(Atom at, char* txt, int txt_len) { static int get_string_property_value(Atom at, char* txt, int txt_len) {
XTextProperty names; XTextProperty names;
XGetTextProperty(fl_display, RootWindow(fl_display, fl_screen), &names, at); XGetTextProperty(fl_display, RootWindow(fl_display, fl_screen), &names, at);
if(!names.nitems || !names.value) if(!names.nitems || !names.value)
@ -136,7 +136,7 @@ int get_string_property_value(Atom at, char* txt, int txt_len) {
* XmuClientWindow() will return parent window of given window; this is used so we don't * XmuClientWindow() will return parent window of given window; this is used so we don't
* send delete message to some button or else, but it's parent. * send delete message to some button or else, but it's parent.
*/ */
Window mu_try_children(Display* dpy, Window win, Atom wm_state) { static Window mu_try_children(Display* dpy, Window win, Atom wm_state) {
Atom real; Atom real;
Window root, parent; Window root, parent;
Window* children = 0; Window* children = 0;
@ -167,7 +167,7 @@ Window mu_try_children(Display* dpy, Window win, Atom wm_state) {
return ret; return ret;
} }
Window mu_client_window(Display* dpy, Window win, Atom wm_state) { static Window mu_client_window(Display* dpy, Window win, Atom wm_state) {
Atom real; Atom real;
int format; int format;
unsigned long n, extra; unsigned long n, extra;
@ -193,7 +193,7 @@ void service_watcher_cb(int pid, int signum) {
EvokeService::instance()->service_watcher(pid, signum); EvokeService::instance()->service_watcher(pid, signum);
} }
void wake_up_cb(int fd, void* v) { static void wake_up_cb(int fd, void* v) {
EvokeService::instance()->wake_up(fd); EvokeService::instance()->wake_up(fd);
} }
@ -313,10 +313,6 @@ bool EvokeService::init_splash(const char* config, bool no_splash, bool dry_run)
if(c.get("evoke", "Splash", buff, sizeof(buff))) if(c.get("evoke", "Splash", buff, sizeof(buff)))
splashimg = buff; splashimg = buff;
edelib::String sound;
if(c.get("evoke", "Sound", buff, sizeof(buff)))
sound = buff;
// Startup key must exists // Startup key must exists
if(!c.get("evoke", "Startup", buff, sizeof(buff))) if(!c.get("evoke", "Startup", buff, sizeof(buff)))
return false; return false;
@ -356,7 +352,6 @@ bool EvokeService::init_splash(const char* config, bool no_splash, bool dry_run)
* since Splash expects that. * since Splash expects that.
*/ */
resolve_path(datadir, splashimg, have_datadir); resolve_path(datadir, splashimg, have_datadir);
resolve_path(datadir, sound, have_datadir);
ClientListIter it, it_end; ClientListIter it, it_end;
for(it = clients.begin(), it_end = clients.end(); it != it_end; ++it) for(it = clients.begin(), it_end = clients.end(); it != it_end; ++it)
@ -365,7 +360,6 @@ bool EvokeService::init_splash(const char* config, bool no_splash, bool dry_run)
Splash sp(no_splash, dry_run); Splash sp(no_splash, dry_run);
sp.set_clients(&clients); sp.set_clients(&clients);
sp.set_background(&splashimg); sp.set_background(&splashimg);
sp.set_sound(&sound);
sp.run(); sp.run();

View File

@ -13,18 +13,17 @@
#ifndef __EVOKESERVICE_H__ #ifndef __EVOKESERVICE_H__
#define __EVOKESERVICE_H__ #define __EVOKESERVICE_H__
#include "Log.h" #include <FL/x.h>
#include "Xsm.h" #include <pthread.h>
#ifdef HAVE_COMPOSITE
#include "Composite.h"
#endif
#include <edelib/List.h> #include <edelib/List.h>
#include <edelib/String.h> #include <edelib/String.h>
#include <FL/x.h> #include "Log.h"
#include <pthread.h> #include "Xsm.h"
#ifdef HAVE_COMPOSITE
#include "Composite.h"
#endif
struct EvokeClient { struct EvokeClient {
edelib::String desc; // short program description (used in Starting... message) edelib::String desc; // short program description (used in Starting... message)

View File

@ -35,9 +35,9 @@ LinkAgainst evoke : -lXcomposite -lXdamage -lXfixes -lXrender ;
#LinkAgainst evoke : -lpthread ; #LinkAgainst evoke : -lpthread ;
EdeProgram evoke : $(SOURCE) ; EdeProgram evoke : $(SOURCE) ;
FltkProgramBare test/evoke_test : test/evoke_test.cpp ; FltkProgramBare test/evoke_test : test/evoke_test.cpp : "noinstall" ;
FltkProgramBare test/stress_test : test/stress_test.cpp ; FltkProgramBare test/stress_test : test/stress_test.cpp : "noinstall" ;
FltkProgramBare test/opacity_test : test/opacity_test.cpp ; FltkProgramBare test/opacity_test : test/opacity_test.cpp : "noinstall" ;
#TranslationStrings locale : $(SOURCE) ; #TranslationStrings locale : $(SOURCE) ;
EdeManual doc/evoke.txt ; EdeManual doc/evoke.txt ;

View File

@ -10,9 +10,6 @@
* See COPYING for details. * See COPYING for details.
*/ */
#include "Logout.h"
#include <edelib/Nls.h>
#include <FL/Fl_Double_Window.h> #include <FL/Fl_Double_Window.h>
#include <FL/Fl_Box.h> #include <FL/Fl_Box.h>
#include <FL/Fl_Button.h> #include <FL/Fl_Button.h>
@ -22,6 +19,9 @@
#include <FL/x.h> #include <FL/x.h>
#include <string.h> // memset #include <string.h> // memset
#include <edelib/Nls.h>
#include "Logout.h"
static int logout_ret; static int logout_ret;
static Fl_Double_Window* win; static Fl_Double_Window* win;
static Fl_Round_Button* rb1; static Fl_Round_Button* rb1;
@ -31,7 +31,7 @@ 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* 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); unsigned char* make_darker(unsigned char *p, int X, int Y, int w, int h);
void rb_cb(Fl_Widget*, void* r) { static void rb_cb(Fl_Widget*, void* r) {
Fl_Round_Button* rb = (Fl_Round_Button*)r; Fl_Round_Button* rb = (Fl_Round_Button*)r;
if(rb == rb2) { if(rb == rb2) {
rb1->value(0); rb1->value(0);
@ -47,7 +47,7 @@ void rb_cb(Fl_Widget*, void* r) {
rb->value(1); rb->value(1);
} }
void ok_cb(Fl_Widget*, void*) { static void ok_cb(Fl_Widget*, void*) {
if(rb1->value()) if(rb1->value())
logout_ret = LOGOUT_LOGOUT; logout_ret = LOGOUT_LOGOUT;
else if(rb2->value()) else if(rb2->value())
@ -57,7 +57,7 @@ void ok_cb(Fl_Widget*, void*) {
win->hide(); win->hide();
} }
void cancel_cb(Fl_Widget*, void*) { static void cancel_cb(Fl_Widget*, void*) {
logout_ret = LOGOUT_CANCEL; logout_ret = LOGOUT_CANCEL;
win->hide(); win->hide();
} }
@ -73,7 +73,7 @@ int logout_dialog(int screen_w, int screen_h, bool disable_restart, bool disable
win = new Fl_Double_Window(0, 0, screen_w, screen_h, _("Logout, restart or shutdown")); win = new Fl_Double_Window(0, 0, screen_w, screen_h, _("Logout, restart or shutdown"));
win->begin(); win->begin();
Fl_Box* bb = new Fl_Box(0, 0, win->w(), win->h()); Fl_Box* bb = new Fl_Box(0, 0, win->w(), win->h());
Fl_RGB_Image* img = new Fl_RGB_Image(imgdata, 1024, 768); Fl_RGB_Image* img = new Fl_RGB_Image(imgdata, win->w(), win->h());
img->alloc_array = 1; img->alloc_array = 1;
bb->image(img); bb->image(img);
@ -113,6 +113,7 @@ int logout_dialog(int screen_w, int screen_h, bool disable_restart, bool disable
g->position(screen_w/2 - g->w()/2, screen_h/2 - g->h()/2); g->position(screen_w/2 - g->w()/2, screen_h/2 - g->h()/2);
//win->position(screen_w/2 - win->w()/2, screen_h/2 - win->h()/2);
win->end(); win->end();
win->clear_border(); win->clear_border();

View File

@ -10,7 +10,6 @@
* See COPYING for details. * See COPYING for details.
*/ */
#include "Spawn.h"
#include <sys/types.h> // fork #include <sys/types.h> // fork
#include <unistd.h> // fork, open, close, dup #include <unistd.h> // fork, open, close, dup
@ -21,10 +20,11 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/time.h> // getrlimit, setrlimit #include <sys/time.h> // getrlimit, setrlimit
#include <sys/resource.h> // #include <sys/resource.h> //
#include "Spawn.h"
extern char** environ; extern char** environ;
SignalWatch* global_watch = 0; SignalWatch* global_watch = 0;
@ -152,52 +152,3 @@ int spawn_program_with_core(const char* cmd, SignalWatch* wf, pid_t* child_pid_r
return ret; return ret;
} }
int spawn_backtrace(const char* gdb_path, const char* program, const char* core, const char* output, const char* script) {
const char* gdb_script = "bt\nquit\n";
const int gdb_script_len = 8;
//signal(SIGCHLD, SIG_DFL);
// file with gdb commands
int sfd = open(script, O_WRONLY | O_TRUNC | O_CREAT, 0770);
if(sfd == -1)
return -1;
write(sfd, gdb_script, gdb_script_len);
close(sfd);
// output file with gdb backtrace
int ofd = open(output, O_WRONLY | O_TRUNC | O_CREAT, 0770);
if(ofd == -1)
return -1;
pid_t pid = fork();
if(pid == -1) {
close(ofd);
return -1;
} else if(pid == 0) {
dup2(ofd, 1);
close(ofd);
char* argv[8];
argv[0] = (char*)gdb_path;
argv[1] = "--quiet";
argv[2] = "--batch";
argv[3] = "-x";
argv[4] = (char*)script;
argv[5] = (char*)program;
argv[6] = (char*)core;
argv[7] = 0;
execvp(argv[0], argv);
return -1;
} else {
int status;
if(waitpid(pid, &status, 0) != pid)
return -1;
}
return 0;
}

View File

@ -36,6 +36,5 @@ typedef void (SignalWatch)(int pid, int status);
int spawn_program(const char* cmd, SignalWatch* wf = 0, pid_t* child_pid_ret = 0, const char* ofile = 0); int spawn_program(const char* cmd, SignalWatch* wf = 0, pid_t* child_pid_ret = 0, const char* ofile = 0);
int spawn_program_with_core(const char* cmd, SignalWatch* wf = 0, pid_t* child_pid_ret = 0); int spawn_program_with_core(const char* cmd, SignalWatch* wf = 0, pid_t* child_pid_ret = 0);
int spawn_backtrace(const char* gdb_path, const char* program, const char* core, const char* output, const char* script);
#endif #endif

View File

@ -10,17 +10,17 @@
* See COPYING for details. * See COPYING for details.
*/ */
#include "Splash.h" #include <stdio.h> // snprintf
#include "Spawn.h"
#include <FL/Fl_Shared_Image.h>
#include <FL/Fl.h>
#include <edelib/Run.h> #include <edelib/Run.h>
#include <edelib/Debug.h> #include <edelib/Debug.h>
#include <edelib/Nls.h> #include <edelib/Nls.h>
#include <FL/Fl_Shared_Image.h> #include "Splash.h"
#include <FL/Fl.h> #include "Spawn.h"
#include <stdio.h> // snprintf
#define TIMEOUT_START 0.5 // timeout when splash is first time shown (also for first client) #define TIMEOUT_START 0.5 // timeout when splash is first time shown (also for first client)
#define TIMEOUT_CONTINUE 2.0 // timeout between starting rest of the cliens #define TIMEOUT_CONTINUE 2.0 // timeout between starting rest of the cliens
@ -28,9 +28,9 @@
extern void service_watcher_cb(int pid, int signum); extern void service_watcher_cb(int pid, int signum);
#ifndef EDEWM_HAVE_NET_SPLASH #ifndef EDEWM_HAVE_NET_SPLASH
Splash* global_splash = NULL; static Splash* global_splash = NULL;
int splash_xmessage_handler(int e) { static int splash_xmessage_handler(int e) {
if(fl_xevent->type == MapNotify) { if(fl_xevent->type == MapNotify) {
XRaiseWindow(fl_display, fl_xid(global_splash)); XRaiseWindow(fl_display, fl_xid(global_splash));
return 1; return 1;
@ -51,7 +51,7 @@ int splash_xmessage_handler(int e) {
* repeatedly call runner() untill all clients are * repeatedly call runner() untill all clients are
* started then hide splash window * started then hide splash window
*/ */
void runner_cb(void* s) { static void runner_cb(void* s) {
Splash* sp = (Splash*)s; Splash* sp = (Splash*)s;
if(sp->next_client()) if(sp->next_client())
@ -93,7 +93,7 @@ void Splash::show(void) {
#endif #endif
void Splash::run(void) { void Splash::run(void) {
EASSERT(clist != NULL); E_ASSERT(clist != NULL);
if(no_splash) { if(no_splash) {
while(next_client_nosplash()) while(next_client_nosplash())
@ -223,7 +223,7 @@ bool Splash::next_client(void) {
} }
EASSERT(counter < clist->size() && "Internal error; 'counter' out of bounds"); E_ASSERT(counter < clist->size() && "Internal error; 'counter' out of bounds");
char buff[1024]; char buff[1024];
const char* msg = (*clist_it).desc.c_str(); const char* msg = (*clist_it).desc.c_str();
@ -257,7 +257,7 @@ bool Splash::next_client_nosplash(void) {
return false; return false;
} }
EASSERT(counter < clist->size() && "Internal error; 'counter' out of bounds"); E_ASSERT(counter < clist->size() && "Internal error; 'counter' out of bounds");
char buff[1024]; char buff[1024];
const char* msg = (*clist_it).desc.c_str(); const char* msg = (*clist_it).desc.c_str();

View File

@ -22,7 +22,6 @@ class Splash : public Fl_Double_Window {
private: private:
ClientList* clist; ClientList* clist;
const edelib::String* bkg; const edelib::String* bkg;
const edelib::String* sound;
unsigned int counter; unsigned int counter;
bool no_splash; bool no_splash;
bool dry_run; bool dry_run;
@ -42,7 +41,6 @@ class Splash : public Fl_Double_Window {
*/ */
void set_clients(ClientList* cl) { clist = cl; } void set_clients(ClientList* cl) { clist = cl; }
void set_background(const edelib::String* s) { bkg = s; } void set_background(const edelib::String* s) { bkg = s; }
void set_sound(const edelib::String* s) { sound = s; }
const ClientList* get_clients(void) const { return clist; } const ClientList* get_clients(void) const { return clist; }
bool next_client(void); bool next_client(void);

View File

@ -10,7 +10,12 @@
* See COPYING for details. * See COPYING for details.
*/ */
#include "Xsm.h" #include <string.h>
#include <limits.h>
#include <FL/x.h>
#include <X11/Xresource.h>
#include <edelib/Debug.h> #include <edelib/Debug.h>
#include <edelib/TiXml.h> #include <edelib/TiXml.h>
#include <edelib/File.h> #include <edelib/File.h>
@ -19,12 +24,8 @@
#include <edelib/Util.h> #include <edelib/Util.h>
#include <edelib/Directory.h> #include <edelib/Directory.h>
#include <edelib/XSettingsCommon.h> #include <edelib/XSettingsCommon.h>
#include <string.h>
#include <limits.h>
#include <FL/x.h> #include "Xsm.h"
#include <X11/Xresource.h>
#define USER_XRESOURCE ".Xdefaults" #define USER_XRESOURCE ".Xdefaults"
#define USER_XRESOURCE_TMP ".Xdefaults-tmp" #define USER_XRESOURCE_TMP ".Xdefaults-tmp"
@ -41,7 +42,7 @@ struct ResourceMap {
* highest priority and will override all previous classes (X Resource class, not C++ one :P) * highest priority and will override all previous classes (X Resource class, not C++ one :P)
* with the same xresource_key. * with the same xresource_key.
*/ */
ResourceMap resource_map [] = { static ResourceMap resource_map [] = {
{ "Fltk/Background2", "background", "*Text" }, { "Fltk/Background2", "background", "*Text" },
{ "Fltk/Background", "background", "*" }, { "Fltk/Background", "background", "*" },
{ "Fltk/Foreground", "foreground", "*" } { "Fltk/Foreground", "foreground", "*" }
@ -49,7 +50,7 @@ ResourceMap resource_map [] = {
#define RESOURCE_MAP_SIZE(x) (sizeof(x)/sizeof(x[0])) #define RESOURCE_MAP_SIZE(x) (sizeof(x)/sizeof(x[0]))
int ignore_xerrors(Display* display, XErrorEvent* xev) { static int ignore_xerrors(Display* display, XErrorEvent* xev) {
return True; return True;
} }
@ -319,6 +320,7 @@ bool Xsm::save_serialized(const char* file) {
iter = iter->next; iter = iter->next;
} }
setting_file.printf("</ede-settings>\n"); setting_file.printf("</ede-settings>\n");
setting_file.close(); setting_file.close();

View File

@ -5,8 +5,6 @@
# DataDirectory = data # DataDirectory = data
DataDirectory = /home/sanel/programs/EDE/ede2/evoke/data DataDirectory = /home/sanel/programs/EDE/ede2/evoke/data
Splash = splash-alpha1.png Splash = splash-alpha1.png
Sound = startup.ogg
# Sound = Startup1_2.ogg
[edewm] [edewm]
Icon = edewm.png Icon = edewm.png

View File

@ -10,17 +10,17 @@
* See COPYING for details. * See COPYING for details.
*/ */
#include "EvokeService.h" #include <string.h>
#include <signal.h>
#include <FL/Fl.h>
#include <FL/x.h>
#include <edelib/Config.h> #include <edelib/Config.h>
#include <edelib/Debug.h> #include <edelib/Debug.h>
#include <edelib/File.h> #include <edelib/File.h>
#include <string.h> #include <FL/Fl.h>
#include <signal.h> #include <FL/x.h>
#include "EvokeService.h"
#define FOREVER 1e20 #define FOREVER 1e20
#define CONFIG_FILE "evoke.conf" #define CONFIG_FILE "evoke.conf"
@ -34,28 +34,28 @@
#define CHECK_ARGV(argv, pshort, plong) ((strcmp(argv, pshort) == 0) || (strcmp(argv, plong) == 0)) #define CHECK_ARGV(argv, pshort, plong) ((strcmp(argv, pshort) == 0) || (strcmp(argv, plong) == 0))
void quit_signal(int sig) { static void quit_signal(int sig) {
EVOKE_LOG("Got quit signal %i\n", sig); EVOKE_LOG("Got quit signal %i\n", sig);
EvokeService::instance()->stop(); EvokeService::instance()->stop();
} }
void xmessage_handler(int, void*) { static void xmessage_handler(int, void*) {
#ifdef USE_FLTK_LOOP_EMULATION
XEvent xev; XEvent xev;
while(XEventsQueued(fl_display, QueuedAfterReading)) { while(XEventsQueued(fl_display, QueuedAfterReading)) {
XNextEvent(fl_display, &xev); XNextEvent(fl_display, &xev);
EvokeService::instance()->handle((const XEvent*)&xev); EvokeService::instance()->handle((const XEvent*)&xev);
} }
} #else
int xmessage_handler2(int) {
return EvokeService::instance()->handle(fl_xevent); return EvokeService::instance()->handle(fl_xevent);
#endif
} }
int composite_handler(int ev) { static int composite_handler(int ev) {
return EvokeService::instance()->composite_handle(fl_xevent); return EvokeService::instance()->composite_handle(fl_xevent);
} }
const char* next_param(int curr, char** argv, int argc) { static const char* next_param(int curr, char** argv, int argc) {
int j = curr + 1; int j = curr + 1;
if(j >= argc) if(j >= argc)
return NULL; return NULL;
@ -241,9 +241,9 @@ int main(int argc, char** argv) {
#else #else
/* /*
* NOTE: composite_handler() is not needed since it will be included * NOTE: composite_handler() is not needed since it will be included
* within xmessage_handler2() call * within xmessage_handler() call
*/ */
Fl::add_handler(xmessage_handler2); Fl::add_handler(xmessage_handler);
#endif #endif
service->start(); service->start();