From 3ac43716b79cd6ee207aee4c0444678f2ac6298b Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 13 May 2003 21:12:18 +0000 Subject: transparent slit --- src/Screen.cc | 5 +++-- src/Screen.hh | 6 ++++-- src/Slit.cc | 44 +++++++++++++++++++++++++++++++++++++++----- src/Slit.hh | 4 +++- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index a81e60b..a399258 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.163 2003/05/13 14:03:27 fluxgen Exp $ +// $Id: Screen.cc,v 1.164 2003/05/13 21:12:18 fluxgen Exp $ #include "Screen.hh" @@ -485,7 +485,8 @@ BScreen::ScreenResource::ScreenResource(ResourceManager &rm, slit_auto_hide(rm, false, scrname+".slit.autoHide", altscrname+".Slit.AutoHide"), slit_placement(rm, Slit::BOTTOMRIGHT, scrname+".slit.placement", altscrname+".Slit.Placement"), - slit_direction(rm, Slit::VERTICAL, scrname+".slit.direction", altscrname+".Slit.Direction") + slit_direction(rm, Slit::VERTICAL, scrname+".slit.direction", altscrname+".Slit.Direction"), + slit_alpha(rm, 255, scrname+".slit.alpha", altscrname+".Slit.Alpha") { diff --git a/src/Screen.hh b/src/Screen.hh index 85d3ff7..72647a6 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.95 2003/05/13 14:02:48 fluxgen Exp $ +// $Id: Screen.hh,v 1.96 2003/05/13 21:12:17 fluxgen Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -111,10 +111,11 @@ public: inline Slit::Placement getSlitPlacement() const { return *resource.slit_placement; } inline Slit::Direction getSlitDirection() const { return *resource.slit_direction; } + inline Resource &slitAlphaResource() { return resource.slit_alpha; } inline void saveSlitPlacement(Slit::Placement p) { resource.slit_placement = p; } inline void saveSlitDirection(Slit::Direction d) { resource.slit_direction = d; } inline void saveSlitAutoHide(bool t) { resource.slit_auto_hide = t; } - + inline unsigned int getSlitOnHead() const { return resource.slit_on_head; } inline void saveSlitOnHead(unsigned int h) { resource.slit_on_head = h; } @@ -411,6 +412,7 @@ private: Resource slit_auto_hide; Resource slit_placement; Resource slit_direction; + Resource slit_alpha; unsigned int slit_on_head; diff --git a/src/Slit.cc b/src/Slit.cc index d61b411..936815d 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Slit.cc,v 1.51 2003/05/13 13:28:28 fluxgen Exp $ +// $Id: Slit.cc,v 1.52 2003/05/13 21:09:43 fluxgen Exp $ #include "Slit.hh" @@ -49,6 +49,8 @@ #include "RootTheme.hh" #include "FbTk/Theme.hh" #include "FbMenu.hh" +#include "Transparent.hh" +#include "IntResMenuItem.hh" #include #include @@ -318,6 +320,9 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) create_mask, &attrib); FbTk::EventManager::instance()->add(*this, frame.window); + m_transp.reset(new FbTk::Transparent(screen().rootPixmap(), frame.window.drawable(), + *screen().slitAlphaResource(), + screen().getScreenNumber())); m_layeritem.reset(new FbTk::XLayerItem(frame.window, layer)); @@ -470,7 +475,7 @@ void Slit::addClient(Window w) { FbTk::EventManager::instance()->add(*this, client->icon_window); frame.window.show(); - frame.window.clear(); + clearWindow(); reconfigure(); updateClientmenu(); @@ -557,6 +562,8 @@ void Slit::removeClient(Window w, bool remap) { void Slit::reconfigure() { + m_transp->setAlpha(*screen().slitAlphaResource()); + frame.width = 0; frame.height = 0; @@ -654,8 +661,7 @@ void Slit::reconfigure() { if (tmp) image_ctrl->removeImage(tmp); - frame.window.clear(); - + clearWindow(); int x, y; switch (direction()) { @@ -1064,7 +1070,21 @@ void Slit::configureRequestEvent(XConfigureRequestEvent &event) { } void Slit::exposeEvent(XExposeEvent &ev) { + clearWindow(); +} + +void Slit::clearWindow() { frame.window.clear(); + if (frame.pixmap != 0) { + if (screen().rootPixmap() != m_transp->source()) + m_transp->setSource(screen().rootPixmap(), screen().getScreenNumber()); + + m_transp->render(frame.window.x(), frame.window.y(), + 0, 0, + frame.window.width(), frame.window.height()); + + } + } void Slit::timeout() { @@ -1162,12 +1182,20 @@ void Slit::setupMenu() { using namespace FbTk; FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand(); + FbTk::MacroCommand *s_a_reconf_slit_macro = new FbTk::MacroCommand(); FbTk::RefCount saverc_cmd(new FbTk::SimpleCommand(*Fluxbox::instance(), &Fluxbox::save_rc)); FbTk::RefCount reconf_cmd(new FbCommands::ReconfigureFluxboxCmd()); + FbTk::RefCount reconf_slit_cmd(new FbTk::SimpleCommand(*this, &Slit::reconfigure)); + s_a_reconf_macro->add(saverc_cmd); s_a_reconf_macro->add(reconf_cmd); + + s_a_reconf_slit_macro->add(saverc_cmd); + s_a_reconf_slit_macro->add(reconf_slit_cmd); + FbTk::RefCount save_and_reconfigure(s_a_reconf_macro); + FbTk::RefCount save_and_reconfigure_slit(s_a_reconf_slit_macro); // setup base menu m_slitmenu.setLabel("Slit"); @@ -1182,7 +1210,13 @@ void Slit::setupMenu() { CommonSet, CommonAutoHide, "Auto hide"), screen().doSlitAutoHide(), - save_and_reconfigure)); + save_and_reconfigure_slit)); + + FbTk::MenuItem *alpha_menuitem = new IntResMenuItem("Alpha", + screen().slitAlphaResource(), + 0, 255); + alpha_menuitem->setCommand(save_and_reconfigure_slit); + m_slitmenu.insert(alpha_menuitem); m_slitmenu.insert(new SlitDirMenuItem(i18n->getMessage( SlitSet, SlitSlitDirection, diff --git a/src/Slit.hh b/src/Slit.hh index f2e74bb..4eeed28 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -/// $Id: Slit.hh,v 1.27 2003/05/11 17:42:51 fluxgen Exp $ +/// $Id: Slit.hh,v 1.28 2003/05/13 21:09:43 fluxgen Exp $ #ifndef SLIT_HH #define SLIT_HH @@ -111,6 +111,7 @@ public: private: + void clearWindow(); void setupMenu(); void removeClient(SlitClient *client, bool remap, bool destroy); @@ -144,6 +145,7 @@ private: std::auto_ptr m_layeritem; std::auto_ptr m_slit_theme; + std::auto_ptr m_transp; }; -- cgit v0.11.2