mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Let ede-launch use xterm if TERM was inherited from login console.
Dumping usage of FL_SHOW event in ede-panel; everything is now handled in Panel::show(). Call Panel::hide() even if ede-panel was ended/killed with outside signal; with this configuration file will be stored. Remember panel position (top/bottom).
This commit is contained in:
parent
200fdd8e4c
commit
bafdb44a10
@ -272,7 +272,9 @@ static void ok_cb(Fl_Widget*, void* w) {
|
||||
if(in_term->value()) {
|
||||
char buf[128];
|
||||
char* term = getenv("TERM");
|
||||
if(!term)
|
||||
|
||||
/* also check if TERM get inherited from login console */
|
||||
if(!term || strcmp(term, "linux") == 0)
|
||||
term = "xterm";
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s -e %s", term, cmd);
|
||||
|
@ -165,6 +165,38 @@ static void move_widget(Panel *self, Fl_Widget *o, int &sx, int &sy) {
|
||||
}
|
||||
#endif
|
||||
|
||||
Panel::Panel() : PanelWindow(300, 30) {
|
||||
clicked = 0;
|
||||
sx = sy = 0;
|
||||
vpos = PANEL_POSITION_BOTTOM;
|
||||
screen_x = screen_y = screen_w = screen_h = 0;
|
||||
screen_h_half = 0;
|
||||
can_move_widgets = false;
|
||||
|
||||
box(FL_UP_BOX);
|
||||
read_config();
|
||||
}
|
||||
|
||||
void Panel::read_config(void) {
|
||||
Resource r;
|
||||
if(!r.load("ede-panel"))
|
||||
return;
|
||||
|
||||
int p;
|
||||
if(r.get("Panel", "position", p, PANEL_POSITION_BOTTOM)) {
|
||||
if((p != PANEL_POSITION_TOP) && (p != PANEL_POSITION_BOTTOM))
|
||||
p = PANEL_POSITION_BOTTOM;
|
||||
}
|
||||
|
||||
vpos = p;
|
||||
}
|
||||
|
||||
void Panel::save_config(void) {
|
||||
Resource r;
|
||||
r.set("Panel", "position", vpos);
|
||||
r.save("ede-panel");
|
||||
}
|
||||
|
||||
void Panel::do_layout(void) {
|
||||
E_RETURN_IF_FAIL(mgr.napplets() > 0);
|
||||
|
||||
@ -231,7 +263,7 @@ void Panel::do_layout(void) {
|
||||
/*
|
||||
* Code for horizontal streching.
|
||||
*
|
||||
* FIXME: This code pretty sucks and need better rewrite in future.
|
||||
* FIXME: This code pretty sucks and need better rewrite in the future.
|
||||
* To work properly, applets that will be streched must be successive or everything will be
|
||||
* messed up. Also, applets that are placed right2left does not work with it; they will be resized to right.
|
||||
*/
|
||||
@ -281,30 +313,35 @@ void Panel::show(void) {
|
||||
if(!netwm_get_workarea(X, Y, W, H))
|
||||
Fl::screen_xywh(X, Y, W, H);
|
||||
|
||||
resize(X, Y + H - DEFAULT_PANEL_H, W, DEFAULT_PANEL_H);
|
||||
|
||||
screen_x = X;
|
||||
screen_y = Y;
|
||||
screen_w = W;
|
||||
screen_h = H;
|
||||
screen_h_half = screen_h / 2;
|
||||
|
||||
/* set size as soon as possible, since do_layout() depends on it */
|
||||
size(W, DEFAULT_PANEL_H);
|
||||
|
||||
do_layout();
|
||||
window_xid_create(this, netwm_make_me_dock);
|
||||
|
||||
/* position it, this is done after XID was created */
|
||||
if(vpos == PANEL_POSITION_BOTTOM) {
|
||||
position(screen_x, screen_h - h());
|
||||
netwm_set_window_strut(this, 0, 0, 0, h());
|
||||
} else {
|
||||
/* FIXME: this does not work well with edewm (nor pekwm). kwin do it correctly. */
|
||||
position(screen_x, screen_y);
|
||||
netwm_set_window_strut(this, 0, 0, h(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Panel::hide(void) {
|
||||
save_config();
|
||||
}
|
||||
|
||||
int Panel::handle(int e) {
|
||||
switch(e) {
|
||||
case FL_SHOW: {
|
||||
int ret = PanelWindow::handle(e);
|
||||
position(0, screen_h - h());
|
||||
|
||||
if(shown())
|
||||
netwm_set_window_strut(this, 0, 0, 0, h());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
case FL_PUSH:
|
||||
clicked = Fl::belowmouse();
|
||||
|
||||
@ -319,29 +356,21 @@ int Panel::handle(int e) {
|
||||
return 1;
|
||||
|
||||
case FL_DRAG: {
|
||||
#if 0
|
||||
if(clicked && clicked->takesevents()) {
|
||||
cursor(FL_CURSOR_MOVE);
|
||||
/* moving the child */
|
||||
//move_widget(this, clicked, sx, sy);
|
||||
clicked->handle(e);
|
||||
} else {
|
||||
#endif
|
||||
cursor(FL_CURSOR_MOVE);
|
||||
/* are moving the panel; only vertical moving is supported */
|
||||
/* are moving the panel; only vertical moving is supported */
|
||||
cursor(FL_CURSOR_MOVE);
|
||||
|
||||
/* snap it to the top or bottom, depending on pressed mouse location */
|
||||
if(Fl::event_y_root() <= screen_h_half && y() > screen_h_half) {
|
||||
position(screen_x, screen_y);
|
||||
netwm_set_window_strut(this, 0, 0, h(), 0);
|
||||
}
|
||||
/* snap it to the top or bottom, depending on pressed mouse location */
|
||||
if(Fl::event_y_root() <= screen_h_half && y() > screen_h_half) {
|
||||
position(screen_x, screen_y);
|
||||
netwm_set_window_strut(this, 0, 0, h(), 0);
|
||||
vpos = PANEL_POSITION_TOP;
|
||||
}
|
||||
|
||||
if(Fl::event_y_root() > screen_h_half && y() < screen_h_half) {
|
||||
/* TODO: use area x and area y */
|
||||
position(screen_x, screen_h - h());
|
||||
netwm_set_window_strut(this, 0, 0, 0, h());
|
||||
}
|
||||
// }
|
||||
if(Fl::event_y_root() > screen_h_half && y() < screen_h_half) {
|
||||
position(screen_x, screen_h - h());
|
||||
netwm_set_window_strut(this, 0, 0, 0, h());
|
||||
vpos = PANEL_POSITION_BOTTOM;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -360,7 +389,6 @@ int Panel::handle(int e) {
|
||||
/* do not quit on Esc key */
|
||||
if(Fl::event_key() == FL_Escape)
|
||||
return 1;
|
||||
|
||||
/* fallthrough */
|
||||
}
|
||||
|
||||
|
@ -9,24 +9,31 @@
|
||||
|
||||
EDELIB_NS_USING_AS(Window, PanelWindow)
|
||||
|
||||
enum {
|
||||
PANEL_POSITION_TOP,
|
||||
PANEL_POSITION_BOTTOM
|
||||
};
|
||||
|
||||
class Panel : public PanelWindow {
|
||||
private:
|
||||
Fl_Widget *clicked;
|
||||
int vpos;
|
||||
int sx, sy;
|
||||
int screen_x, screen_y, screen_w, screen_h, screen_h_half;
|
||||
bool can_move_widgets;
|
||||
|
||||
AppletManager mgr;
|
||||
|
||||
void read_config(void);
|
||||
void save_config(void);
|
||||
void do_layout(void);
|
||||
|
||||
public:
|
||||
Panel() : PanelWindow(300, 30), clicked(0), sx(0), sy(0),
|
||||
screen_x(0), screen_y(0), screen_w(0), screen_h(0), screen_h_half(0), can_move_widgets(false)
|
||||
{ box(FL_UP_BOX); }
|
||||
Panel();
|
||||
|
||||
int handle(int e);
|
||||
void show(void);
|
||||
void hide(void);
|
||||
int handle(int e);
|
||||
void load_applets(void);
|
||||
|
||||
int panel_w(void) { return w(); }
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <signal.h>
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Double_Window.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
@ -5,9 +6,26 @@
|
||||
#include "Panel.h"
|
||||
#include "AppletManager.h"
|
||||
|
||||
static bool running;
|
||||
|
||||
static void exit_signal(int signum) {
|
||||
running = false;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Panel* panel = new Panel();
|
||||
signal(SIGTERM, exit_signal);
|
||||
signal(SIGKILL, exit_signal);
|
||||
signal(SIGINT, exit_signal);
|
||||
|
||||
Panel *panel = new Panel();
|
||||
panel->load_applets();
|
||||
panel->show();
|
||||
return Fl::run();
|
||||
running = true;
|
||||
|
||||
while(running)
|
||||
Fl::wait();
|
||||
|
||||
/* so Panel::hide() can be called */
|
||||
panel->hide();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user