From 12f44680dfefde602f3387c6d385f4c5e68990e4 Mon Sep 17 00:00:00 2001 From: Gediminas Liktaras Date: Thu, 20 Oct 2011 09:41:25 +0200 Subject: Added support for ARGB visual, patch #3284774 fluxbox now properly displays windows that require ARGB visuals when an external compositor is running. This was done by creating the container window with the correct visual and colormap when needed. Closes #2874629 --- src/FbRootWindow.cc | 35 ++++++++++++++++++++++++++--------- src/FbRootWindow.hh | 8 ++++++++ src/FbTk/FbWindow.cc | 29 +++++++++++++++++++---------- src/FbTk/FbWindow.hh | 14 +++++++++++--- src/FbWinFrame.cc | 32 ++++++++++++++++++++++++-------- src/FbWinFrame.hh | 2 +- src/Window.cc | 2 +- 7 files changed, 90 insertions(+), 32 deletions(-) diff --git a/src/FbRootWindow.cc b/src/FbRootWindow.cc index 7e2b77e..e329719 100644 --- a/src/FbRootWindow.cc +++ b/src/FbRootWindow.cc @@ -27,10 +27,20 @@ FbRootWindow::FbRootWindow(int screen_num): FbTk::FbWindow(RootWindow(FbTk::App::instance()->display(), screen_num)), m_visual(0), - m_colormap(0) { + m_colormap(0), + m_decorationDepth(0), + m_decorationVisual(0), + m_decorationColormap(0) { Display *disp = FbTk::App::instance()->display(); + m_visual = DefaultVisual(disp, screen_num); + m_colormap = DefaultColormap(disp, screen_num); + + m_decorationDepth = DefaultDepth(disp, screen_num); + m_decorationVisual = DefaultVisual(disp, screen_num); + m_decorationColormap = DefaultColormap(disp, screen_num); + // search for a TrueColor Visual... if we can't find one... we will use the // default visual for the screen XVisualInfo vinfo_template, *vinfo_return; @@ -44,19 +54,26 @@ 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) + && (depth() < vinfo_return[i].depth)){ m_visual = vinfo_return[i].visual; + setDepth(vinfo_return[i].depth); + } + + if((m_decorationDepth < vinfo_return[i].depth) + && (vinfo_return[i].depth != 32)) { + m_decorationVisual = vinfo_return[i].visual; + m_decorationDepth = vinfo_return[i].depth; + } } XFree(vinfo_return); } - if (m_visual) { - m_colormap = XCreateColormap(disp, window(), - m_visual, AllocNone); - } else { - m_visual = DefaultVisual(disp, screen_num); - m_colormap = DefaultColormap(disp, screen_num); + if (m_visual != DefaultVisual(disp, screen_num)) { + m_colormap = XCreateColormap(disp, window(), m_visual, AllocNone); + } + if (m_decorationVisual != DefaultVisual(disp, screen_num)) { + m_decorationColormap = XCreateColormap(disp, window(), m_visual, AllocNone); } } diff --git a/src/FbRootWindow.hh b/src/FbRootWindow.hh index 34b8219..8e97cc3 100644 --- a/src/FbRootWindow.hh +++ b/src/FbRootWindow.hh @@ -38,9 +38,17 @@ public: Visual *visual() const { return m_visual; } Colormap colormap() const { return m_colormap; } + int decorationDepth() const { return m_decorationDepth; } + Visual *decorationVisual() const { return m_decorationVisual; } + Colormap decorationColormap() const { return m_decorationColormap; } + private: Visual *m_visual; Colormap m_colormap; + + int m_decorationDepth; + Visual *m_decorationVisual; + Colormap m_decorationColormap; }; #endif // FBROOTWINDOW_HH diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index 9fa59fc..8362733 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc @@ -77,7 +77,9 @@ FbWindow::FbWindow(int screen_num, bool override_redirect, bool save_unders, unsigned int depth, - int class_type): + int class_type, + Visual *visual, + Colormap cmap): FbDrawable(), m_parent(0), m_screen_num(screen_num), @@ -93,7 +95,7 @@ FbWindow::FbWindow(int screen_num, 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, @@ -101,7 +103,10 @@ FbWindow::FbWindow(const FbWindow &parent, long eventmask, bool override_redirect, bool save_unders, - unsigned int depth, int class_type): + unsigned int depth, + int class_type, + Visual *visual, + Colormap cmap): FbDrawable(), m_parent(&parent), m_screen_num(parent.screenNumber()), @@ -113,9 +118,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, visual, cmap); } FbWindow::FbWindow(Window client): @@ -634,9 +637,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; m_border_color = 0; @@ -654,11 +656,18 @@ void FbWindow::create(Window parent, int x, int y, values.save_under = True; } + if (cmap != CopyFromParent) { + valmask |= CWColormap | CWBackPixel | CWBorderPixel; + values.colormap = cmap; + values.background_pixel = XWhitePixel(display(), 0); + values.border_pixel = XBlackPixel(display(), 0); + } + 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 diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh index 6f6a558..e03083c 100644 --- a/src/FbTk/FbWindow.hh +++ b/src/FbTk/FbWindow.hh @@ -57,7 +57,9 @@ public: bool overrride_redirect = false, bool save_unders = false, unsigned int depth = CopyFromParent, - int class_type = InputOutput); + int class_type = InputOutput, + Visual *visual = CopyFromParent, + Colormap cmap = CopyFromParent); FbWindow(const FbWindow &parent, int x, int y, @@ -66,7 +68,9 @@ public: bool overrride_redirect = false, bool save_unders = false, unsigned int depth = CopyFromParent, - int class_type = InputOutput); + int class_type = InputOutput, + Visual *visual = CopyFromParent, + Colormap cmap = CopyFromParent); virtual ~FbWindow(); virtual void setBackgroundColor(const FbTk::Color &bg_color); @@ -207,6 +211,8 @@ protected: /// creates a window with x window client (m_window = client) explicit FbWindow(Window client); + void setDepth(unsigned int depth) { m_depth = depth; } + private: /// sets new X window and destroys old void setNew(Window win); @@ -216,7 +222,9 @@ private: bool override_redirect, bool save_unders, unsigned int depth, - int class_type); + int class_type, + Visual *visual, + Colormap cmap); const FbWindow *m_parent; ///< parent FbWindow int m_screen_num; ///< screen num on which this window exist diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index a8ee4d5..53cecf7 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -45,7 +45,8 @@ using std::string; using FbTk::STLUtil::forAll; -FbWinFrame::FbWinFrame(BScreen &screen, WindowState &state, +FbWinFrame::FbWinFrame(BScreen &screen, unsigned int client_depth, + WindowState &state, FocusableTheme &theme): m_screen(screen), m_theme(theme), @@ -54,26 +55,41 @@ 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, true, false, + client_depth, InputOutput, + ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().visual() : CopyFromParent), + ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().colormap() : CopyFromParent)), m_layeritem(window(), *screen.layerManager().getLayer(ResourceLayer::NORMAL)), m_titlebar(m_window, 0, 0, 100, 16, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | - EnterWindowMask | LeaveWindowMask), + EnterWindowMask | LeaveWindowMask, + false, false, screen.rootWindow().decorationDepth(), InputOutput, + screen.rootWindow().decorationVisual(), + screen.rootWindow().decorationColormap()), m_tab_container(m_titlebar), m_label(m_titlebar, m_theme->font(), FbTk::BiDiString("")), m_handle(m_window, 0, 0, 100, 5, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | - EnterWindowMask | LeaveWindowMask), + EnterWindowMask | LeaveWindowMask, + false, false, screen.rootWindow().decorationDepth(), InputOutput, + screen.rootWindow().decorationVisual(), + screen.rootWindow().decorationColormap()), m_grip_right(m_handle, 0, 0, 10, 4, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | - EnterWindowMask | LeaveWindowMask), + EnterWindowMask | LeaveWindowMask, + false, false, screen.rootWindow().decorationDepth(), InputOutput, + screen.rootWindow().decorationVisual(), + screen.rootWindow().decorationColormap()), m_grip_left(m_handle, 0, 0, 10, 4, - ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | ExposureMask | - EnterWindowMask | LeaveWindowMask), + ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | ExposureMask | + EnterWindowMask | LeaveWindowMask, + false, false, screen.rootWindow().decorationDepth(), InputOutput, + screen.rootWindow().decorationVisual(), + screen.rootWindow().decorationColormap()), m_clientarea(m_window, 0, 0, 100, 100, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 5e13301..347a668 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -70,7 +70,7 @@ public: }; /// create a top level window - FbWinFrame(BScreen &screen, WindowState &state, + FbWinFrame(BScreen &screen, unsigned int client_depth, WindowState &state, FocusableTheme &theme); /* /// create a frame window inside another FbWindow, NOT IMPLEMENTED! diff --git a/src/Window.cc b/src/Window.cc index 6e60a80..db5bacc 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -281,7 +281,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client): screen().unfocusedWinButtonTheme()), m_theme(*this, screen().focusedWinFrameTheme(), screen().unfocusedWinFrameTheme()), - m_frame(client.screen(), m_state, m_theme), + m_frame(client.screen(), client.depth(), m_state, m_theme), m_placed(false), m_old_layernum(0), m_parent(client.screen().rootWindow()), -- cgit v0.11.2