Speed up removal items from group (FLTK 1.3 added faster method). Also fixing strange issue with desktop switch during minimize.

Added AppletWidget class, an experimental code for widgets that wants to accept custom methods. Needs completion though
This commit is contained in:
Sanel Zukan 2013-01-04 10:33:53 +00:00
parent 22f4e094cf
commit 7431373b29
3 changed files with 47 additions and 12 deletions

View File

@ -26,6 +26,9 @@ class Fl_Widget;
/* stored version in each applet shared library in case interface get changed */
#define EDE_PANEL_APPLET_INTERFACE_VERSION 0x01
/* random number (must be less than FL_WINDOW) so panel could know it is AppletWidget<> */
#define EDE_PANEL_APPLET_TYPE 0x27
/*
* Options assigned to each applet: how it will be resizable (horizontally or vertically)
* and how it will be aligned. Each applet is by default aligned left without resizing ability.
@ -46,6 +49,19 @@ struct AppletInfo {
unsigned long options;
};
/*
* each applet want to inherit this class if would like to exchange data with panel
* NOTE: new things could be added in future, but that will be reflected through EDE_PANEL_APPLET_INTERFACE_VERSION
*/
template <typename T>
class AppletWidget : public T {
public:
AppletWidget(int X, int Y, int W, int H, const char *l = 0) : T(X, Y, W, H, l) {
T::type(EDE_PANEL_APPLET_TYPE);
}
};
/* module stuff */
typedef Fl_Widget* (*applet_create_t)(void);
typedef void (*applet_destroy_t)(Fl_Widget *);

View File

@ -1,3 +1,23 @@
/*
* $Id$
*
* 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 "Applet.h"
#include <ctype.h>

View File

@ -97,9 +97,6 @@ Taskbar::Taskbar() : Fl_Group(0, 0, 40, 25), curr_active(NULL), prev_active(NULL
end();
fixed_layout = false;
//box(FL_FLAT_BOX);
//color(FL_RED);
update_task_buttons();
netwm_callback_add(net_event_cb, this);
}
@ -121,32 +118,32 @@ void Taskbar::update_task_buttons(void) {
int curr_workspace = netwm_workspace_get_current();
bool need_full_redraw = false;
/*
* first remove windows not available in list received by wm
*
* TODO: FLTK 1.3.x got new function remove(int index) which will make
* faster removal, comparing to remove(Fl_Widget*)
*/
for(int i = 0, found; i < children(); i++) {
found = 0;
b = (TaskButton*)child(i);
for(int j = 0; j < nwins; j++) {
if(b->get_window_xid() == wins[j]) {
/* assure this window is on current workspace */
found = 1;
break;
}
}
if(!found) {
/* FLTK since 1.3 optimized Fl_Group::remove() */
#if (FL_MAJOR_VERSION >= 1) && (FL_MINOR_VERSION >= 3)
remove(i);
#else
remove(b);
#endif
/* Fl_Group does not call delete on remove() */
delete b;
need_full_redraw = true;
}
}
/* now see which one needs to create */
/* now see which one needs to be created */
for(int i = 0, found; i < nwins; i++) {
found = 0;
@ -284,10 +281,12 @@ void Taskbar::update_active_button(bool do_redraw, int xid) {
o = (TaskButton*)child(i);
if(!o->visible()) continue;
if(o->get_window_xid() == (Window)xid)
if(o->get_window_xid() == (Window)xid) {
o->box(FL_DOWN_BOX);
else
curr_active = o;
} else {
o->box(FL_UP_BOX);
}
}
if(do_redraw) redraw();