use FbPixmap
This commit is contained in:
parent
d75cb35327
commit
fabfc41002
2 changed files with 31 additions and 27 deletions
48
src/Shape.cc
48
src/Shape.cc
|
@ -19,12 +19,14 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: Shape.cc,v 1.8 2004/01/09 02:17:46 fluxgen Exp $
|
// $Id: Shape.cc,v 1.9 2004/01/11 15:02:11 fluxgen Exp $
|
||||||
|
|
||||||
#include "Shape.hh"
|
#include "Shape.hh"
|
||||||
|
|
||||||
#include "FbTk/FbWindow.hh"
|
#include "FbTk/FbWindow.hh"
|
||||||
#include "FbTk/App.hh"
|
#include "FbTk/App.hh"
|
||||||
#include "FbTk/GContext.hh"
|
#include "FbTk/GContext.hh"
|
||||||
|
#include "FbTk/FbPixmap.hh"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ using namespace std;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Pixmap createShape(FbTk::FbWindow &win, int place) {
|
FbTk::FbPixmap *createShape(FbTk::FbWindow &win, int place) {
|
||||||
if (win.window() == 0 || place == 0 ||
|
if (win.window() == 0 || place == 0 ||
|
||||||
win.width() < 3 || win.height() < 3)
|
win.width() < 3 || win.height() < 3)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -111,39 +113,34 @@ Pixmap createShape(FbTk::FbWindow &win, int place) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pixmap pm = XCreatePixmap(disp, win.window(), win_width, win_height, 1);
|
FbTk::FbPixmap *pm = new FbTk::FbPixmap(win, win_width, win_height, 1);
|
||||||
|
|
||||||
FbTk::GContext gc(pm);
|
|
||||||
|
FbTk::GContext gc(*pm);
|
||||||
|
|
||||||
XPutImage(disp, pm, gc.gc(), ximage, 0, 0, 0, 0,
|
XPutImage(disp, pm->drawable(), gc.gc(), ximage, 0, 0, 0, 0,
|
||||||
win_width, win_height);
|
win_width, win_height);
|
||||||
|
|
||||||
XDestroyImage(ximage);
|
XDestroyImage(ximage);
|
||||||
|
|
||||||
return pm;
|
return pm;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
Shape::Shape(FbTk::FbWindow &win, int shapeplaces):
|
Shape::Shape(FbTk::FbWindow &win, int shapeplaces):
|
||||||
m_win(&win),
|
m_win(&win),
|
||||||
m_shapeplaces(shapeplaces) {
|
m_shapeplaces(shapeplaces) {
|
||||||
|
|
||||||
m_shape = createShape(win, shapeplaces);
|
m_shape.reset(createShape(win, shapeplaces));
|
||||||
m_width = win.width();
|
|
||||||
m_height = win.height();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Shape::~Shape() {
|
Shape::~Shape() {
|
||||||
if (m_shape != 0)
|
|
||||||
XFreePixmap(FbTk::App::instance()->display(), m_shape);
|
|
||||||
|
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
if (m_win != 0 && m_win->window()) {
|
if (m_win != 0 && m_win->window()) {
|
||||||
// reset shape of window
|
// Reset shape of window
|
||||||
XShapeCombineMask(FbTk::App::instance()->display(),
|
XShapeCombineMask(FbTk::App::instance()->display(),
|
||||||
m_win->window(),
|
m_win->window(),
|
||||||
ShapeBounding,
|
ShapeBounding,
|
||||||
|
@ -162,14 +159,10 @@ void Shape::update() {
|
||||||
if (m_win == 0 || m_win->window() == 0)
|
if (m_win == 0 || m_win->window() == 0)
|
||||||
return;
|
return;
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
if (m_win->width() != m_width ||
|
if (m_shape.get() == 0 ||
|
||||||
m_win->height() != m_height) {
|
m_win->width() != width() ||
|
||||||
if (m_shape != 0)
|
m_win->height() != height()) {
|
||||||
XFreePixmap(FbTk::App::instance()->display(), m_shape);
|
m_shape.reset(createShape(*m_win, m_shapeplaces));
|
||||||
m_shape = createShape(*m_win, m_shapeplaces);
|
|
||||||
m_width = m_win->width();
|
|
||||||
m_height = m_win->height();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// the m_shape can be = 0 which will just reset the shape mask
|
// the m_shape can be = 0 which will just reset the shape mask
|
||||||
|
@ -178,9 +171,10 @@ void Shape::update() {
|
||||||
m_win->window(),
|
m_win->window(),
|
||||||
ShapeBounding,
|
ShapeBounding,
|
||||||
-m_win->borderWidth(), -m_win->borderWidth(),
|
-m_win->borderWidth(), -m_win->borderWidth(),
|
||||||
m_shape,
|
m_shape.get() ? m_shape->drawable() : 0,
|
||||||
ShapeSet);
|
ShapeSet);
|
||||||
|
|
||||||
|
|
||||||
#endif // SHAPE
|
#endif // SHAPE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -215,3 +209,11 @@ bool Shape::isShaped(const FbTk::FbWindow &win) {
|
||||||
|
|
||||||
return (shaped != 0 ? true : false);
|
return (shaped != 0 ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Shape::width() const {
|
||||||
|
return m_shape.get() ? m_shape->width() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int Shape::height() const {
|
||||||
|
return m_shape.get() ? m_shape->height() : 0;
|
||||||
|
}
|
||||||
|
|
10
src/Shape.hh
10
src/Shape.hh
|
@ -19,15 +19,17 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: Shape.hh,v 1.3 2003/12/16 23:32:02 fluxgen Exp $
|
// $Id: Shape.hh,v 1.4 2004/01/11 15:02:11 fluxgen Exp $
|
||||||
|
|
||||||
#ifndef SHAPE_HH
|
#ifndef SHAPE_HH
|
||||||
#define SHAPE_HH
|
#define SHAPE_HH
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace FbTk {
|
namespace FbTk {
|
||||||
class FbWindow;
|
class FbWindow;
|
||||||
|
class FbPixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// creates round corners on windows
|
/// creates round corners on windows
|
||||||
|
@ -49,16 +51,16 @@ public:
|
||||||
void update();
|
void update();
|
||||||
/// assign a new window
|
/// assign a new window
|
||||||
void setWindow(FbTk::FbWindow &win);
|
void setWindow(FbTk::FbWindow &win);
|
||||||
|
unsigned int width() const;
|
||||||
|
unsigned int height() const;
|
||||||
// sets shape notify mask
|
// sets shape notify mask
|
||||||
static void setShapeNotify(const FbTk::FbWindow &win);
|
static void setShapeNotify(const FbTk::FbWindow &win);
|
||||||
/// @return true if window has shape
|
/// @return true if window has shape
|
||||||
static bool isShaped(const FbTk::FbWindow &win);
|
static bool isShaped(const FbTk::FbWindow &win);
|
||||||
private:
|
private:
|
||||||
FbTk::FbWindow *m_win; ///< window to be shaped
|
FbTk::FbWindow *m_win; ///< window to be shaped
|
||||||
Pixmap m_shape; ///< our shape pixmap
|
std::auto_ptr<FbTk::FbPixmap> m_shape; ///< our shape pixmap
|
||||||
int m_shapeplaces; ///< places to shape
|
int m_shapeplaces; ///< places to shape
|
||||||
unsigned int m_width; ///< width of window (the "old" size), if width != window width then shape resizes
|
|
||||||
unsigned int m_height; ///< height of window (the "old" size), if height != window height then shape resizes
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHAPE_HH
|
#endif // SHAPE_HH
|
||||||
|
|
Loading…
Reference in a new issue