mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Instead local USE_SHAPE, use HAVE_SHAPE from global config.h.
Some code style update.
This commit is contained in:
parent
5fe543ff4c
commit
0c2831c50e
@ -10,6 +10,10 @@
|
|||||||
* See COPYING for details.
|
* See COPYING for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <FL/Fl.H>
|
#include <FL/Fl.H>
|
||||||
#include <FL/fl_draw.H>
|
#include <FL/fl_draw.H>
|
||||||
#include <FL/Fl_Shared_Image.H>
|
#include <FL/Fl_Shared_Image.H>
|
||||||
@ -22,7 +26,7 @@
|
|||||||
#include <edelib/Nls.h>
|
#include <edelib/Nls.h>
|
||||||
#include <edelib/Run.h>
|
#include <edelib/Run.h>
|
||||||
|
|
||||||
#ifdef USE_SHAPE
|
#ifdef HAVE_SHAPE
|
||||||
#include <X11/extensions/shape.h>
|
#include <X11/extensions/shape.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -219,7 +223,7 @@ void DesktopIcon::fix_position(int X, int Y) {
|
|||||||
void DesktopIcon::drag(int x, int y, bool apply) {
|
void DesktopIcon::drag(int x, int y, bool apply) {
|
||||||
if(!micon) {
|
if(!micon) {
|
||||||
micon = new MovableIcon(this);
|
micon = new MovableIcon(this);
|
||||||
#if USE_SHAPE
|
#if HAVE_SHAPE
|
||||||
/*
|
/*
|
||||||
* This is used to calculate correct window startup/ending
|
* This is used to calculate correct window startup/ending
|
||||||
* position since icon is placed in the middle of the box.
|
* position since icon is placed in the middle of the box.
|
||||||
@ -243,7 +247,7 @@ void DesktopIcon::drag(int x, int y, bool apply) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(apply) {
|
if(apply) {
|
||||||
#if USE_SHAPE
|
#if HAVE_SHAPE
|
||||||
int ix, iy;
|
int ix, iy;
|
||||||
ix = iy = 0;
|
ix = iy = 0;
|
||||||
if(image()) {
|
if(image()) {
|
||||||
@ -259,7 +263,7 @@ void DesktopIcon::drag(int x, int y, bool apply) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used only in Desktop::move_selection
|
/* used only in Desktop::move_selection */
|
||||||
int DesktopIcon::drag_icon_x(void) {
|
int DesktopIcon::drag_icon_x(void) {
|
||||||
if(!micon)
|
if(!micon)
|
||||||
return x();
|
return x();
|
||||||
@ -267,7 +271,7 @@ int DesktopIcon::drag_icon_x(void) {
|
|||||||
return micon->x();
|
return micon->x();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used only in Desktop::move_selection
|
/* used only in Desktop::move_selection */
|
||||||
int DesktopIcon::drag_icon_y(void) {
|
int DesktopIcon::drag_icon_y(void) {
|
||||||
if(!micon)
|
if(!micon)
|
||||||
return y();
|
return y();
|
||||||
@ -315,7 +319,7 @@ void DesktopIcon::fast_redraw(void) {
|
|||||||
xpos = x() - 4;
|
xpos = x() - 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LABEL_OFFSET + 2 include selection box line height too; same for xpos
|
/* LABEL_OFFSET + 2 include selection box line height too; same for xpos */
|
||||||
parent()->damage(FL_DAMAGE_ALL, xpos, y(), wsz, h() + lheight + LABEL_OFFSET + 2);
|
parent()->damage(FL_DAMAGE_ALL, xpos, y(), wsz, h() + lheight + LABEL_OFFSET + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,13 +329,13 @@ void DesktopIcon::draw(void) {
|
|||||||
if(image() && (damage() & FL_DAMAGE_ALL)) {
|
if(image() && (damage() & FL_DAMAGE_ALL)) {
|
||||||
Fl_Image* im = image();
|
Fl_Image* im = image();
|
||||||
|
|
||||||
// center image in the box
|
/* center image in the box */
|
||||||
int ix = (w()/2) - (im->w()/2);
|
int ix = (w()/2) - (im->w()/2);
|
||||||
int iy = (h()/2) - (im->h()/2);
|
int iy = (h()/2) - (im->h()/2);
|
||||||
ix += x();
|
ix += x();
|
||||||
iy += y();
|
iy += y();
|
||||||
|
|
||||||
// darker_img is always present if image() is present
|
/* darker_img is always present if image() is present */
|
||||||
if(is_focused())
|
if(is_focused())
|
||||||
darker_img->draw(ix, iy);
|
darker_img->draw(ix, iy);
|
||||||
else
|
else
|
||||||
@ -354,44 +358,40 @@ void DesktopIcon::draw(void) {
|
|||||||
int old_font = fl_font();
|
int old_font = fl_font();
|
||||||
int old_font_sz = fl_size();
|
int old_font_sz = fl_size();
|
||||||
|
|
||||||
// draw with icon's font
|
/* draw with icon's font */
|
||||||
fl_font(labelfont(), labelsize());
|
fl_font(labelfont(), labelsize());
|
||||||
|
|
||||||
// pseudo-shadow
|
/* pseudo-shadow */
|
||||||
fl_color(FL_BLACK);
|
fl_color(FL_BLACK);
|
||||||
fl_draw(label(), X+1, Y+1, lwidth, lheight, align(), 0, 0);
|
fl_draw(label(), X+1, Y+1, lwidth, lheight, align(), 0, 0);
|
||||||
|
|
||||||
fl_color(globals->label_foreground);
|
fl_color(globals->label_foreground);
|
||||||
fl_draw(label(), X, Y, lwidth, lheight, align(), 0, 0);
|
fl_draw(label(), X, Y, lwidth, lheight, align(), 0, 0);
|
||||||
|
|
||||||
// restore old font
|
/* restore old font */
|
||||||
fl_font(old_font, old_font_sz);
|
fl_font(old_font, old_font_sz);
|
||||||
|
|
||||||
if(is_focused()) {
|
if(is_focused()) {
|
||||||
/*
|
/* draw focused box on our way so later this can be used to draw customised boxes */
|
||||||
* draw focused box on our way so later
|
|
||||||
* this can be used to draw customised boxes
|
|
||||||
*/
|
|
||||||
fl_color(globals->label_foreground);
|
fl_color(globals->label_foreground);
|
||||||
fl_line_style(FL_DOT);
|
fl_line_style(FL_DOT);
|
||||||
|
|
||||||
fl_push_matrix();
|
fl_push_matrix();
|
||||||
fl_begin_loop();
|
fl_begin_loop();
|
||||||
fl_vertex(X,Y);
|
fl_vertex(X, Y);
|
||||||
fl_vertex(X+lwidth,Y);
|
fl_vertex(X + lwidth, Y);
|
||||||
fl_vertex(X+lwidth,Y+lheight);
|
fl_vertex(X + lwidth, Y + lheight);
|
||||||
fl_vertex(X,Y+lheight);
|
fl_vertex(X, Y + lheight);
|
||||||
fl_vertex(X,Y);
|
fl_vertex(X, Y);
|
||||||
fl_end_loop();
|
fl_end_loop();
|
||||||
fl_pop_matrix();
|
fl_pop_matrix();
|
||||||
|
|
||||||
// revert to default line style
|
/* revert to default line style */
|
||||||
fl_line_style(0);
|
fl_line_style(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// revert to old color whatever that be
|
/* revert to old color whatever that be */
|
||||||
fl_color(old);
|
fl_color(old);
|
||||||
|
|
||||||
E_DEBUG(E_STRLOC ": DesktopIcon label redraw\n");
|
E_DEBUG(E_STRLOC ": DesktopIcon label redraw\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -403,16 +403,14 @@ int DesktopIcon::handle(int event) {
|
|||||||
case FL_ENTER:
|
case FL_ENTER:
|
||||||
case FL_LEAVE:
|
case FL_LEAVE:
|
||||||
return 1;
|
return 1;
|
||||||
/*
|
/* We have to handle FL_MOVE too, if want to get only once FL_ENTER when entered or FL_LEAVE when leaved */
|
||||||
* We have to handle FL_MOVE too, if want to get only once
|
|
||||||
* FL_ENTER when entered or FL_LEAVE when leaved.
|
|
||||||
*/
|
|
||||||
case FL_MOVE:
|
case FL_MOVE:
|
||||||
return 1;
|
return 1;
|
||||||
case FL_PUSH:
|
case FL_PUSH:
|
||||||
if(Fl::event_button() == 3) {
|
if(Fl::event_button() == 3) {
|
||||||
// Fl_Menu_Item::popup() by default does not call callbacks
|
/* Fl_Menu_Item::popup() by default does not call callbacks */
|
||||||
const Fl_Menu_Item* m = imenu->menu()->popup(Fl::event_x(), Fl::event_y());
|
const Fl_Menu_Item* m = imenu->menu()->popup(Fl::event_x(), Fl::event_y());
|
||||||
|
|
||||||
if(m && m->callback())
|
if(m && m->callback())
|
||||||
m->do_callback(0, this);
|
m->do_callback(0, this);
|
||||||
}
|
}
|
||||||
@ -451,7 +449,7 @@ MovableIcon::MovableIcon(DesktopIcon* ic) : Fl_Window(ic->x(), ic->y(), ic->w(),
|
|||||||
* Force box be same width/height as icon so it
|
* Force box be same width/height as icon so it
|
||||||
* can fit inside masked window.
|
* can fit inside masked window.
|
||||||
*/
|
*/
|
||||||
#ifdef USE_SHAPE
|
#ifdef HAVE_SHAPE
|
||||||
Fl_Image* img = ic->icon_image();
|
Fl_Image* img = ic->icon_image();
|
||||||
if(img)
|
if(img)
|
||||||
icon_box = new Fl_Box(0, 0, img->w(), img->h());
|
icon_box = new Fl_Box(0, 0, img->w(), img->h());
|
||||||
@ -473,7 +471,7 @@ void MovableIcon::show(void) {
|
|||||||
if(!shown())
|
if(!shown())
|
||||||
Fl_X::make_xid(this);
|
Fl_X::make_xid(this);
|
||||||
|
|
||||||
#ifdef USE_SHAPE
|
#ifdef HAVE_SHAPE
|
||||||
if(icon->icon_image()) {
|
if(icon->icon_image()) {
|
||||||
mask = create_mask(icon->icon_image());
|
mask = create_mask(icon->icon_image());
|
||||||
if(mask) {
|
if(mask) {
|
||||||
@ -485,6 +483,7 @@ void MovableIcon::show(void) {
|
|||||||
*/
|
*/
|
||||||
Atom opacity_atom = XInternAtom(fl_display, "_NET_WM_WINDOW_OPACITY", False);
|
Atom opacity_atom = XInternAtom(fl_display, "_NET_WM_WINDOW_OPACITY", False);
|
||||||
unsigned int opacity = 0xc0000000;
|
unsigned int opacity = 0xc0000000;
|
||||||
|
|
||||||
XChangeProperty(fl_display, fl_xid(this), opacity_atom, XA_CARDINAL, 32, PropModeReplace,
|
XChangeProperty(fl_display, fl_xid(this), opacity_atom, XA_CARDINAL, 32, PropModeReplace,
|
||||||
(unsigned char*)&opacity, 1L);
|
(unsigned char*)&opacity, 1L);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
SubDir TOP ede-desktop ;
|
SubDir TOP ede-desktop ;
|
||||||
|
|
||||||
ObjectC++Flags DesktopIcon.cpp : -DUSE_SHAPE ;
|
|
||||||
ObjectC++Flags ede-desktop.cpp : -DUSE_EDELIB_WINDOW ;
|
ObjectC++Flags ede-desktop.cpp : -DUSE_EDELIB_WINDOW ;
|
||||||
|
|
||||||
SOURCE = ede-desktop.cpp Utils.cpp Wallpaper.cpp DesktopIcon.cpp IconProperties.cpp ;
|
SOURCE = ede-desktop.cpp Utils.cpp Wallpaper.cpp DesktopIcon.cpp IconProperties.cpp ;
|
||||||
|
@ -199,7 +199,6 @@ void Desktop::init_internals(void) {
|
|||||||
wallpaper = new Wallpaper(0, 0, w(), h());
|
wallpaper = new Wallpaper(0, 0, w(), h());
|
||||||
end();
|
end();
|
||||||
|
|
||||||
|
|
||||||
dbus = new edelib::EdbusConnection();
|
dbus = new edelib::EdbusConnection();
|
||||||
if(!dbus->connect(edelib::EDBUS_SESSION)) {
|
if(!dbus->connect(edelib::EDBUS_SESSION)) {
|
||||||
E_WARNING(E_STRLOC ": Unable to connect to session bus. Disabling dbus interface...\n");
|
E_WARNING(E_STRLOC ": Unable to connect to session bus. Disabling dbus interface...\n");
|
||||||
@ -565,7 +564,7 @@ void Desktop::select(DesktopIcon* ic, bool do_redraw) {
|
|||||||
if(in_selection(ic))
|
if(in_selection(ic))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
selectionbuff.push_back(ic);
|
selectionbuf.push_back(ic);
|
||||||
|
|
||||||
if(!ic->is_focused()) {
|
if(!ic->is_focused()) {
|
||||||
ic->do_focus();
|
ic->do_focus();
|
||||||
@ -579,8 +578,8 @@ void Desktop::select_only(DesktopIcon* ic) {
|
|||||||
E_ASSERT(ic != NULL);
|
E_ASSERT(ic != NULL);
|
||||||
|
|
||||||
unfocus_all();
|
unfocus_all();
|
||||||
selectionbuff.clear();
|
selectionbuf.clear();
|
||||||
selectionbuff.push_back(ic);
|
selectionbuf.push_back(ic);
|
||||||
|
|
||||||
ic->do_focus();
|
ic->do_focus();
|
||||||
ic->fast_redraw();
|
ic->fast_redraw();
|
||||||
@ -589,12 +588,12 @@ void Desktop::select_only(DesktopIcon* ic) {
|
|||||||
bool Desktop::in_selection(const DesktopIcon* ic) {
|
bool Desktop::in_selection(const DesktopIcon* ic) {
|
||||||
E_ASSERT(ic != NULL);
|
E_ASSERT(ic != NULL);
|
||||||
|
|
||||||
if(selectionbuff.empty())
|
if(selectionbuf.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DesktopIconListIter it, it_end;
|
DesktopIconListIter it, it_end;
|
||||||
|
|
||||||
for(it = selectionbuff.begin(), it_end = selectionbuff.end(); it != it_end; ++it) {
|
for(it = selectionbuf.begin(), it_end = selectionbuf.end(); it != it_end; ++it) {
|
||||||
if((*it) == ic)
|
if((*it) == ic)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -603,7 +602,7 @@ bool Desktop::in_selection(const DesktopIcon* ic) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Desktop::move_selection(int x, int y, bool apply) {
|
void Desktop::move_selection(int x, int y, bool apply) {
|
||||||
if(selectionbuff.empty())
|
if(selectionbuf.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int prev_x, prev_y, tmp_x, tmp_y;
|
int prev_x, prev_y, tmp_x, tmp_y;
|
||||||
@ -611,7 +610,7 @@ void Desktop::move_selection(int x, int y, bool apply) {
|
|||||||
|
|
||||||
DesktopIconListIter it, it_end;
|
DesktopIconListIter it, it_end;
|
||||||
|
|
||||||
for(it = selectionbuff.begin(), it_end = selectionbuff.end(); it != it_end; ++it) {
|
for(it = selectionbuf.begin(), it_end = selectionbuf.end(); it != it_end; ++it) {
|
||||||
ic = (*it);
|
ic = (*it);
|
||||||
|
|
||||||
prev_x = ic->drag_icon_x();
|
prev_x = ic->drag_icon_x();
|
||||||
@ -946,13 +945,13 @@ int Desktop::handle(int event) {
|
|||||||
|
|
||||||
if(NOT_SELECTABLE(clicked)) {
|
if(NOT_SELECTABLE(clicked)) {
|
||||||
E_DEBUG(E_STRLOC ": DESKTOP CLICK !!!\n");
|
E_DEBUG(E_STRLOC ": DESKTOP CLICK !!!\n");
|
||||||
if(!selectionbuff.empty()) {
|
if(!selectionbuf.empty()) {
|
||||||
/*
|
/*
|
||||||
* Only focused are in selectionbuff, so this is fine to do; also will prevent
|
* Only focused are in selectionbuf, so this is fine to do; also will prevent
|
||||||
* full redraw when is clicked on desktop
|
* full redraw when is clicked on desktop
|
||||||
*/
|
*/
|
||||||
unfocus_all();
|
unfocus_all();
|
||||||
selectionbuff.clear();
|
selectionbuf.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// track position so moving can be deduced
|
// track position so moving can be deduced
|
||||||
@ -1005,7 +1004,7 @@ int Desktop::handle(int event) {
|
|||||||
|
|
||||||
case FL_DRAG:
|
case FL_DRAG:
|
||||||
moving = true;
|
moving = true;
|
||||||
if(!selectionbuff.empty()) {
|
if(!selectionbuf.empty()) {
|
||||||
E_DEBUG(E_STRLOC ": DRAG icon from desktop\n");
|
E_DEBUG(E_STRLOC ": DRAG icon from desktop\n");
|
||||||
move_selection(Fl::event_x_root(), Fl::event_y_root(), false);
|
move_selection(Fl::event_x_root(), Fl::event_y_root(), false);
|
||||||
} else {
|
} else {
|
||||||
@ -1045,8 +1044,8 @@ int Desktop::handle(int event) {
|
|||||||
* Possible flickers due overlay will be later removed when is called move_selection(), which
|
* Possible flickers due overlay will be later removed when is called move_selection(), which
|
||||||
* will in turn redraw icons again after position them.
|
* will in turn redraw icons again after position them.
|
||||||
*/
|
*/
|
||||||
if(!selectionbuff.empty())
|
if(!selectionbuf.empty())
|
||||||
selectionbuff.clear();
|
selectionbuf.clear();
|
||||||
|
|
||||||
DesktopIconListIter it, it_end;
|
DesktopIconListIter it, it_end;
|
||||||
for(it = icons.begin(), it_end = icons.end(); it != it_end; ++it) {
|
for(it = icons.begin(), it_end = icons.end(); it != it_end; ++it) {
|
||||||
@ -1057,16 +1056,15 @@ int Desktop::handle(int event) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!selectionbuff.empty() && moving)
|
if(!selectionbuf.empty() && moving)
|
||||||
move_selection(Fl::event_x_root(), Fl::event_y_root(), true);
|
move_selection(Fl::event_x_root(), Fl::event_y_root(), true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do not send FL_RELEASE during move
|
* Do not send FL_RELEASE during move
|
||||||
*
|
|
||||||
* TODO: should be alowed FL_RELEASE to multiple icons? (aka. run command for all selected icons)?
|
* TODO: should be alowed FL_RELEASE to multiple icons? (aka. run command for all selected icons)?
|
||||||
*/
|
*/
|
||||||
if(selectionbuff.size() == 1 && !moving)
|
if(selectionbuf.size() == 1 && !moving)
|
||||||
(*selectionbuff.begin())->handle(FL_RELEASE);
|
(*selectionbuf.begin())->handle(FL_RELEASE);
|
||||||
|
|
||||||
moving = false;
|
moving = false;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -108,7 +108,7 @@ private:
|
|||||||
edelib::EdbusConnection* dbus;
|
edelib::EdbusConnection* dbus;
|
||||||
|
|
||||||
DesktopIconList icons;
|
DesktopIconList icons;
|
||||||
DesktopIconList selectionbuff;
|
DesktopIconList selectionbuf;
|
||||||
|
|
||||||
edelib::String trash_path;
|
edelib::String trash_path;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user