From 1d355a91925536ba2b4f0ffe652cb72540c91000 Mon Sep 17 00:00:00 2001 From: akir Date: Thu, 9 Sep 2004 14:29:10 +0000 Subject: transfered ::getRootPixmap from several places to new home, FbPixmap --- src/FbTk/FbPixmap.cc | 41 ++++++++++++++++++++++++++++++++++++++++- src/FbTk/FbPixmap.hh | 3 ++- src/FbTk/FbWindow.cc | 32 ++++---------------------------- src/FbTk/Menu.cc | 29 ++++------------------------- src/Screen.cc | 44 +++++++++++--------------------------------- src/Screen.hh | 3 +-- 6 files changed, 62 insertions(+), 90 deletions(-) diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index bbc1906..c698ce6 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -19,13 +19,14 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbPixmap.cc,v 1.12 2004/07/06 10:47:36 fluxgen Exp $ +// $Id: FbPixmap.cc,v 1.13 2004/09/09 14:29:10 akir Exp $ #include "FbPixmap.hh" #include "App.hh" #include "GContext.hh" #include +#include #include using namespace std; @@ -203,6 +204,7 @@ void FbPixmap::rotate() { } void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) { + if (drawable() == 0 || (dest_width == width() && dest_height == height())) return; @@ -284,6 +286,43 @@ Pixmap FbPixmap::release() { return ret; } +Pixmap FbPixmap::getRootPixmap(int screen_num) { + + Pixmap root_pm = 0; + // get root pixmap for transparency + Display *disp = FbTk::App::instance()->display(); + Atom real_type; + int real_format; + unsigned long items_read, items_left; + unsigned int *data; + if (XGetWindowProperty(disp, RootWindow(disp, screen_num), + XInternAtom(disp, "_XROOTPMAP_ID", false), + 0L, 1L, + false, XA_PIXMAP, &real_type, + &real_format, &items_read, &items_left, + (unsigned char **) &data) == Success && + items_read) { + root_pm = (Pixmap) (*data); + XFree(data); +/* TODO: analyze why this doesnt work + } else if (XGetWindowProperty(disp, RootWindow(disp, screen_num), + XInternAtom(disp, "_XSETROOT_ID", false), + 0L, 1L, + false, XA_PIXMAP, &real_type, + &real_format, &items_read, &items_left, + (unsigned char **) &data) == Success && + items_read) { + root_pm = (Pixmap) (*data); + XFree(data); +*/ + } + + + return root_pm; + + +} + void FbPixmap::free() { if (m_pm != 0) { XFreePixmap(FbTk::App::instance()->display(), m_pm); diff --git a/src/FbTk/FbPixmap.hh b/src/FbTk/FbPixmap.hh index 77dc555..ee5d6ac 100644 --- a/src/FbTk/FbPixmap.hh +++ b/src/FbTk/FbPixmap.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbPixmap.hh,v 1.12 2004/07/05 23:51:57 fluxgen Exp $ +// $Id: FbPixmap.hh,v 1.13 2004/09/09 14:29:10 akir Exp $ #ifndef FBTK_FBPIXMAP_HH #define FBTK_FBPIXMAP_HH @@ -68,6 +68,7 @@ public: inline unsigned int height() const { return m_height; } inline int depth() const { return m_depth; } + static Pixmap getRootPixmap(int screen_num); private: void free(); diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index 2209835..5417c09 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc @@ -19,9 +19,10 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWindow.cc,v 1.37 2004/08/31 15:26:39 rathnor Exp $ +// $Id: FbWindow.cc,v 1.38 2004/09/09 14:29:10 akir Exp $ #include "FbWindow.hh" +#include "FbPixmap.hh" #include "EventManager.hh" #include "Color.hh" @@ -43,31 +44,6 @@ namespace FbTk { -namespace { -Pixmap getRootPixmap(int screen_num) { - Pixmap root_pm = 0; - // get root pixmap for transparency - Display *disp = FbTk::App::instance()->display(); - Atom real_type; - int real_format; - unsigned long items_read, items_left; - unsigned int *data; - if (XGetWindowProperty(disp, RootWindow(disp, screen_num), - XInternAtom(disp, "_XROOTPMAP_ID", false), - 0L, 1L, - false, XA_PIXMAP, &real_type, - &real_format, &items_read, &items_left, - (unsigned char **) &data) == Success && - items_read) { - root_pm = (Pixmap) (*data); - XFree(data); - } - - return root_pm; -} - -}; // end anonymous namespace - Display *FbWindow::s_display = 0; FbWindow::FbWindow():m_parent(0), m_screen_num(0), m_window(0), m_x(0), m_y(0), @@ -207,7 +183,7 @@ void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, u return; // update source and destination if needed - Pixmap root = getRootPixmap(screenNumber()); + Pixmap root = FbPixmap::getRootPixmap(screenNumber()); if (m_transparent->source() != root) m_transparent->setSource(root, screenNumber()); @@ -245,7 +221,7 @@ void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, u void FbWindow::setAlpha(unsigned char alpha) { #ifdef HAVE_XRENDER if (m_transparent.get() == 0 && alpha < 255) { - m_transparent.reset(new Transparent(getRootPixmap(screenNumber()), window(), alpha, screenNumber())); + m_transparent.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), window(), alpha, screenNumber())); } else if (alpha < 255 && alpha != m_transparent->alpha()) m_transparent->setAlpha(alpha); else if (alpha == 255) diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index b38ae73..a1fdf8c 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.cc,v 1.79 2004/08/31 15:26:39 rathnor Exp $ +// $Id: Menu.cc,v 1.80 2004/09/09 14:29:10 akir Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -44,6 +44,7 @@ #include "Transparent.hh" #include "SimpleCommand.hh" #include "I18n.hh" +#include "FbPixmap.hh" #include #include @@ -74,28 +75,6 @@ static Menu *shown = 0; Menu *Menu::s_focused = 0; -static Pixmap getRootPixmap(int screen_num) { - Pixmap root_pm = 0; - // get root pixmap for transparency - Display *disp = FbTk::App::instance()->display(); - Atom real_type; - int real_format; - unsigned long items_read, items_left; - unsigned int *data; - if (XGetWindowProperty(disp, RootWindow(disp, screen_num), - XInternAtom(disp, "_XROOTPMAP_ID", false), - 0L, 1L, - false, XA_PIXMAP, &real_type, - &real_format, &items_read, &items_left, - (unsigned char **) &data) == Success && - items_read) { - root_pm = (Pixmap) (*data); - XFree(data); - } - - return root_pm; -} - Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): m_theme(tm), m_parent(0), @@ -1406,7 +1385,7 @@ void Menu::reconfigure() { } else if (alpha () < 255) { if (m_transp.get() == 0) { - m_transp.reset(new Transparent(getRootPixmap(screenNumber()), + m_transp.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), m_real_frame_pm.drawable(), alpha(), screenNumber())); } else @@ -1497,7 +1476,7 @@ void Menu::renderTransp(int x, int y, // render the root background #ifdef HAVE_XRENDER - Pixmap root = getRootPixmap(screenNumber()); + Pixmap root = FbPixmap::getRootPixmap(screenNumber()); if (m_transp->source() != root) m_transp->setSource(root, screenNumber()); diff --git a/src/Screen.cc b/src/Screen.cc index 67e954b..8372f0f 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.288 2004/09/06 13:17:56 akir Exp $ +// $Id: Screen.cc,v 1.289 2004/09/09 14:29:03 akir Exp $ #include "Screen.hh" @@ -231,7 +231,8 @@ BScreen::BScreen(FbTk::ResourceManager &rm, m_shutdown(false) { - Display *disp = FbTk::App::instance()->display(); + Fluxbox *fluxbox = Fluxbox::instance(); + Display *disp = fluxbox->display(); initXinerama(); @@ -242,7 +243,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask); - FbTk::App::instance()->sync(false); + fluxbox->sync(false); XSetErrorHandler((XErrorHandler) old); @@ -263,7 +264,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm, rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr)); - Fluxbox *fluxbox = Fluxbox::instance(); // load this screens resources fluxbox->load_rc(*this); @@ -378,7 +378,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, // So we lock root theme temporary so it doesn't uses RootTheme::reconfigTheme // This must be fixed in the future. m_root_theme->lock(true); - FbTk::ThemeManager::instance().load(Fluxbox::instance()->getStyleFilename()); + FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename()); m_root_theme->lock(false); m_root_theme->setLineAttributes(*resource.gc_line_width, *resource.gc_line_style, @@ -386,8 +386,8 @@ BScreen::BScreen(FbTk::ResourceManager &rm, *resource.gc_join_style); #ifdef SLIT - m_slit.reset(new Slit(*this, *layerManager().getLayer(Fluxbox::instance()->getDesktopLayer()), - Fluxbox::instance()->getSlitlistFilename().c_str())); + m_slit.reset(new Slit(*this, *layerManager().getLayer(fluxbox->getDesktopLayer()), + fluxbox->getSlitlistFilename().c_str())); #endif // SLIT rm.unlock(); @@ -445,7 +445,7 @@ void BScreen::initWindows() { Fluxbox *fluxbox = Fluxbox::instance(); // preen the window list of all icon windows... for better dockapp support - for (int i = 0; i < (int) nchild; i++) { + for (unsigned int i = 0; i < nchild; i++) { if (children[i] == None) continue; @@ -455,7 +455,7 @@ void BScreen::initWindows() { if (wmhints) { if ((wmhints->flags & IconWindowHint) && (wmhints->icon_window != children[i])) - for (int j = 0; j < (int) nchild; j++) { + for (unsigned int j = 0; j < nchild; j++) { if (children[j] == wmhints->icon_window) { #ifdef DEBUG cerr<<"BScreen::initWindows(): children[j] = 0x"<validateWindow(children[i])) { @@ -493,7 +493,7 @@ void BScreen::initWindows() { fluxbox->searchWindow(transient_for) == 0) { // search forward for transient_for // and swap place with it so it gets created first - int j = i + 1; + unsigned int j = i + 1; for (; j < nchild; ++j) { if (children[j] == transient_for) { swap(children[i], children[j]); @@ -548,28 +548,6 @@ unsigned int BScreen::currentWorkspaceID() const { return m_current_workspace->workspaceID(); } -Pixmap BScreen::rootPixmap() const { - - Pixmap root_pm = 0; - Display *disp = FbTk::App::instance()->display(); - Atom real_type; - int real_format; - unsigned long items_read, items_left; - unsigned int *data; - if (rootWindow().property(XInternAtom(disp, "_XROOTPMAP_ID", false), - 0L, 1L, - false, XA_PIXMAP, &real_type, - &real_format, &items_read, &items_left, - (unsigned char **) &data) && - items_read) { - root_pm = (Pixmap) (*data); - XFree(data); - } - - return root_pm; - -} - unsigned int BScreen::maxLeft(int head) const { // we ignore strut if we're doing full maximization if (hasXinerama()) diff --git a/src/Screen.hh b/src/Screen.hh index b81110f..076ee63 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.143 2004/08/31 15:26:38 rathnor Exp $ +// $Id: Screen.hh,v 1.144 2004/09/09 14:29:04 akir Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -137,7 +137,6 @@ public: unsigned int currentWorkspaceID() const; - Pixmap rootPixmap() const; /* maximum screen bounds for given window */ -- cgit v0.11.2