2002-12-03 16:25:27 +00:00
|
|
|
// FbWindow.cc for FbTk - fluxbox toolkit
|
2003-04-29 09:00:13 +00:00
|
|
|
// Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
2002-12-03 16:25:27 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2004-11-19 11:37:27 +00:00
|
|
|
// $Id$
|
2002-12-03 16:25:27 +00:00
|
|
|
|
|
|
|
#include "FbWindow.hh"
|
2004-09-09 14:29:10 +00:00
|
|
|
#include "FbPixmap.hh"
|
2002-12-03 16:25:27 +00:00
|
|
|
|
2003-08-04 12:44:43 +00:00
|
|
|
#include "EventManager.hh"
|
2002-12-03 16:25:27 +00:00
|
|
|
#include "Color.hh"
|
|
|
|
#include "App.hh"
|
2003-08-04 12:44:43 +00:00
|
|
|
#include "Transparent.hh"
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
2004-04-28 13:04:06 +00:00
|
|
|
#include <X11/Xutil.h>
|
2003-08-04 12:44:43 +00:00
|
|
|
#include <X11/Xatom.h>
|
2002-12-03 16:25:27 +00:00
|
|
|
|
2004-08-31 15:26:40 +00:00
|
|
|
#ifdef HAVE_CASSERT
|
|
|
|
#include <cassert>
|
|
|
|
#else
|
|
|
|
#include <assert.h>
|
|
|
|
#endif
|
2002-12-03 16:25:27 +00:00
|
|
|
|
|
|
|
namespace FbTk {
|
|
|
|
|
2004-12-21 16:12:28 +00:00
|
|
|
FbWindow::FbWindow():FbDrawable(), m_parent(0), m_screen_num(0), m_window(0), m_x(0), m_y(0),
|
2003-09-14 09:51:40 +00:00
|
|
|
m_width(0), m_height(0), m_border_width(0), m_depth(0), m_destroy(true),
|
2004-09-10 15:46:08 +00:00
|
|
|
m_buffer_pm(0){
|
2002-12-16 11:17:26 +00:00
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
2004-12-21 16:12:28 +00:00
|
|
|
FbWindow::FbWindow(const FbWindow& the_copy):m_parent(the_copy.parent()),
|
|
|
|
m_screen_num(the_copy.screenNumber()), m_window(the_copy.window()),
|
|
|
|
m_x(the_copy.x()), m_y(the_copy.y()),
|
2003-08-04 12:44:43 +00:00
|
|
|
m_width(the_copy.width()), m_height(the_copy.height()),
|
2004-12-21 16:12:28 +00:00
|
|
|
m_border_width(the_copy.borderWidth()),
|
2003-09-14 09:51:40 +00:00
|
|
|
m_depth(the_copy.depth()), m_destroy(true),
|
|
|
|
m_buffer_pm(0) {
|
2003-08-04 12:44:43 +00:00
|
|
|
the_copy.m_window = 0;
|
|
|
|
}
|
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
FbWindow::FbWindow(int screen_num,
|
2004-12-21 16:12:28 +00:00
|
|
|
int x, int y,
|
|
|
|
unsigned int width, unsigned int height,
|
|
|
|
long eventmask,
|
2002-12-03 16:25:27 +00:00
|
|
|
bool override_redirect,
|
2004-05-17 15:01:32 +00:00
|
|
|
bool save_unders,
|
2002-12-03 16:25:27 +00:00
|
|
|
int depth,
|
2002-12-16 11:17:26 +00:00
|
|
|
int class_type):
|
2004-09-10 15:46:08 +00:00
|
|
|
FbDrawable(),
|
2004-01-08 22:07:58 +00:00
|
|
|
m_parent(0),
|
2002-12-16 11:17:26 +00:00
|
|
|
m_screen_num(screen_num),
|
2004-01-08 22:07:58 +00:00
|
|
|
m_destroy(true),
|
2003-09-14 09:51:40 +00:00
|
|
|
m_buffer_pm(0) {
|
2004-12-21 16:12:28 +00:00
|
|
|
|
|
|
|
create(RootWindow(display(), screen_num),
|
2002-12-03 16:25:27 +00:00
|
|
|
x, y, width, height, eventmask,
|
2004-05-17 15:01:32 +00:00
|
|
|
override_redirect, save_unders, depth, class_type);
|
2002-12-03 16:25:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
FbWindow::FbWindow(const FbWindow &parent,
|
2004-12-21 16:12:28 +00:00
|
|
|
int x, int y, unsigned int width, unsigned int height,
|
2003-04-14 12:13:36 +00:00
|
|
|
long eventmask,
|
2004-05-17 15:01:32 +00:00
|
|
|
bool override_redirect,
|
|
|
|
bool save_unders,
|
2002-12-16 11:17:26 +00:00
|
|
|
int depth, int class_type):
|
2003-04-17 14:16:20 +00:00
|
|
|
m_parent(&parent),
|
2004-12-21 16:12:28 +00:00
|
|
|
m_screen_num(parent.screenNumber()),
|
2004-01-08 22:07:58 +00:00
|
|
|
m_destroy(true),
|
2004-12-21 16:12:28 +00:00
|
|
|
m_buffer_pm(0) {
|
2002-12-03 16:25:27 +00:00
|
|
|
|
2004-12-21 16:12:28 +00:00
|
|
|
create(parent.window(), x, y, width, height, eventmask,
|
2004-05-17 15:01:32 +00:00
|
|
|
override_redirect, save_unders, depth, class_type);
|
2004-12-21 16:12:28 +00:00
|
|
|
|
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
};
|
|
|
|
|
2004-12-21 16:12:28 +00:00
|
|
|
FbWindow::FbWindow(Window client):FbDrawable(), m_parent(0),
|
2003-05-13 14:07:24 +00:00
|
|
|
m_screen_num(0),
|
2004-01-08 22:07:58 +00:00
|
|
|
m_window(0),
|
2003-10-26 20:52:28 +00:00
|
|
|
m_x(0), m_y(0),
|
|
|
|
m_width(1), m_height(1),
|
|
|
|
m_border_width(0),
|
|
|
|
m_depth(0),
|
2003-09-14 09:51:40 +00:00
|
|
|
m_destroy(false), // don't destroy this window
|
|
|
|
m_buffer_pm(0) {
|
2003-05-10 23:11:33 +00:00
|
|
|
|
|
|
|
setNew(client);
|
2003-04-14 12:13:36 +00:00
|
|
|
}
|
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
FbWindow::~FbWindow() {
|
2003-04-17 14:16:20 +00:00
|
|
|
|
2004-09-11 15:52:23 +00:00
|
|
|
// Need to free xrender pics before destroying window
|
|
|
|
if (m_transparent.get() != 0)
|
|
|
|
m_transparent.reset(0);
|
|
|
|
|
2003-04-17 14:16:20 +00:00
|
|
|
if (m_window != 0) {
|
|
|
|
// so we don't get any dangling eventhandler for this window
|
2004-12-21 16:12:28 +00:00
|
|
|
FbTk::EventManager::instance()->remove(m_window);
|
2003-04-17 14:16:20 +00:00
|
|
|
if (m_destroy)
|
2004-12-21 16:12:28 +00:00
|
|
|
XDestroyWindow(display(), m_window);
|
2003-04-17 14:16:20 +00:00
|
|
|
}
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FbWindow::setBackgroundColor(const FbTk::Color &bg_color) {
|
2004-09-11 23:01:34 +00:00
|
|
|
XSetWindowBackground(display(), m_window, bg_color.pixel());
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::setBackgroundPixmap(Pixmap bg_pixmap) {
|
2004-09-11 23:01:34 +00:00
|
|
|
XSetWindowBackgroundPixmap(display(), m_window, bg_pixmap);
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::setBorderColor(const FbTk::Color &border_color) {
|
2004-09-11 23:01:34 +00:00
|
|
|
XSetWindowBorder(display(), m_window, border_color.pixel());
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
2003-08-04 12:44:43 +00:00
|
|
|
|
2004-12-21 16:12:28 +00:00
|
|
|
void FbWindow::setBorderWidth(unsigned int size) {
|
2004-09-11 23:01:34 +00:00
|
|
|
XSetWindowBorderWidth(display(), m_window, size);
|
2003-01-05 22:58:11 +00:00
|
|
|
m_border_width = size;
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::setName(const char *name) {
|
2004-09-11 23:01:34 +00:00
|
|
|
XStoreName(display(), m_window, name);
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::setEventMask(long mask) {
|
2004-09-11 23:01:34 +00:00
|
|
|
XSelectInput(display(), m_window, mask);
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::clear() {
|
2004-09-11 23:01:34 +00:00
|
|
|
XClearWindow(display(), m_window);
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
2004-12-21 16:12:28 +00:00
|
|
|
void FbWindow::clearArea(int x, int y,
|
|
|
|
unsigned int width, unsigned int height,
|
2003-06-24 10:12:57 +00:00
|
|
|
bool exposures) {
|
2004-09-11 23:01:34 +00:00
|
|
|
XClearArea(display(), window(), x, y, width, height, exposures);
|
2003-06-24 10:12:57 +00:00
|
|
|
}
|
|
|
|
|
2003-08-04 12:44:43 +00:00
|
|
|
void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, unsigned int the_height) {
|
|
|
|
#ifdef HAVE_XRENDER
|
2004-09-12 14:56:20 +00:00
|
|
|
if (!m_transparent.get())
|
|
|
|
return;
|
|
|
|
|
2003-08-04 12:44:43 +00:00
|
|
|
if (width() == 0 || height() == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (the_width == 0 || the_height == 0) {
|
|
|
|
the_width = width();
|
|
|
|
the_height = height();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (the_x < 0 || the_y < 0) {
|
|
|
|
the_x = 0;
|
|
|
|
the_y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// update source and destination if needed
|
2004-09-09 14:29:10 +00:00
|
|
|
Pixmap root = FbPixmap::getRootPixmap(screenNumber());
|
2003-08-04 12:44:43 +00:00
|
|
|
if (m_transparent->source() != root)
|
|
|
|
m_transparent->setSource(root, screenNumber());
|
|
|
|
|
2003-09-14 09:51:40 +00:00
|
|
|
if (m_buffer_pm) {
|
|
|
|
if (m_transparent->dest() != m_buffer_pm) {
|
|
|
|
m_transparent->setDest(m_buffer_pm, screenNumber());
|
|
|
|
}
|
|
|
|
} else if (m_transparent->dest() != window())
|
2003-08-04 12:44:43 +00:00
|
|
|
m_transparent->setDest(window(), screenNumber());
|
|
|
|
|
2003-09-14 09:51:40 +00:00
|
|
|
|
2003-08-04 12:44:43 +00:00
|
|
|
// get root position
|
|
|
|
|
|
|
|
const FbWindow *root_parent = parent();
|
|
|
|
// our position in parent ("root")
|
|
|
|
int root_x = x() + borderWidth(), root_y = y() + borderWidth();
|
|
|
|
if (root_parent != 0) {
|
|
|
|
root_x += root_parent->x() + root_parent->borderWidth();
|
|
|
|
root_y += root_parent->y() + root_parent->borderWidth();
|
|
|
|
while (root_parent->parent() != 0) {
|
|
|
|
root_parent = root_parent->parent();
|
|
|
|
root_x += root_parent->x() + root_parent->borderWidth();
|
|
|
|
root_y += root_parent->y() + root_parent->borderWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // else toplevel window so we already have x, y set
|
|
|
|
|
|
|
|
// render background image from root pos to our window
|
|
|
|
m_transparent->render(root_x + the_x, root_y + the_y,
|
|
|
|
the_x, the_y,
|
|
|
|
the_width, the_height);
|
|
|
|
#endif // HAVE_XRENDER
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::setAlpha(unsigned char alpha) {
|
|
|
|
#ifdef HAVE_XRENDER
|
2004-09-12 14:56:20 +00:00
|
|
|
if (FbTk::Transparent::haveComposite()) {
|
|
|
|
if (m_transparent.get() != 0)
|
|
|
|
m_transparent.reset(0);
|
|
|
|
|
|
|
|
// don't setOpaque, let controlling objects do that
|
|
|
|
// since it's only needed on toplevel windows
|
|
|
|
} else if (m_transparent.get() == 0 && alpha < 255) {
|
2004-09-09 14:29:10 +00:00
|
|
|
m_transparent.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), window(), alpha, screenNumber()));
|
2004-05-24 13:09:32 +00:00
|
|
|
} else if (alpha < 255 && alpha != m_transparent->alpha())
|
2003-08-04 12:44:43 +00:00
|
|
|
m_transparent->setAlpha(alpha);
|
2004-05-24 13:09:32 +00:00
|
|
|
else if (alpha == 255)
|
2003-08-04 12:44:43 +00:00
|
|
|
m_transparent.reset(0); // destroy transparent object
|
|
|
|
#endif // HAVE_XRENDER
|
|
|
|
}
|
|
|
|
|
2004-06-07 20:24:38 +00:00
|
|
|
unsigned char FbWindow::alpha() const {
|
|
|
|
#ifdef HAVE_XRENDER
|
|
|
|
if (m_transparent.get())
|
|
|
|
return m_transparent->alpha();
|
|
|
|
#endif // HAVE_XRENDER
|
|
|
|
return 255;
|
|
|
|
}
|
2003-08-04 12:44:43 +00:00
|
|
|
|
|
|
|
FbWindow &FbWindow::operator = (const FbWindow &win) {
|
|
|
|
m_parent = win.parent();
|
|
|
|
m_screen_num = win.screenNumber();
|
|
|
|
m_window = win.window();
|
|
|
|
m_x = win.x();
|
|
|
|
m_y = win.y();
|
|
|
|
m_width = win.width();
|
|
|
|
m_height = win.height();
|
|
|
|
m_border_width = win.borderWidth();
|
|
|
|
m_depth = win.depth();
|
|
|
|
// take over this window
|
|
|
|
win.m_window = 0;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
FbWindow &FbWindow::operator = (Window win) {
|
2004-12-21 16:12:28 +00:00
|
|
|
setNew(win);
|
2003-05-10 23:11:33 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::setNew(Window win) {
|
2003-05-19 08:27:49 +00:00
|
|
|
|
2003-04-14 12:13:36 +00:00
|
|
|
if (m_window != 0 && m_destroy)
|
2004-09-11 23:01:34 +00:00
|
|
|
XDestroyWindow(display(), m_window);
|
2003-10-26 20:52:28 +00:00
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
m_window = win;
|
2003-10-26 20:52:28 +00:00
|
|
|
|
2003-05-06 23:50:31 +00:00
|
|
|
if (m_window != 0) {
|
2002-12-03 21:59:58 +00:00
|
|
|
updateGeometry();
|
2003-05-06 23:50:31 +00:00
|
|
|
XWindowAttributes attr;
|
|
|
|
attr.screen = 0;
|
|
|
|
//get screen number
|
2004-09-11 23:01:34 +00:00
|
|
|
if (XGetWindowAttributes(display(),
|
2003-05-06 23:50:31 +00:00
|
|
|
m_window,
|
|
|
|
&attr) != 0 && attr.screen != 0) {
|
|
|
|
m_screen_num = XScreenNumberOfScreen(attr.screen);
|
2004-01-21 20:07:41 +00:00
|
|
|
if (attr.width <= 0)
|
|
|
|
m_width = 1;
|
|
|
|
else
|
|
|
|
m_width = attr.width;
|
|
|
|
|
|
|
|
if (attr.height <= 0)
|
|
|
|
m_height = 1;
|
|
|
|
else
|
|
|
|
m_height = attr.height;
|
|
|
|
|
2003-10-26 20:52:28 +00:00
|
|
|
m_x = attr.x;
|
|
|
|
m_y = attr.y;
|
|
|
|
m_depth = attr.depth;
|
|
|
|
m_border_width = attr.border_width;
|
2003-05-06 23:50:31 +00:00
|
|
|
}
|
2004-12-21 16:12:28 +00:00
|
|
|
|
2003-05-10 23:11:33 +00:00
|
|
|
}
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::show() {
|
2004-09-11 23:01:34 +00:00
|
|
|
XMapWindow(display(), m_window);
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 11:17:26 +00:00
|
|
|
void FbWindow::showSubwindows() {
|
2004-09-11 23:01:34 +00:00
|
|
|
XMapSubwindows(display(), m_window);
|
2002-12-16 11:17:26 +00:00
|
|
|
}
|
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
void FbWindow::hide() {
|
2004-09-11 23:01:34 +00:00
|
|
|
XUnmapWindow(display(), m_window);
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::lower() {
|
2004-09-11 23:01:34 +00:00
|
|
|
XLowerWindow(display(), window());
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::raise() {
|
2004-09-11 23:01:34 +00:00
|
|
|
XRaiseWindow(display(), window());
|
2003-07-02 05:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::setInputFocus(int revert_to, int time) {
|
2004-09-11 23:01:34 +00:00
|
|
|
XSetInputFocus(display(), window(), revert_to, time);
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
2003-05-17 10:43:20 +00:00
|
|
|
void FbWindow::setCursor(Cursor cur) {
|
2004-12-21 16:12:28 +00:00
|
|
|
XDefineCursor(display(), window(), cur);
|
2003-05-17 10:43:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::unsetCursor() {
|
2004-09-11 23:01:34 +00:00
|
|
|
XUndefineCursor(display(), window());
|
2003-05-17 10:43:20 +00:00
|
|
|
}
|
|
|
|
|
2004-09-11 12:33:14 +00:00
|
|
|
void FbWindow::reparent(const FbWindow &parent, int x, int y, bool continuing) {
|
2004-09-11 23:01:34 +00:00
|
|
|
XReparentWindow(display(), window(), parent.window(), x, y);
|
2003-08-15 13:52:06 +00:00
|
|
|
m_parent = &parent;
|
2004-09-11 12:33:14 +00:00
|
|
|
if (continuing) // we will continue managing this window after reparent
|
|
|
|
updateGeometry();
|
2003-08-15 13:52:06 +00:00
|
|
|
}
|
2003-05-19 22:38:55 +00:00
|
|
|
|
2004-04-28 13:04:06 +00:00
|
|
|
std::string FbWindow::textProperty(Atom property) const {
|
|
|
|
XTextProperty text_prop;
|
|
|
|
char ** stringlist;
|
|
|
|
int count;
|
|
|
|
std::string ret;
|
|
|
|
|
2004-09-11 23:01:34 +00:00
|
|
|
if (XGetTextProperty(display(), window(), &text_prop, property) == 0)
|
2004-04-28 13:04:06 +00:00
|
|
|
return "";
|
|
|
|
|
|
|
|
if (text_prop.value == 0 || text_prop.nitems == 0)
|
|
|
|
return "";
|
|
|
|
|
|
|
|
if (text_prop.encoding != XA_STRING) {
|
|
|
|
// still returns a "StringList" despite the different name
|
2004-09-11 23:01:34 +00:00
|
|
|
if (XmbTextPropertyToTextList(display(), &text_prop, &stringlist, &count) == 0 || count == 0)
|
2004-04-28 13:04:06 +00:00
|
|
|
return "";
|
|
|
|
} else {
|
|
|
|
if (XTextPropertyToStringList(&text_prop, &stringlist, &count) == 0 || count == 0)
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = stringlist[0];
|
|
|
|
XFreeStringList(stringlist);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-05-19 22:38:55 +00:00
|
|
|
bool FbWindow::property(Atom property,
|
|
|
|
long long_offset, long long_length,
|
|
|
|
bool do_delete,
|
|
|
|
Atom req_type,
|
|
|
|
Atom *actual_type_return,
|
|
|
|
int *actual_format_return,
|
|
|
|
unsigned long *nitems_return,
|
|
|
|
unsigned long *bytes_after_return,
|
|
|
|
unsigned char **prop_return) const {
|
2004-12-21 16:12:28 +00:00
|
|
|
if (XGetWindowProperty(display(), window(),
|
|
|
|
property, long_offset, long_length, do_delete,
|
2003-08-04 12:44:43 +00:00
|
|
|
req_type, actual_type_return,
|
|
|
|
actual_format_return, nitems_return,
|
|
|
|
bytes_after_return, prop_return) == Success)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2003-05-19 22:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::changeProperty(Atom property, Atom type,
|
|
|
|
int format,
|
|
|
|
int mode,
|
|
|
|
unsigned char *data,
|
|
|
|
int nelements) {
|
2004-12-21 16:12:28 +00:00
|
|
|
|
2004-09-11 23:01:34 +00:00
|
|
|
XChangeProperty(display(), m_window, property, type,
|
2004-12-21 16:12:28 +00:00
|
|
|
format, mode,
|
2003-05-19 22:38:55 +00:00
|
|
|
data, nelements);
|
|
|
|
}
|
|
|
|
|
2004-12-21 16:12:28 +00:00
|
|
|
void FbWindow::deleteProperty(Atom property) {
|
|
|
|
XDeleteProperty(display(), m_window, property);
|
|
|
|
}
|
|
|
|
|
2002-12-16 11:17:26 +00:00
|
|
|
int FbWindow::screenNumber() const {
|
|
|
|
return m_screen_num;
|
|
|
|
}
|
2003-04-14 12:13:36 +00:00
|
|
|
|
2003-08-26 23:45:36 +00:00
|
|
|
long FbWindow::eventMask() const {
|
|
|
|
XWindowAttributes attrib;
|
2004-12-21 16:12:28 +00:00
|
|
|
XGetWindowAttributes(display(), window(),
|
2004-06-15 11:03:17 +00:00
|
|
|
&attrib);
|
|
|
|
return attrib.your_event_mask;
|
|
|
|
|
2003-08-26 23:45:36 +00:00
|
|
|
}
|
|
|
|
|
2004-09-12 14:56:20 +00:00
|
|
|
void FbWindow::setOpaque(unsigned char alpha) {
|
|
|
|
#ifdef HAVE_XRENDER
|
|
|
|
static Atom m_alphaatom = XInternAtom(display(), "_NET_WM_WINDOW_OPACITY", False);
|
|
|
|
unsigned int opacity = alpha << 24;
|
|
|
|
changeProperty(m_alphaatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1l);
|
|
|
|
#endif // HAVE_XRENDER
|
|
|
|
}
|
|
|
|
|
2003-09-14 09:51:40 +00:00
|
|
|
void FbWindow::setBufferPixmap(Pixmap pm) {
|
|
|
|
m_buffer_pm = pm;
|
|
|
|
}
|
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
void FbWindow::updateGeometry() {
|
|
|
|
if (m_window == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Window root;
|
2003-02-23 16:52:17 +00:00
|
|
|
unsigned int border_width, depth;
|
2004-09-11 23:01:34 +00:00
|
|
|
XGetGeometry(display(), m_window, &root, &m_x, &m_y,
|
2004-12-21 16:12:28 +00:00
|
|
|
(unsigned int *)&m_width, (unsigned int *)&m_height,
|
2003-02-23 16:52:17 +00:00
|
|
|
&border_width, &depth);
|
2003-05-10 13:26:37 +00:00
|
|
|
m_depth = depth;
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::create(Window parent, int x, int y,
|
2004-12-21 16:12:28 +00:00
|
|
|
unsigned int width, unsigned int height,
|
2002-12-03 16:25:27 +00:00
|
|
|
long eventmask, bool override_redirect,
|
2004-05-17 15:01:32 +00:00
|
|
|
bool save_unders, int depth, int class_type) {
|
2004-12-21 16:12:28 +00:00
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
|
2003-01-05 22:58:11 +00:00
|
|
|
m_border_width = 0;
|
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
long valmask = CWEventMask;
|
|
|
|
XSetWindowAttributes values;
|
|
|
|
values.event_mask = eventmask;
|
|
|
|
|
2004-12-21 16:12:28 +00:00
|
|
|
if (override_redirect) {
|
2002-12-03 16:25:27 +00:00
|
|
|
valmask |= CWOverrideRedirect;
|
|
|
|
values.override_redirect = True;
|
|
|
|
}
|
|
|
|
|
2004-05-17 15:01:32 +00:00
|
|
|
if (save_unders) {
|
|
|
|
valmask |= CWSaveUnder;
|
|
|
|
values.save_under = True;
|
|
|
|
}
|
|
|
|
|
2004-09-11 23:01:34 +00:00
|
|
|
m_window = XCreateWindow(display(), parent, x, y, width, height,
|
2004-12-21 16:12:28 +00:00
|
|
|
0, // border width
|
2002-12-03 16:25:27 +00:00
|
|
|
depth, // depth
|
|
|
|
class_type, // class
|
|
|
|
CopyFromParent, // visual
|
|
|
|
valmask, // create mask
|
|
|
|
&values); // create atrribs
|
2004-12-21 16:12:28 +00:00
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
assert(m_window);
|
|
|
|
|
|
|
|
updateGeometry();
|
2003-10-14 21:49:21 +00:00
|
|
|
FbWindow::setBackgroundColor(Color("gray", screenNumber()));
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator == (Window win, const FbWindow &fbwin) {
|
|
|
|
return win == fbwin.window();
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|