From 8d4a1dba28b704fde23c5de799597d32896cbc7a Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Mon, 7 Apr 2008 15:35:02 +0000 Subject: [PATCH] Removed NotifyBox. It should be replaced with notification stuff Added some dbus code. Desktop changes are reported via 'org.equinoxproject.Eiconman.DesktopChanged' signal --- eiconman/Jamfile | 5 +- eiconman/NotifyBox.cpp | 114 ----------------------------------------- eiconman/NotifyBox.h | 47 ----------------- eiconman/Utils.cpp | 46 ----------------- eiconman/Utils.h | 8 --- eiconman/eiconman.cpp | 87 ++++++++----------------------- eiconman/eiconman.h | 10 ++-- 7 files changed, 27 insertions(+), 290 deletions(-) delete mode 100644 eiconman/NotifyBox.cpp delete mode 100644 eiconman/NotifyBox.h diff --git a/eiconman/Jamfile b/eiconman/Jamfile index 50a2295..c550cf4 100644 --- a/eiconman/Jamfile +++ b/eiconman/Jamfile @@ -13,9 +13,10 @@ SubDir TOP eiconman ; ObjectC++Flags DesktopIcon.cpp : -DUSE_SHAPE ; ObjectC++Flags eiconman.cpp : -DUSE_EDELIB_WINDOW ; -SOURCE = eiconman.cpp Utils.cpp Wallpaper.cpp DesktopIcon.cpp NotifyBox.cpp ; +SOURCE = eiconman.cpp Utils.cpp Wallpaper.cpp DesktopIcon.cpp ; -# LinkAgainst eiconman : -lXfixes -lXdamage ; +ObjectC++Flags $(SOURCE) : -Wno-long-long -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include ; +LinkAgainst eiconman : -L/opt/ede/lib -ledelib -ledelib_dbus -ldbus-1 ; EdeProgram eiconman : $(SOURCE) ; TranslationStrings locale : $(SOURCE) ; diff --git a/eiconman/NotifyBox.cpp b/eiconman/NotifyBox.cpp deleted file mode 100644 index 1a59670..0000000 --- a/eiconman/NotifyBox.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * $Id$ - * - * Eiconman, desktop and icon manager - * Part of Equinox Desktop Environment (EDE). - * Copyright (c) 2000-2007 EDE Authors. - * - * This program is licensed under terms of the - * GNU General Public License version 2 or newer. - * See COPYING for details. - */ - -#include "NotifyBox.h" -#include "eiconman.h" -#include - -#include -#include -#include - -#define MAX_LABEL_WIDTH 200 - -#define TIMEOUT (1.0f/60.0f) -#define TIME_SHOWN 3.0f - -NotifyBox::NotifyBox(int aw, int ah) : Fl_Window(0, 0, 10, 10) { - area_w = aw; - area_h = ah; - lwidth = lheight = 0; - is_shown = false; - - clear_border(); - set_non_modal(); - - begin(); - txt_box = new Fl_Box(0, 0, w(), h()); - txt_box->box(FL_BORDER_BOX); - txt_box->color(FL_WHITE); - txt_box->align(FL_ALIGN_WRAP); - end(); -} - -NotifyBox::~NotifyBox() { - EDEBUG("NotifyBox::~NotifyBox()\n"); -} - -void NotifyBox::update_label_size(void) { - lwidth = MAX_LABEL_WIDTH; - lheight= 0; - - fl_font(txt_box->labelfont(), txt_box->labelsize()); - fl_measure(txt_box->label(), lwidth, lheight, txt_box->align()); - - lwidth += 10; - lheight += 10; -} - -void NotifyBox::resize_all(void) { - update_label_size(); - - // center box - int x_pos = (area_w/2) - (lwidth/2); - resize(x_pos, 0, lwidth, lheight); - txt_box->resize(0, 0, w(), h()); -} - -void NotifyBox::show(void) { - if(shown()) - return; - - EDEBUG(ESTRLOC ": %i %i\n", x(), y()); - resize_all(); - - Fl_Window::show(); - is_shown = true; - Fl::add_timeout(TIME_SHOWN, visible_timeout_cb, this); -} - -void NotifyBox::hide(void) { - if(!shown()) - return; - - Fl_Window::hide(); - is_shown = false; - Fl::remove_timeout(visible_timeout_cb); - Fl::remove_timeout(animate_cb); -} - -void NotifyBox::label(const char* l) { - txt_box->label(l); - resize_all(); -} - -void NotifyBox::copy_label(const char* l) { - txt_box->copy_label(l); - resize_all(); -} - -const char* NotifyBox::label(void) { - return txt_box->label(); -} - -void NotifyBox::animate(void) { - if(y() > -lheight) { - position(x(), y() - 1); - Fl::repeat_timeout(TIMEOUT, animate_cb, this); - } else - hide(); -} - -void NotifyBox::visible_timeout(void) { - Fl::remove_timeout(visible_timeout_cb); - Fl::add_timeout(TIMEOUT, animate_cb, this); -} diff --git a/eiconman/NotifyBox.h b/eiconman/NotifyBox.h deleted file mode 100644 index 2ad3639..0000000 --- a/eiconman/NotifyBox.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * $Id$ - * - * Eiconman, desktop and icon manager - * Part of Equinox Desktop Environment (EDE). - * Copyright (c) 2000-2007 EDE Authors. - * - * This program is licensed under terms of the - * GNU General Public License version 2 or newer. - * See COPYING for details. - */ - -#ifndef __NOTIFYBOX_H__ -#define __NOTIFYBOX_H__ - -#include -#include - -class NotifyBox : public Fl_Window { - private: - bool is_shown; - int lwidth, lheight; - int area_w, area_h; - Fl_Box* txt_box; - void update_label_size(void); - void resize_all(void); - - public: - NotifyBox(int aw, int ah); - ~NotifyBox(); - - virtual void show(void); - virtual void hide(void); - bool shown(void) { return is_shown; } - - const char* label(void); - void label(const char* l); - void copy_label(const char* l); - - static void animate_cb(void* b) { ((NotifyBox*)b)->animate(); } - void animate(void); - - static void visible_timeout_cb(void* b) { ((NotifyBox*)b)->visible_timeout(); } - void visible_timeout(void); -}; - -#endif diff --git a/eiconman/Utils.cpp b/eiconman/Utils.cpp index be6231c..4fd67be 100644 --- a/eiconman/Utils.cpp +++ b/eiconman/Utils.cpp @@ -25,9 +25,6 @@ Atom _XA_NET_CURRENT_DESKTOP = 0; Atom _XA_NET_DESKTOP_NAMES = 0; Atom _XA_XROOTPMAP_ID = 0; -Atom _XA_EDE_DESKTOP_NOTIFY = 0; -Atom _XA_EDE_DESKTOP_NOTIFY_COLOR = 0; - int overlay_x = 0; int overlay_y = 0; int overlay_w = 0; @@ -45,9 +42,6 @@ void init_atoms(void) { _XA_NET_CURRENT_DESKTOP = XInternAtom(fl_display, "_NET_CURRENT_DESKTOP", False); _XA_NET_DESKTOP_NAMES = XInternAtom(fl_display, "_NET_DESKTOP_NAMES", False); _XA_XROOTPMAP_ID = XInternAtom(fl_display, "_XROOTPMAP_ID", False); - - _XA_EDE_DESKTOP_NOTIFY = XInternAtom(fl_display, "_EDE_DESKTOP_NOTIFY", False); - _XA_EDE_DESKTOP_NOTIFY_COLOR = XInternAtom(fl_display, "_EDE_DESKTOP_NOTIFY_COLOR", False); } bool net_get_workarea(int& x, int& y, int& w, int &h) { @@ -159,46 +153,6 @@ int net_get_workspace_names(char**& names) { return nsz; } -bool ede_get_desktop_notify(char* txt, int txt_len) { - XTextProperty names; - XGetTextProperty(fl_display, RootWindow(fl_display, fl_screen), &names, _XA_EDE_DESKTOP_NOTIFY); - if(!names.nitems || !names.value) - return false; - - char** vnames; - int nsz = 0; - if(!XTextPropertyToStringList(&names, &vnames, &nsz)) { - XFree(names.value); - return false; - } - - strncpy(txt, vnames[0], txt_len); - txt[txt_len] = '\0'; - XFreeStringList(vnames); - return true; -} - -Fl_Color ede_get_desktop_notify_color(void) { - Atom real; - int format; - unsigned long n, extra; - unsigned char* prop; - - int status = XGetWindowProperty(fl_display, RootWindow(fl_display, fl_screen), - _XA_EDE_DESKTOP_NOTIFY_COLOR, 0L, 0x7fffffff, False, XA_CARDINAL, &real, &format, &n, &extra, - (unsigned char**)&prop); - - int color = FL_WHITE; - - if(status != Success && !prop) - return (Fl_Color)color; - - color = int(*(long*)prop); - XFree(prop); - - return (Fl_Color)color; -} - #if 0 int net_get_workspace_names(char** names) { Atom nd = XInternAtom(fl_display, "_NET_DESKTOP_NAMES", False); diff --git a/eiconman/Utils.h b/eiconman/Utils.h index 66dd9b1..f3e93a3 100644 --- a/eiconman/Utils.h +++ b/eiconman/Utils.h @@ -26,11 +26,6 @@ extern Atom _XA_NET_CURRENT_DESKTOP; extern Atom _XA_NET_DESKTOP_NAMES; extern Atom _XA_XROOTPMAP_ID; -// via XGetTextProperty/XSetTextProperty -extern Atom _XA_EDE_DESKTOP_NOTIFY; -// via XChangeProperty (prop = Fl_Color, sizeof(int)) -extern Atom _XA_EDE_DESKTOP_NOTIFY_COLOR; - void init_atoms(void); int net_get_workspace_count(void); @@ -39,9 +34,6 @@ bool net_get_workarea(int& x, int& y, int& w, int &h); void net_make_me_desktop(Fl_Window* w); int net_get_workspace_names(char**& names); -bool ede_get_desktop_notify(char* txt, int txt_len); -Fl_Color ede_get_desktop_notify_color(void); - void draw_xoverlay(int x, int y, int w, int h); void clear_xoverlay(void); void set_xoverlay_drawable(Fl_Window* win); diff --git a/eiconman/eiconman.cpp b/eiconman/eiconman.cpp index 95d0043..81fe008 100644 --- a/eiconman/eiconman.cpp +++ b/eiconman/eiconman.cpp @@ -18,7 +18,6 @@ #include "DesktopIcon.h" #include "Utils.h" #include "Wallpaper.h" -#include "NotifyBox.h" #include #include @@ -45,14 +44,13 @@ #include // rand, srand #include // time -#if 0 -#include -#endif - #define EICONMAN_UID 0x10 #define CONFIG_NAME "eiconman.conf" #define ICONS_CONFIG_NAME "eiconman-icons.conf" +#define EICONMAN_INTERFACE "org.equinoxproject.Eiconman" +#define EICONMAN_OBJECT "/org/equinoxproject/Eiconman" + #define SELECTION_SINGLE (Fl::event_button() == 1) #define SELECTION_MULTI (Fl::event_button() == 1 && (Fl::event_key(FL_Shift_L) || Fl::event_key(FL_Shift_R))) @@ -61,6 +59,7 @@ #undef MAX #define MAX(x,y) ((x) > (y) ? (x) : (y)) + /* * Which widgets Fl::belowmouse() should skip. This should be updated * when new non-icon child is added to Desktop window. @@ -88,13 +87,6 @@ Fl_Menu_Item desktop_menu[] = { {0} }; -#if 0 -XserverRegion xregion; -XserverRegion xpart; -Damage xdamage; -int xevent_base, xerror_base; -#endif - Desktop* Desktop::pinstance = NULL; bool running = false; @@ -140,40 +132,12 @@ void icons_conf_cb(Fl_Widget*, void*) { } int desktop_xmessage_handler(int event) { -#if 0 - if(fl_xevent->type == xevent_base + XDamageNotify) { - XDamageNotifyEvent* xdev = (XDamageNotifyEvent*)fl_xevent; - - EDEBUG(ESTRLOC ": Damaged region %i %i %i %i on 0x%lx\n", xdev->area.x, xdev->area.y, - xdev->area.width, xdev->area.height, xdev->drawable); - - XDamageSubtract(fl_display, xdev->damage, None, None); - XFixesSetRegion(fl_display, xpart, &xdev->area, 1); - XFixesUnionRegion(fl_display, xregion, xregion, xpart); - } - - XDamageSubtract(fl_display, xdamage, xregion, None); - XFixesSetRegion(fl_display, xregion, 0, 0); -#endif - if(fl_xevent->type == PropertyNotify) { if(fl_xevent->xproperty.atom == _XA_NET_CURRENT_DESKTOP) { Desktop::instance()->notify_desktop_changed(); return 1; } - if(fl_xevent->xproperty.atom == _XA_EDE_DESKTOP_NOTIFY) { - char buff[256]; - if(ede_get_desktop_notify(buff, 256) && buff[0] != '\0') - Desktop::instance()->notify_box(buff, true); - return 1; - } - - if(fl_xevent->xproperty.atom == _XA_EDE_DESKTOP_NOTIFY_COLOR) { - Desktop::instance()->notify_box_color(ede_get_desktop_notify_color()); - return 1; - } - if(fl_xevent->xproperty.atom == _XA_NET_WORKAREA) { Desktop::instance()->update_workarea(); return 1; @@ -211,7 +175,7 @@ Desktop::~Desktop() { delete dsett; delete selbox; - delete notify; + delete dbus; edelib::DirWatch::shutdown(); } @@ -232,9 +196,15 @@ void Desktop::init_internals(void) { wallpaper = new Wallpaper(0, 0, w(), h()); end(); - notify = new NotifyBox(w(), h()); set_bg_color(dsett->color, false); + dbus = new edelib::EdbusConnection(); + if(!dbus->connect(edelib::EDBUS_SESSION)) { + E_WARNING("Unable to connecto to session bus. Disabling dbus interface...\n"); + delete dbus; + dbus = NULL; + } + read_config(); /* @@ -310,13 +280,6 @@ void Desktop::show(void) { if(!shown()) { Fl_X::make_xid(this); net_make_me_desktop(this); -#if 0 - XDamageQueryExtension(fl_display, &xevent_base, &xerror_base); - - xdamage = XDamageCreate(fl_display, fl_xid(this), XDamageReportBoundingBox); - xregion = XFixesCreateRegionFromWindow(fl_display, fl_xid(this), 0); - xpart = XFixesCreateRegionFromWindow(fl_display, fl_xid(this), 0); -#endif } } @@ -770,23 +733,6 @@ void Desktop::select_in_area(void) { } } -void Desktop::notify_box(const char* msg, bool copy) { - if(!msg) - return; - - if(copy) - notify->copy_label(msg); - else - notify->label(msg); - - if(!notify->shown()) - notify->show(); -} - -void Desktop::notify_box_color(Fl_Color col) { - notify->color(col); -} - void Desktop::notify_desktop_changed(void) { int num = net_get_current_desktop(); if(num == -1) @@ -802,7 +748,14 @@ void Desktop::notify_desktop_changed(void) { return; } - notify_box(names[num], true); + if(dbus) { + edelib::EdbusMessage msg; + // send org.equinoxproject.Eiconman.DesktopChanged(int32, string) signal + msg.create_signal(EICONMAN_OBJECT, EICONMAN_INTERFACE, "DesktopChanged"); + msg << num << names[num]; + dbus->send(msg); + } + XFreeStringList(names); } diff --git a/eiconman/eiconman.h b/eiconman/eiconman.h index cedf051..d986797 100644 --- a/eiconman/eiconman.h +++ b/eiconman/eiconman.h @@ -25,6 +25,7 @@ #include #include #include +#include #define EDAMAGE_CHILD_LABEL 0x10 #define EDAMAGE_OVERLAY 0x20 @@ -82,7 +83,6 @@ struct SelectionOverlay { class Wallpaper; class DesktopIcon; -class NotifyBox; class Fl_Menu_Button; @@ -110,9 +110,9 @@ class Desktop : public DESKTOP_WINDOW { GlobalIconSettings gisett; DesktopSettings* dsett; - Fl_Menu_Button* dmenu; - Wallpaper* wallpaper; - NotifyBox* notify; + Fl_Menu_Button* dmenu; + Wallpaper* wallpaper; + edelib::EdbusConnection* dbus; DesktopIconList icons; DesktopIconList selectionbuff; @@ -164,8 +164,6 @@ class Desktop : public DESKTOP_WINDOW { void set_bg_color(int c, bool do_redraw = true); - void notify_box(const char* msg, bool copy = false); - void notify_box_color(Fl_Color col); void notify_desktop_changed(void); void dir_watch(const char* dir, const char* changed, int flags);