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.

This commit is contained in:
Sanel Zukan 2014-11-28 15:46:05 +00:00
parent f0c50eeebf
commit 8f8a937e98
3 changed files with 25 additions and 9 deletions

View File

@ -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) { Desktop::Desktop() : EDE_DESKTOP_WINDOW(0, 0, 100, 100, EDE_DESKTOP_APP) {
end(); end();
/* use nice darker blue color as default for background */ /* use nice darker blue color as default for background */
color(fl_rgb_color(73, 64, 102)); 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)) if(!netwm_workarea_get_size(X, Y, W, H))
Fl::screen_xywh(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); resize(X, Y, W, H);
/* also resize wallpaper if given */ /* also resize wallpaper if given */
if(wallpaper && wallpaper->visible()) if(wallpaper && wallpaper->visible() && resize_wallpaper) {
wallpaper->resize(0, 0, w(), h()); E_DEBUG(E_STRLOC ": resizing wallpaper to %i %i\n", W, H);
wallpaper->resize(0, 0, W, H);
}
} }
void Desktop::read_config(void) { void Desktop::read_config(void) {

View File

@ -72,6 +72,7 @@ public:
void show(void); void show(void);
void update_workarea(void); void update_workarea(void);
void update_workarea(int X, int Y, int W, int H);
void read_config(void); void read_config(void);
void read_desktop_folder(const char *dpath = NULL); void read_desktop_folder(const char *dpath = NULL);

View File

@ -370,10 +370,6 @@ void Wallpaper::set_rootpmap(void) {
bool Wallpaper::load(const char *path, int s, bool rootpmap) { bool Wallpaper::load(const char *path, int s, bool rootpmap) {
E_ASSERT(path != NULL); 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); Fl_Shared_Image *img = Fl_Shared_Image::get(path);
E_RETURN_VAL_IF_FAIL(img != NULL, false); E_RETURN_VAL_IF_FAIL(img != NULL, false);
@ -423,7 +419,7 @@ void Wallpaper::draw(void) {
iw = im->w(); iw = im->w();
ih = im->h(); ih = im->h();
E_RETURN_IF_FAIL(iw > 0 && ih > 0); E_RETURN_IF_FAIL(iw > 0 && ih > 0);
if(state == WALLPAPER_CENTER) { if(state == WALLPAPER_CENTER) {
@ -476,7 +472,7 @@ int Wallpaper::handle(int event) {
void Wallpaper::resize(int X, int Y, int W, int H) { void Wallpaper::resize(int X, int Y, int W, int H) {
if(X == x() && Y == y() && W == w() && H == h()) if(X == x() && Y == y() && W == w() && H == h())
return; return;
Fl_Box::resize(X, Y, W, H); Fl_Box::resize(X, Y, W, H);
if(image()) { if(image()) {
/* /*