From 7431373b292ff6ea23c029795f48d7c0ee5e56fc Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Fri, 4 Jan 2013 10:33:53 +0000 Subject: [PATCH] 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 --- ede-panel/Applet.h | 16 +++++++++++++ .../applets/quick-launch/QuickLaunch.cpp | 20 ++++++++++++++++ ede-panel/applets/taskbar/Taskbar.cpp | 23 +++++++++---------- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/ede-panel/Applet.h b/ede-panel/Applet.h index 4db5c35..5d89920 100644 --- a/ede-panel/Applet.h +++ b/ede-panel/Applet.h @@ -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 +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 *); diff --git a/ede-panel/applets/quick-launch/QuickLaunch.cpp b/ede-panel/applets/quick-launch/QuickLaunch.cpp index bbb258c..c2c712b 100644 --- a/ede-panel/applets/quick-launch/QuickLaunch.cpp +++ b/ede-panel/applets/quick-launch/QuickLaunch.cpp @@ -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 diff --git a/ede-panel/applets/taskbar/Taskbar.cpp b/ede-panel/applets/taskbar/Taskbar.cpp index b231fc6..98f9d5e 100644 --- a/ede-panel/applets/taskbar/Taskbar.cpp +++ b/ede-panel/applets/taskbar/Taskbar.cpp @@ -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();