From 8f8a937e98010672a317af3f4f93edb03f1d09f6 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Fri, 28 Nov 2014 15:46:05 +0000 Subject: [PATCH] Added support for wallpaper size update when screen sizes are changed. Also, there are some tricks applied so wallpaper scaling be done only when really is needed. --- ede-desktop/Desktop.cpp | 25 ++++++++++++++++++++++--- ede-desktop/Desktop.h | 1 + ede-desktop/Wallpaper.cpp | 8 ++------ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/ede-desktop/Desktop.cpp b/ede-desktop/Desktop.cpp index f081884..90f513b 100644 --- a/ede-desktop/Desktop.cpp +++ b/ede-desktop/Desktop.cpp @@ -168,6 +168,7 @@ static void folder_create_cb(Fl_Widget*, void *d) { Desktop::Desktop() : EDE_DESKTOP_WINDOW(0, 0, 100, 100, EDE_DESKTOP_APP) { end(); + /* use nice darker blue color as default for background */ color(fl_rgb_color(73, 64, 102)); @@ -232,12 +233,30 @@ void Desktop::update_workarea(void) { if(!netwm_workarea_get_size(X, Y, W, H)) Fl::screen_xywh(X, Y, W, H); - E_DEBUG(E_STRLOC ": resizing to %i %i %i %i\n", X, Y, W, H); + update_workarea(X, Y, W, H); +} + +void Desktop::update_workarea(int X, int Y, int W, int H) { + /* prevent multiple calls with the same values */ + if(X == x() && Y == y() && W == w() && H == h()) + return; + + E_DEBUG(E_STRLOC ": resizing to %i %i %i %i (was: %i %i %i %i)\n", + X, Y, W, H, x(), y(), w(), h()); + + /* + * Check if wallpaper needs resizing. Sometimes, while screen size is updated + * X11 can change x/y, but keep w/h; here, wallpaper size update is not needed. + */ + bool resize_wallpaper = !(W == w() && H == h()); + resize(X, Y, W, H); /* also resize wallpaper if given */ - if(wallpaper && wallpaper->visible()) - wallpaper->resize(0, 0, w(), h()); + if(wallpaper && wallpaper->visible() && resize_wallpaper) { + E_DEBUG(E_STRLOC ": resizing wallpaper to %i %i\n", W, H); + wallpaper->resize(0, 0, W, H); + } } void Desktop::read_config(void) { diff --git a/ede-desktop/Desktop.h b/ede-desktop/Desktop.h index 50410a4..3022166 100644 --- a/ede-desktop/Desktop.h +++ b/ede-desktop/Desktop.h @@ -72,6 +72,7 @@ public: void show(void); void update_workarea(void); + void update_workarea(int X, int Y, int W, int H); void read_config(void); void read_desktop_folder(const char *dpath = NULL); diff --git a/ede-desktop/Wallpaper.cpp b/ede-desktop/Wallpaper.cpp index b9f3652..1dad139 100644 --- a/ede-desktop/Wallpaper.cpp +++ b/ede-desktop/Wallpaper.cpp @@ -370,10 +370,6 @@ void Wallpaper::set_rootpmap(void) { bool Wallpaper::load(const char *path, int s, bool rootpmap) { E_ASSERT(path != NULL); - /* in case this function gets multiple calls */ - if(wpath == path && state == s && rootpmap == use_rootpmap) - return true; - Fl_Shared_Image *img = Fl_Shared_Image::get(path); E_RETURN_VAL_IF_FAIL(img != NULL, false); @@ -423,7 +419,7 @@ void Wallpaper::draw(void) { iw = im->w(); ih = im->h(); - + E_RETURN_IF_FAIL(iw > 0 && ih > 0); if(state == WALLPAPER_CENTER) { @@ -476,7 +472,7 @@ int Wallpaper::handle(int event) { void Wallpaper::resize(int X, int Y, int W, int H) { if(X == x() && Y == y() && W == w() && H == h()) return; - + Fl_Box::resize(X, Y, W, H); if(image()) { /*