From 8c7f2ea10eadb76de4eb42d1b4c841171539db17 Mon Sep 17 00:00:00 2001 From: Jim Ramsay Date: Fri, 1 May 2009 18:15:34 -0400 Subject: Everything but Text Managed 32-bit visuals for everything, but text is broken (menus, titlebars, etc) --- src/Ewmh.cc | 4 +-- src/FbRootWindow.cc | 17 ++++++++-- src/FbRootWindow.hh | 2 ++ src/FbTk/App.cc | 34 ++++++++++++++++++- src/FbTk/App.hh | 19 +++++++++++ src/FbTk/Color.cc | 83 ++++++++++++++++++++++++++++++++++++----------- src/FbTk/Color.hh | 18 ++++++++-- src/FbTk/FbWindow.cc | 37 ++++++++++++++++++--- src/FbTk/FbWindow.hh | 8 +++-- src/FbTk/ImageControl.cc | 6 ++-- src/FbTk/ImageImlib2.cc | 4 +-- src/FbTk/Menu.cc | 3 ++ src/FbTk/Shape.cc | 2 +- src/FbTk/Texture.cc | 2 +- src/FbTk/TextureRender.cc | 2 +- src/FbTk/Transparent.cc | 6 ++-- src/FbTk/XFontImp.cc | 4 +-- src/FbTk/XftFontImp.cc | 18 +++++----- src/FbWinFrame.cc | 5 ++- src/IconButton.cc | 2 +- src/Screen.cc | 4 +-- src/Toolbar.cc | 2 +- src/WinButton.cc | 3 +- src/WinClient.cc | 6 ++++ src/WinClient.hh | 3 ++ src/fluxbox.cc | 3 ++ 26 files changed, 233 insertions(+), 64 deletions(-) diff --git a/src/Ewmh.cc b/src/Ewmh.cc index b64a95d..3579461 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -195,7 +195,7 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { height = icon_data.begin()->first.second; // tmp image for the pixmap - XImage* img_pm = XCreateImage(dpy, DefaultVisual(dpy, scrn), winclient.depth(), + XImage* img_pm = XCreateImage(dpy, FbTk::App::instance()->defaultVisual(scrn), winclient.depth(), ZPixmap, 0, NULL, width, height, 32, 0); if (!img_pm) { @@ -204,7 +204,7 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { } // tmp image for the mask - XImage* img_mask = XCreateImage(dpy, DefaultVisual(dpy, scrn), 1, + XImage* img_mask = XCreateImage(dpy, FbTk::App::instance()->defaultVisual(scrn), 1, XYBitmap, 0, NULL, width, height, 32, 0); diff --git a/src/FbRootWindow.cc b/src/FbRootWindow.cc index 7e2b77e..1d92441 100644 --- a/src/FbRootWindow.cc +++ b/src/FbRootWindow.cc @@ -24,10 +24,13 @@ #include "FbTk/App.hh" #include +#include + FbRootWindow::FbRootWindow(int screen_num): FbTk::FbWindow(RootWindow(FbTk::App::instance()->display(), screen_num)), m_visual(0), - m_colormap(0) { + m_colormap(0), + m_depth(0) { Display *disp = FbTk::App::instance()->display(); @@ -44,9 +47,13 @@ FbRootWindow::FbRootWindow(int screen_num): vinfo_nitems > 0) { for (int i = 0; i < vinfo_nitems; i++) { - // We can't handle 32-bit visuals just yet (Composite ARGB) - if (vinfo_return[i].depth != 32 && DefaultDepth(disp, screen_num) < vinfo_return[i].depth) + if (DefaultDepth(disp, screen_num) < vinfo_return[i].depth) { m_visual = vinfo_return[i].visual; + m_depth = vinfo_return[i].depth; + fprintf(stderr, "visual 0x%02x with depth %d\n", + (unsigned)XVisualIDFromVisual(m_visual), + m_depth); + } } XFree(vinfo_return); @@ -55,8 +62,12 @@ FbRootWindow::FbRootWindow(int screen_num): if (m_visual) { m_colormap = XCreateColormap(disp, window(), m_visual, AllocNone); + FbTk::App::instance()->registerScreenDefaults(screen_num, m_visual, m_colormap, m_depth); } else { m_visual = DefaultVisual(disp, screen_num); m_colormap = DefaultColormap(disp, screen_num); + m_depth = DefaultDepth(disp, screen_num); + fprintf(stderr, "Falling back to default visual 0x%02x\n", + (unsigned)XVisualIDFromVisual(m_visual)); } } diff --git a/src/FbRootWindow.hh b/src/FbRootWindow.hh index 34b8219..7e33b5a 100644 --- a/src/FbRootWindow.hh +++ b/src/FbRootWindow.hh @@ -37,10 +37,12 @@ public: FbTk::FbWindow &operator = (Window win) { return *this; } Visual *visual() const { return m_visual; } Colormap colormap() const { return m_colormap; } + unsigned int depth() const { return m_depth; } private: Visual *m_visual; Colormap m_colormap; + unsigned int m_depth; }; #endif // FBROOTWINDOW_HH diff --git a/src/FbTk/App.cc b/src/FbTk/App.cc index 39cd36e..a70aa82 100644 --- a/src/FbTk/App.cc +++ b/src/FbTk/App.cc @@ -36,7 +36,9 @@ App *App::instance() { return s_app; } -App::App(const char *displayname):m_done(false), m_display(0) { +App::App(const char *displayname): + m_done(false), m_display(0) +{ if (s_app != 0) throw std::string("Can't create more than one instance of FbTk::App"); s_app = this; @@ -79,4 +81,34 @@ void App::end() { m_done = true; //end loop in App::eventLoop } +void App::registerScreenDefaults(unsigned int screen, Visual *visual, Colormap cmap, unsigned int depth) { + ScreenDflt d(visual, cmap, depth); + + m_screen_defaults[screen] = d; +} + +Visual *App::defaultVisual(unsigned int screen) { + if (m_screen_defaults.find(screen) != m_screen_defaults.end()) { + return m_screen_defaults[screen].visual; + } + + return DefaultVisual(display(), screen); +} + +Colormap App::defaultColormap(unsigned int screen) { + if (m_screen_defaults.find(screen) != m_screen_defaults.end()) { + return m_screen_defaults[screen].cmap; + } + + return DefaultColormap(display(), screen); +} + +int App::defaultDepth(unsigned int screen) { + if (m_screen_defaults.find(screen) != m_screen_defaults.end()) { + return m_screen_defaults[screen].depth; + } + + return DefaultDepth(display(), screen); +} + } // end namespace FbTk diff --git a/src/FbTk/App.hh b/src/FbTk/App.hh index d878661..4399551 100644 --- a/src/FbTk/App.hh +++ b/src/FbTk/App.hh @@ -23,6 +23,9 @@ #define FBTK_APP_HH #include +#include + +using std::map; namespace FbTk { @@ -47,6 +50,13 @@ public: virtual ~App(); /// display connection Display *display() const { return m_display; } + + /// Registers a screen's default values for global retrieval + void registerScreenDefaults(unsigned int screen, Visual *visual, Colormap cmap, unsigned int depth); + Visual *defaultVisual(unsigned int screen); + Colormap defaultColormap(unsigned int screen); + int defaultDepth(unsigned int screen); + void sync(bool discard); /// starts event loop virtual void eventLoop(); @@ -57,6 +67,15 @@ private: static App *s_app; bool m_done; Display *m_display; + + struct ScreenDflt { + ScreenDflt(): visual(0), cmap(0), depth(0) {} + ScreenDflt(Visual *v, Colormap c, int d): visual(v), cmap(c), depth(d) {} + Visual *visual; + Colormap cmap; + int depth; + }; + map m_screen_defaults; }; } // end namespace FbTk diff --git a/src/FbTk/Color.cc b/src/FbTk/Color.cc index 2cd4278..ae35a94 100644 --- a/src/FbTk/Color.cc +++ b/src/FbTk/Color.cc @@ -31,6 +31,10 @@ using std::cerr; using std::endl; using std::string; +#if HAVE_XRENDER +#include +#endif + namespace { inline unsigned char maxValue(unsigned short colval) { @@ -50,19 +54,31 @@ Color::Color(): } Color::Color(const Color &col_copy): - m_red(0), m_green(0), m_blue(0), + m_red(0), m_green(0), m_blue(0), m_alpha(0), m_pixel(0), m_allocated(false), m_screen(0) { copy(col_copy); } Color::Color(unsigned short red, unsigned short green, unsigned short blue, int screen): - m_red(red), m_green(green), m_blue(blue), + m_red(red), m_green(green), m_blue(blue), m_alpha(0), m_pixel(0), m_allocated(false), m_screen(screen) { - allocate(red, green, blue, screen); + + printf("Color: New RGB color: %d/%d/%d\n", red, green, blue); + allocate(red, green, blue, 0, screen); } +Color::Color(unsigned short red, unsigned short green, unsigned short blue, unsigned short alpha, int screen): + m_red(red), m_green(green), m_blue(blue), m_alpha(alpha), + m_pixel(0), m_allocated(false), + m_screen(screen) { + + printf("Color: New RGB color: %d/%d/%d/%d\n", red, green, blue, alpha); + allocate(red, green, blue, alpha, screen); +} + + Color::Color(const char *color_string, int screen): m_red(0), m_green(0), m_blue(0), m_pixel(0), @@ -86,29 +102,23 @@ bool Color::setFromString(const char *color_string, int screen) { StringUtil::removeTrailingWhitespace(color_string_tmp); Display *disp = App::instance()->display(); - Colormap colm = DefaultColormap(disp, screen); + Colormap colm = App::instance()->defaultColormap(screen); XColor color; + printf("Color: Parsing color string %s\n", color_string_tmp.c_str()); if (! XParseColor(disp, colm, color_string_tmp.c_str(), &color)) return false; - else if (! XAllocColor(disp, colm, &color)) - return false; - setPixel(color.pixel); - setRGB(maxValue(color.red), - maxValue(color.green), - maxValue(color.blue)); - setAllocated(true); - m_screen = screen; + allocate(color.red, color.green, color.blue, 0, screen); - return true; + return isAllocated(); } bool Color::validColorString(const char *color_string, int screen) { XColor color; Display *disp = App::instance()->display(); - Colormap colm = DefaultColormap(disp, screen); + Colormap colm = App::instance()->defaultColormap(screen); // trim white space string color_string_tmp = color_string; StringUtil::removeFirstWhitespace(color_string_tmp); @@ -129,9 +139,14 @@ Color &Color::operator = (const Color &col_copy) { void Color::free() { if (isAllocated()) { - unsigned long pixel = m_pixel; Display *disp = App::instance()->display(); - XFreeColors(disp, DefaultColormap(disp, m_screen), &pixel, 1, 0); +#if HAVE_XRENDER + XftColorFree(disp, App::instance()->defaultVisual(m_screen), + App::instance()->defaultColormap(m_screen), &m_xftcolor); +#else /* No XRENDER */ + unsigned long pixel = m_pixel; + XFreeColors(disp, App::instance()->defaultColormap(m_screen), &pixel, 1, 0); +#endif setPixel(0); setRGB(0, 0, 0); setAllocated(false); @@ -149,39 +164,69 @@ void Color::copy(const Color &col_copy) { allocate(col_copy.red()*0x101, col_copy.green()*0x101, col_copy.blue()*0x101, + col_copy.alpha()*0x101, col_copy.m_screen); } -void Color::allocate(unsigned short red, unsigned short green, unsigned short blue, int screen) { +void Color::allocate(unsigned short red, unsigned short green, unsigned short blue, unsigned short alpha, int screen) { Display *disp = App::instance()->display(); + Colormap cmap = App::instance()->defaultColormap(screen); + int xresult; + +#if HAVE_XRENDER + Visual *vis = App::instance()->defaultVisual(screen); + XRenderColor acolor; + acolor.red = red; + acolor.green = green; + acolor.blue = blue; + acolor.alpha = alpha; + + xresult = XftColorAllocValue(disp, vis, cmap, &acolor, &m_xftcolor); + printf("Color: XftColorAllocValue(%04x/%04x/%04x/%04x) returned %d\n", + red, green, blue, alpha, xresult); +#else /* No XRENDER */ XColor color; // fill xcolor structure color.red = red; color.green = green; color.blue = blue; + xresult = XAllocColor(disp, cmap, &color); + printf("Color: XAllocColor(%04x/%04x/%04x) returned %d\n", + red, green, blue, xresult); +#endif - if (!XAllocColor(disp, DefaultColormap(disp, screen), &color)) { + if (!xresult) { _FB_USES_NLS; cerr<<"FbTk::Color: "<<_FBTK_CONSOLETEXT(Error, ColorAllocation, "Allocation error.", "XAllocColor failed...")< +#if HAVE_XRENDER +#include +#endif + namespace FbTk { /// Allocates rgb color and pixel value @@ -34,6 +39,7 @@ public: explicit Color(unsigned long pixel); Color(const Color &col_copy); Color(unsigned short red, unsigned short green, unsigned short blue, int screen); + Color(unsigned short red, unsigned short green, unsigned short blue, unsigned short alpha, int screen); /// parses and sets rgb and pixel value from a string Color(const char *color_string, int screen); ~Color(); @@ -49,6 +55,7 @@ public: unsigned short red() const { return m_red; } unsigned short green() const { return m_green; } unsigned short blue() const { return m_blue; } + unsigned short alpha() const { return m_alpha; } unsigned long pixel() const { return m_pixel; } /// @return true if the color name in color_string is resolved, else false @@ -58,12 +65,17 @@ private: void free(); void copy(const Color &col); void allocate(unsigned short red, unsigned short green, - unsigned short blue, int screen); + unsigned short blue, unsigned short alpha, + int screen); void setAllocated(bool a) { m_allocated = a; } - void setRGB(unsigned short red, unsigned short green, unsigned short blue); + void setRGB(unsigned short red, unsigned short green, unsigned short blue, + unsigned short alpha = 0); - unsigned short m_red, m_green, m_blue; + unsigned short m_red, m_green, m_blue, m_alpha; +#if HAVE_XRENDER + XftColor m_xftcolor; +#endif unsigned long m_pixel; bool m_allocated; int m_screen; diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index 2ef24fa..e1b27cd 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc @@ -72,9 +72,11 @@ FbWindow::FbWindow(int screen_num, int x, int y, unsigned int width, unsigned int height, long eventmask, + Visual *visual, + Colormap cmap, + unsigned int depth, bool override_redirect, bool save_unders, - unsigned int depth, int class_type): FbDrawable(), m_parent(0), @@ -84,9 +86,18 @@ FbWindow::FbWindow(int screen_num, m_lastbg_color(0), m_lastbg_pm(0), m_renderer(0) { + XWindowAttributes a; + if (XGetWindowAttributes(display(), RootWindow(display(), screen_num), &a)) { + printf("Creating screen window. RootWindow visual is 0x%02x, requested visual is 0x%02x\n", + (unsigned int)XVisualIDFromVisual(a.visual), + visual == CopyFromParent ? 0xff : (unsigned int)XVisualIDFromVisual(visual)); + } else { + printf("Creating screen window. RootWindow visual is unknown, requested visual is 0x%02x\n", + visual == CopyFromParent ? 0xff : (unsigned int)XVisualIDFromVisual(visual)); + } create(RootWindow(display(), screen_num), x, y, width, height, eventmask, - override_redirect, save_unders, depth, class_type); + override_redirect, save_unders, depth, class_type, visual, cmap); }; FbWindow::FbWindow(const FbWindow &parent, @@ -102,7 +113,7 @@ FbWindow::FbWindow(const FbWindow &parent, m_lastbg_pm(0), m_renderer(0) { create(parent.window(), x, y, width, height, eventmask, - override_redirect, save_unders, depth, class_type); + override_redirect, save_unders, depth, class_type, CopyFromParent); }; @@ -603,7 +614,8 @@ bool FbWindow::updateGeometry() { void FbWindow::create(Window parent, int x, int y, unsigned int width, unsigned int height, long eventmask, bool override_redirect, - bool save_unders, unsigned int depth, int class_type) { + bool save_unders, unsigned int depth, int class_type, + Visual *visual, Colormap cmap) { m_border_width = 0; @@ -623,13 +635,28 @@ void FbWindow::create(Window parent, int x, int y, values.save_under = True; } + if (cmap) { + valmask |= CWColormap | CWBackPixel | CWBorderPixel; + values.colormap = cmap; + /* For some reason, with a 32-bit visual, we need to set these */ + values.background_pixel = XWhitePixel(display(), 0); + values.border_pixel = XBlackPixel(display(), 0); + } + + if (depth > 0 || cmap || visual) + printf("Creating window... depth %d, cmap %p, visual 0x%02x (%p)\n", + depth, (void*)cmap, + visual == CopyFromParent ? 0xff : (unsigned int)XVisualIDFromVisual(visual), + visual); m_window = XCreateWindow(display(), parent, x, y, width, height, 0, // border width depth, // depth class_type, // class - CopyFromParent, // visual + visual, // visual valmask, // create mask &values); // create atrribs + if (depth > 0 || cmap || visual) + printf(" Complete\n"); assert(m_window); diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh index edeffe1..7cc6707 100644 --- a/src/FbTk/FbWindow.hh +++ b/src/FbTk/FbWindow.hh @@ -54,9 +54,11 @@ public: FbWindow(int screen_num, int x, int y, unsigned int width, unsigned int height, long eventmask, + Visual *visual = CopyFromParent, + Colormap cmap = 0, + unsigned int depth = CopyFromParent, bool overrride_redirect = false, bool save_unders = false, - unsigned int depth = CopyFromParent, int class_type = InputOutput); FbWindow(const FbWindow &parent, @@ -215,7 +217,9 @@ private: bool override_redirect, bool save_unders, unsigned int depth, - int class_type); + int class_type, + Visual *visual, + Colormap cmap = 0); const FbWindow *m_parent; ///< parent FbWindow int m_screen_num; ///< screen num on which this window exist diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc index 067bcde..277cb29 100644 --- a/src/FbTk/ImageControl.cc +++ b/src/FbTk/ImageControl.cc @@ -112,11 +112,11 @@ ImageControl::ImageControl(int screen_num, Display *disp = FbTk::App::instance()->display(); - m_screen_depth = DefaultDepth(disp, screen_num); + m_screen_depth = FbTk::App::instance()->defaultDepth(screen_num); m_screen_num = screen_num; m_root_window = RootWindow(disp, screen_num); - m_visual = DefaultVisual(disp, screen_num); - m_colormap = DefaultColormap(disp, screen_num); + m_visual = FbTk::App::instance()->defaultVisual(screen_num); + m_colormap = FbTk::App::instance()->defaultColormap(screen_num); cache_max = cmax; diff --git a/src/FbTk/ImageImlib2.cc b/src/FbTk/ImageImlib2.cc index 9983604..d710c4f 100644 --- a/src/FbTk/ImageImlib2.cc +++ b/src/FbTk/ImageImlib2.cc @@ -91,8 +91,8 @@ PixmapWithMask *ImageImlib2::load(const std::string &filename, int screen_num) c imlib_context_push(new_context); imlib_context_set_display(dpy); - imlib_context_set_visual(DefaultVisual(dpy, screen_num)); - imlib_context_set_colormap(DefaultColormap(dpy, screen_num)); + imlib_context_set_visual(FbTk::App::instance()->defaultVisual(screen_num)); + imlib_context_set_colormap(FbTk::App::instance()->defaultColormap(screen_num)); imlib_context_set_drawable(RootWindow(dpy, screen_num)); imlib_context_pop(); diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 7cf2ac9..274dbd9 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -140,6 +140,9 @@ Menu::Menu(FbTk::ThemeProxy &tm, ImageControl &imgctrl): menu.window = FbTk::FbWindow(tm->screenNum(), 0, 0, 10, 10, event_mask, + 0, // cmap + CopyFromParent, // depth + CopyFromParent, // visual true, // override redirect true); // save_under diff --git a/src/FbTk/Shape.cc b/src/FbTk/Shape.cc index 6bb63aa..4ff25bd 100644 --- a/src/FbTk/Shape.cc +++ b/src/FbTk/Shape.cc @@ -65,7 +65,7 @@ Pixmap makePixmap(FbWindow &drawable, const unsigned char rows[]) { memset(data, 0xFF, data_size); XImage *ximage = XCreateImage(disp, - DefaultVisual(disp, drawable.screenNumber()), + App::instance()->defaultVisual(drawable.screenNumber()), 1, XYPixmap, 0, data, diff --git a/src/FbTk/Texture.cc b/src/FbTk/Texture.cc index 2fcd915..2c13595 100644 --- a/src/FbTk/Texture.cc +++ b/src/FbTk/Texture.cc @@ -112,7 +112,7 @@ void Texture::setFromString(const char * const texture_str) { void Texture::calcHiLoColors(int screen_num) { Display *disp = FbTk::App::instance()->display(); XColor xcol; - Colormap colm = DefaultColormap(disp, screen_num); + Colormap colm = FbTk::App::instance()->defaultColormap(screen_num); xcol.red = (unsigned int) (m_color.red() + (m_color.red() >> 1)); diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index 73c1a94..fde995c 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc @@ -328,7 +328,7 @@ XImage *TextureRender::renderXImage() { Display *disp = FbTk::App::instance()->display(); XImage *image = XCreateImage(disp, - DefaultVisual(disp, control.screenNumber()), control.depth(), ZPixmap, 0, 0, + FbTk::App::instance()->defaultVisual(control.screenNumber()), control.depth(), ZPixmap, 0, 0, width, height, 32, 0); if (! image) { diff --git a/src/FbTk/Transparent.cc b/src/FbTk/Transparent.cc index 992678a..3d3a76e 100644 --- a/src/FbTk/Transparent.cc +++ b/src/FbTk/Transparent.cc @@ -167,7 +167,7 @@ Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int s XRenderPictFormat *format = XRenderFindVisualFormat(disp, - DefaultVisual(disp, screen_num)); + FbTk::App::instance()->defaultVisual(screen_num)); if (src != 0 && format != 0) { m_src_pic = XRenderCreatePicture(disp, src, format, @@ -228,7 +228,7 @@ void Transparent::setDest(Drawable dest, int screen_num) { XRenderPictFormat *format = XRenderFindVisualFormat(disp, - DefaultVisual(disp, screen_num)); + FbTk::App::instance()->defaultVisual(screen_num)); if (format == 0) { _FB_USES_NLS; cerr<<"FbTk::Transparent: "; @@ -272,7 +272,7 @@ void Transparent::setSource(Drawable source, int screen_num) { XRenderPictFormat *format = XRenderFindVisualFormat(disp, - DefaultVisual(disp, screen_num)); + FbTk::App::instance()->defaultVisual(screen_num)); if (format == 0) { _FB_USES_NLS; cerr<<"FbTk::Transparent: "; diff --git a/src/FbTk/XFontImp.cc b/src/FbTk/XFontImp.cc index a94aa75..58bb07a 100644 --- a/src/FbTk/XFontImp.cc +++ b/src/FbTk/XFontImp.cc @@ -225,7 +225,7 @@ void XFontImp::rotate(FbTk::Orientation orient) { // reserve memory for first XImage vertdata = (unsigned char *)calloc((unsigned)(vert_len * vert_h), 1); - XImage *I1 = XCreateImage(dpy, DefaultVisual(dpy, screen), + XImage *I1 = XCreateImage(dpy, App::instance()->defaultVisual(screen), 1, XYBitmap, 0, (char *)vertdata, vert_w, vert_h, 8, 0); @@ -269,7 +269,7 @@ void XFontImp::rotate(FbTk::Orientation orient) { bitdata = (unsigned char *)calloc((unsigned)(bit_h * bit_len), 1); // create the image - XImage *I2 = XCreateImage(dpy, DefaultVisual(dpy, screen), 1, XYBitmap, 0, + XImage *I2 = XCreateImage(dpy, App::instance()->defaultVisual(screen), 1, XYBitmap, 0, (char *)bitdata, bit_w, bit_h, 8, 0); if (I2 == None) { diff --git a/src/FbTk/XftFontImp.cc b/src/FbTk/XftFontImp.cc index 80eb2c4..fe5b8e6 100644 --- a/src/FbTk/XftFontImp.cc +++ b/src/FbTk/XftFontImp.cc @@ -102,8 +102,8 @@ void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString XftDraw *draw = XftDrawCreate(w.display(), w.drawable(), - DefaultVisual(w.display(), screen), - DefaultColormap(w.display(), screen)); + App::instance()->defaultVisual(screen), + App::instance()->defaultColormap(screen)); XGCValues gc_val; @@ -114,7 +114,7 @@ void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString // get red, green, blue values XColor xcol; xcol.pixel = gc_val.foreground; - XQueryColor(w.display(), DefaultColormap(w.display(), screen), &xcol); + XQueryColor(w.display(), App::instance()->defaultColormap(screen), &xcol); // convert xcolor to XftColor XRenderColor rendcol; @@ -124,8 +124,8 @@ void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString rendcol.alpha = 0xFFFF; XftColor xftcolor; XftColorAllocValue(w.display(), - DefaultVisual(w.display(), screen), - DefaultColormap(w.display(), screen), + App::instance()->defaultVisual(screen), + App::instance()->defaultColormap(screen), &rendcol, &xftcolor); // draw string @@ -145,8 +145,8 @@ void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString x, y, (XftChar8 *)(text.data()), len); XftColorFree(w.display(), - DefaultVisual(w.display(), screen), - DefaultColormap(w.display(), screen), &xftcolor); + App::instance()->defaultVisual(screen), + App::instance()->defaultColormap(screen), &xftcolor); XftDrawDestroy(draw); return; } @@ -161,8 +161,8 @@ void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString XftColorFree(w.display(), - DefaultVisual(w.display(), screen), - DefaultColormap(w.display(), screen), &xftcolor); + App::instance()->defaultVisual(screen), + App::instance()->defaultColormap(screen), &xftcolor); XftDrawDestroy(draw); } diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 2975252..c7763f8 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -51,7 +51,10 @@ FbWinFrame::FbWinFrame(BScreen &screen, WindowState &state, m_window(theme->screenNum(), state.x, state.y, state.width, state.height, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | - LeaveWindowMask, true), + LeaveWindowMask, + screen.rootWindow().visual(), + screen.rootWindow().colormap(), screen.rootWindow().depth(), + true, false), m_layeritem(window(), *screen.layerManager().getLayer(Layer::NORMAL)), m_titlebar(m_window, 0, 0, 100, 16, ButtonPressMask | ButtonReleaseMask | diff --git a/src/IconButton.cc b/src/IconButton.cc index d63f6da..a1d7efa 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -202,7 +202,7 @@ void IconButton::update(FbTk::Subject *subj) { m_icon_window.moveResize(iconx, icony, neww, newh); m_icon_pixmap.copy(m_win.icon().pixmap().drawable(), - DefaultDepth(display, screen), screen); + FbTk::App::instance()->defaultDepth(screen), screen); m_icon_pixmap.scale(m_icon_window.width(), m_icon_window.height()); // rotate the icon or not?? lets go not for now, and see what they say... diff --git a/src/Screen.cc b/src/Screen.cc index 8b605e7..416b6be 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -335,8 +335,8 @@ BScreen::BScreen(FbTk::ResourceManager &rm, m_geom_window(new OSDWindow(m_root_window, *this, *m_focused_windowtheme)), m_pos_window(new OSDWindow(m_root_window, *this, *m_focused_windowtheme)), m_tooltip_window(new TooltipWindow(m_root_window, *this, *m_focused_windowtheme)), - m_dummy_window(scrn, -1, -1, 1, 1, 0, true, false, CopyFromParent, - InputOnly), + m_dummy_window(scrn, -1, -1, 1, 1, 0, CopyFromParent, 0, CopyFromParent, + true, false, InputOnly), resource(rm, screenname, altscreenname), m_resource_manager(rm), m_name(screenname), diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 96d2701..30ca9a0 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -187,7 +187,7 @@ Toolbar::Frame::Frame(FbTk::EventHandler &evh, int screen_num): // event mask ButtonPressMask | ButtonReleaseMask | ExposureMask | EnterWindowMask | LeaveWindowMask | SubstructureNotifyMask, - + CopyFromParent, 0, CopyFromParent, true) // override redirect { diff --git a/src/WinButton.cc b/src/WinButton.cc index d64034e..d570758 100644 --- a/src/WinButton.cc +++ b/src/WinButton.cc @@ -284,11 +284,10 @@ void WinButton::update(FbTk::Subject *subj) { // update the menu icon if (m_type == MENUICON && !m_listen_to.empty()) { - Display* display = m_listen_to.fbWindow().display(); int screen = m_listen_to.screen().screenNumber(); if (m_listen_to.icon().pixmap().drawable() != None) { m_icon_pixmap.copy(m_listen_to.icon().pixmap().drawable(), - DefaultDepth(display, screen), screen); + FbTk::App::instance()->defaultDepth(screen), screen); m_icon_pixmap.scale(width() - 4, height() - 4); } else m_icon_pixmap.release(); diff --git a/src/WinClient.cc b/src/WinClient.cc index 3a22e4a..c64f5d8 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -107,6 +107,12 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin): // this needs to be done before creating an fbwindow, so this doesn't get // tabbed using the apps file updateTransientInfo(); + + // Record the visual + XWindowAttributes a; + XGetWindowAttributes(display(), win, &a); + m_visual = a.visual; + printf("WinClient: Client visual is 0x%02x\n", (unsigned)XVisualIDFromVisual(m_visual)); } WinClient::~WinClient() { diff --git a/src/WinClient.hh b/src/WinClient.hh index 90c5b14..d589dd0 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh @@ -126,6 +126,8 @@ public: static const int PropMwmHintsElements = 3; + Visual* visual() const { return m_visual; } + /** !! TODO !! remove or move these to private @@ -155,6 +157,7 @@ private: bool m_title_override; bool m_icon_override; + Visual *m_visual; WindowState::WindowType m_window_type; MwmHints *m_mwm_hint; diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 93768da..580bc4c 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -169,6 +169,9 @@ int handleXErrors(Display *d, XErrorEvent *e) { (int)e->request_code<<"/"<<(int)e->minor_code<<" resource 0x"<resourceid<error_code != 9 && e->error_code != 183) // kill(0, 2); + if (e->error_code == BadDrawable) { + kill(0,2); + } } #endif // !DEBUG -- cgit v0.11.2