Moving hider to panel itself, instead as separate applet.

Hider calls some Panel specific code and doing that from applet will make shit like selinux or apparmor quite unhappy (due relocations), which will refuse to start ede-panel. ...yet another workaround for that crapy security junk.
This commit is contained in:
Sanel Zukan 2013-01-04 14:36:40 +00:00
parent d09f846380
commit 7b1245f06a
9 changed files with 106 additions and 77 deletions

View File

@ -1,49 +1,41 @@
#include "Applet.h"
#include "Panel.h"
/*
* $Id: ede-panel.cpp 3463 2012-12-17 15:49:33Z karijes $
*
* Copyright (C) 2012 Sanel Zukan
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <unistd.h>
#include <FL/Fl_Button.H>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/x.H>
#include <edelib/Nls.h>
#include <edelib/Debug.h>
#include <FL/x.H>
#include "Hider.h"
#include "Panel.h"
/* delay in secs */
#define PANEL_MOVE_DELAY 0.0015
/* how fast we will move X axis */
#define PANEL_ANIM_SPEED 50
static void hide_cb(Fl_Widget*, void *h);
class Hider : public Fl_Button {
private:
int old_x, old_y, is_hidden, old_px, stop_x;
public:
Hider() : Fl_Button(0, 0, 10, 25, "@>"), old_x(0), old_y(0), is_hidden(0), old_px(0), stop_x(0) {
labelsize(8);
box(FL_FLAT_BOX);
tooltip(_("Hide panel"));
callback(hide_cb, this);
}
int panel_hidden(void) { return is_hidden; }
void panel_hidden(int s) { is_hidden = s; }
void panel_show(void);
void panel_hide(void);
void post_show(void);
void post_hide(void);
void animate(void);
};
static void hide_cb(Fl_Widget*, void *h) {
Hider *hh = (Hider*)h;
if(hh->panel_hidden())
hh->panel_show();
else
hh->panel_hide();
hh->panel_hidden() ? hh->panel_show() : hh->panel_hide();
}
static void animate_cb(void *h) {
@ -51,8 +43,15 @@ static void animate_cb(void *h) {
hh->animate();
}
Hider::Hider() : Fl_Button(0, 0, 10, 25, "@>"), old_x(0), old_y(0), is_hidden(0), old_px(0), stop_x(0) {
labelsize(8);
box(FL_FLAT_BOX);
tooltip(_("Hide panel"));
callback(hide_cb, this);
}
void Hider::animate(void) {
Panel *p = EDE_PANEL_GET_PANEL_OBJECT(this);
Panel *p = (Panel*)parent();
if(!panel_hidden()) {
/* hide */
@ -76,7 +75,8 @@ void Hider::animate(void) {
}
void Hider::panel_hide(void) {
Panel *p = EDE_PANEL_GET_PANEL_OBJECT(this);
Panel *p = (Panel*)parent();
int X, Y, W, H;
p->screen_size(X, Y, W, H);
@ -87,7 +87,7 @@ void Hider::panel_hide(void) {
}
void Hider::post_hide(void) {
Panel *p = EDE_PANEL_GET_PANEL_OBJECT(this);
Panel *p = (Panel*)parent();
/* align to bounds */
p->position(stop_x, p->y());
@ -116,7 +116,7 @@ void Hider::panel_show(void) {
}
void Hider::post_show(void) {
Panel *p = EDE_PANEL_GET_PANEL_OBJECT(this);
Panel *p = (Panel*)parent();
/* align to bounds */
p->position(old_px, p->y());
@ -136,12 +136,3 @@ void Hider::post_show(void) {
panel_hidden(0);
tooltip(_("Hide panel"));
}
EDE_PANEL_APPLET_EXPORT (
Hider,
EDE_PANEL_APPLET_OPTION_ALIGN_RIGHT,
"Hide-panel applet",
"0.1",
"empty",
"Sanel Zukan"
)

41
ede-panel/Hider.h Normal file
View File

@ -0,0 +1,41 @@
/*
* $Id: ede-panel.cpp 3463 2012-12-17 15:49:33Z karijes $
*
* Copyright (C) 2012 Sanel Zukan
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <FL/Fl_Button.H>
#ifndef __HIDER_H__
#define __HIDER_H__
class Hider : public Fl_Button {
private:
int old_x, old_y, is_hidden, old_px, stop_x;
public:
Hider();
int panel_hidden(void) { return is_hidden; }
void panel_hidden(int s) { is_hidden = s; }
void panel_show(void);
void panel_hide(void);
void post_show(void);
void post_hide(void);
void animate(void);
};
#endif

View File

@ -10,8 +10,8 @@
SubDir TOP ede-panel ;
EdeProgram ede-panel : Panel.cpp AppletManager.cpp ede-panel.cpp ;
#ObjectC++Flags Panel.cpp : -DEDE_PANEL_LOCAL_APPLETS ;
EdeProgram ede-panel : Hider.cpp Panel.cpp AppletManager.cpp ede-panel.cpp ;
ObjectC++Flags Panel.cpp : -DEDE_PANEL_LOCAL_APPLETS ;
if $(OS) != "SOLARIS" {
# also must use this flag (on anything but Solaris) or program will crash

View File

@ -32,6 +32,7 @@
#include <edelib/Netwm.h>
#include "Panel.h"
#include "Hider.h"
/* empty space from left and right panel border */
#define INITIAL_SPACING 5
@ -218,6 +219,7 @@ static void move_widget(Panel *self, Fl_Widget *o, int &sx, int &sy) {
Panel::Panel() : PanelWindow(300, 30, "ede-panel") {
gpanel = this;
hider = NULL;
clicked = 0;
sx = sy = 0;
@ -229,6 +231,9 @@ Panel::Panel() : PanelWindow(300, 30, "ede-panel") {
box(FL_UP_BOX);
read_config();
hider = new Hider();
add(hider);
}
void Panel::read_config(void) {
@ -261,7 +266,7 @@ void Panel::save_config(void) {
}
void Panel::do_layout(void) {
E_RETURN_IF_FAIL(mgr.napplets() > 0);
E_RETURN_IF_FAIL(children() > 0);
Fl_Widget *o;
unsigned long opts;
@ -276,6 +281,12 @@ void Panel::do_layout(void) {
/* first center it vertically */
center_widget_h(o, this);
/* manage hider specifically */
if(hider && o == hider) {
right.push_back(o);
continue;
}
/* could be slow, but I'm relaying how number of loaded applets will not be that large */
if(!mgr.get_applet_options(o, opts)) {
/* here are put widgets not loaded as applets */
@ -500,7 +511,6 @@ void Panel::load_applets(void) {
"start_menu.so",
"quick_launch.so",
"pager.so",
"hider.so",
"clock.so",
"taskbar.so",
"keyboard_layout.so",
@ -524,10 +534,9 @@ void Panel::load_applets(void) {
mgr.fill_group(this);
#else
mgr.load("./applets/start-menu/start_menu.so");
mgr.load("./applets/quick-launch/quick_launch.so");
mgr.load("./applets/start-menu/start_menu.so");
mgr.load("./applets/pager/pager.so");
mgr.load("./applets/hider/hider.so");
mgr.load("./applets/clock/clock.so");
mgr.load("./applets/taskbar/taskbar.so");
mgr.load("./applets/keyboard-layout/keyboard_layout.so");

View File

@ -34,9 +34,13 @@ enum {
PANEL_POSITION_BOTTOM
};
class Hider;
class Panel : public PanelWindow {
private:
Fl_Widget *clicked;
Hider *hider;
int vpos;
int sx, sy;
int screen_x, screen_y, screen_w, screen_h, screen_h_half;

View File

@ -13,7 +13,6 @@ SubDir TOP ede-panel applets ;
# SubInclude TOP ede-panel applets demo ;
SubInclude TOP ede-panel applets clock ;
SubInclude TOP ede-panel applets cpu-monitor ;
SubInclude TOP ede-panel applets hider ;
SubInclude TOP ede-panel applets mem-monitor ;
SubInclude TOP ede-panel applets keyboard-layout ;
SubInclude TOP ede-panel applets pager ;

View File

@ -1,13 +0,0 @@
#
# $Id: Jamfile 2864 2009-10-03 07:49:30Z karijes $
#
# Part of Equinox Desktop Environment (EDE).
# Copyright (c) 2012 EDE Authors.
#
# This program is licensed under terms of the
# GNU General Public License version 2 or newer.
# See COPYING for details.
SubDir TOP ede-panel applets hider ;
PanelApplet hider : Hider.cpp ;

View File

@ -68,7 +68,6 @@ static int validate_drawable(Display *d, Window xid) {
}
Tray::Tray() : Fl_Group(0, 0, 1, 25), opcode(0) {
//color(FL_RED);
box(FL_FLAT_BOX);
register_notification_area();
}

View File

@ -103,6 +103,9 @@ static void net_event_cb(int action, Window xid, void *data) {
Taskbar::Taskbar() : Fl_Group(0, 0, 40, 25), curr_active(NULL), prev_active(NULL) {
end();
//box(FL_FLAT_BOX);
//color(FL_RED);
fixed_layout = false;
ignore_workspace_value = false;
@ -227,8 +230,7 @@ void Taskbar::resize(int X, int Y, int W, int H) {
}
void Taskbar::layout_children(void) {
if(!children())
return;
if(!children()) return;
Fl_Widget *o;
int X, Y, W, reduce = 0, sz = 0, all_buttons_w = 0;
@ -252,11 +254,7 @@ void Taskbar::layout_children(void) {
all_buttons_w += DEFAULT_SPACING;
}
/*
* find reduction size
* TODO: due large number of childs, 'reduce' could be bigger than child
* width, yielding drawing issues on borders
*/
/* find reduction size */
if(all_buttons_w > W)
reduce = (all_buttons_w - W) / sz;
@ -265,11 +263,12 @@ void Taskbar::layout_children(void) {
o = child(i);
if(!o->visible()) continue;
o->resize(X, Y, o->w() - reduce, o->h());
X += o->w();
if(i != children() - 1)
X += DEFAULT_SPACING;
/*
* I'm putting -1 here to leave a small space at the end of group; this will also
* make children adaptive to not overflow group in case too many of them was created
*/
o->resize(X, Y, o->w() - reduce - 1, o->h());
X += o->w() + DEFAULT_SPACING;
}
}