2002-12-03 16:25:27 +00:00
|
|
|
// FbWindow.cc for FbTk - fluxbox toolkit
|
2006-02-16 06:53:05 +00:00
|
|
|
// Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
|
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.
|
|
|
|
|
|
|
|
#include "FbWindow.hh"
|
2004-09-09 14:29:10 +00:00
|
|
|
#include "FbPixmap.hh"
|
2006-05-07 10:08:25 +00:00
|
|
|
#include "FbString.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
|
|
|
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
#include <limits>
|
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
namespace FbTk {
|
|
|
|
|
2008-05-24 08:03:59 +00:00
|
|
|
FbWindow::FbWindow():
|
|
|
|
FbDrawable(),
|
|
|
|
m_parent(0), m_screen_num(0), m_window(0),
|
|
|
|
m_x(0), m_y(0), m_width(0), m_height(0),
|
|
|
|
m_border_width(0), m_border_color(0),
|
|
|
|
m_depth(0), m_destroy(true),
|
|
|
|
m_lastbg_color_set(false), m_lastbg_color(0), m_lastbg_pm(0),
|
|
|
|
m_renderer(0) {
|
2002-12-16 11:17:26 +00:00
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
2008-05-24 08:03:59 +00:00
|
|
|
FbWindow::FbWindow(const FbWindow& the_copy):
|
|
|
|
FbDrawable(),
|
|
|
|
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()),
|
|
|
|
m_width(the_copy.width()), m_height(the_copy.height()),
|
|
|
|
m_border_width(the_copy.borderWidth()),
|
|
|
|
m_border_color(the_copy.borderColor()),
|
|
|
|
m_depth(the_copy.depth()), m_destroy(true),
|
|
|
|
m_lastbg_color_set(false), m_lastbg_color(0), m_lastbg_pm(0),
|
|
|
|
m_renderer(the_copy.m_renderer) {
|
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,
|
2007-12-25 05:15:17 +00:00
|
|
|
unsigned 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),
|
2010-05-16 12:24:34 +00:00
|
|
|
m_window(0),
|
|
|
|
m_x(0), m_y(0), m_width(1), m_height(1),
|
2010-03-26 16:28:18 +00:00
|
|
|
m_border_width(0),
|
|
|
|
m_border_color(0),
|
|
|
|
m_depth(0),
|
2004-01-08 22:07:58 +00:00
|
|
|
m_destroy(true),
|
2005-04-10 18:18:14 +00:00
|
|
|
m_lastbg_color_set(false),
|
|
|
|
m_lastbg_color(0),
|
2005-04-28 14:20:59 +00:00
|
|
|
m_lastbg_pm(0), m_renderer(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);
|
2009-09-30 19:02:24 +00:00
|
|
|
}
|
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,
|
2007-12-25 05:15:17 +00:00
|
|
|
unsigned int depth, int class_type):
|
2010-05-16 12:24:34 +00:00
|
|
|
FbDrawable(),
|
2003-04-17 14:16:20 +00:00
|
|
|
m_parent(&parent),
|
2004-12-21 16:12:28 +00:00
|
|
|
m_screen_num(parent.screenNumber()),
|
2010-05-16 12:24:34 +00:00
|
|
|
m_window(0),
|
|
|
|
m_x(0), m_y(0),
|
|
|
|
m_width(1), m_height(1),
|
2004-01-08 22:07:58 +00:00
|
|
|
m_destroy(true),
|
2005-04-27 17:57:40 +00:00
|
|
|
m_lastbg_color_set(false), m_lastbg_color(0),
|
2005-04-28 14:20:59 +00:00
|
|
|
m_lastbg_pm(0), m_renderer(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
|
|
|
|
|
|
|
|
2009-09-30 19:02:24 +00:00
|
|
|
}
|
2002-12-03 16:25:27 +00:00
|
|
|
|
2008-05-24 08:03:59 +00:00
|
|
|
FbWindow::FbWindow(Window client):
|
|
|
|
FbDrawable(),
|
|
|
|
m_parent(0), m_screen_num(0), m_window(0),
|
|
|
|
m_x(0), m_y(0), m_width(1), m_height(1),
|
|
|
|
m_border_width(0), m_border_color(0),
|
|
|
|
m_depth(0), m_destroy(false), // don't destroy this window
|
|
|
|
m_lastbg_color_set(false), m_lastbg_color(0), m_lastbg_pm(0),
|
|
|
|
m_renderer(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
|
2006-04-21 16:07:45 +00:00
|
|
|
if (m_transparent.get() != 0) {
|
|
|
|
removeAlphaWin(*this);
|
2004-09-11 15:52:23 +00:00
|
|
|
m_transparent.reset(0);
|
2006-04-21 16:07:45 +00:00
|
|
|
}
|
2004-09-11 15:52:23 +00:00
|
|
|
|
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
|
|
|
}
|
2006-04-21 16:07:45 +00:00
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::setBackgroundColor(const FbTk::Color &bg_color) {
|
2005-04-10 18:18:14 +00:00
|
|
|
if (bg_color.isAllocated()) {
|
|
|
|
m_lastbg_color = bg_color.pixel();
|
|
|
|
m_lastbg_color_set = true;
|
|
|
|
m_lastbg_pm = None;
|
|
|
|
} else {
|
|
|
|
m_lastbg_color_set = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateBackground(false);
|
2002-12-03 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::setBackgroundPixmap(Pixmap bg_pixmap) {
|
2005-04-10 18:18:14 +00:00
|
|
|
m_lastbg_pm = bg_pixmap;
|
|
|
|
if (bg_pixmap != None)
|
|
|
|
m_lastbg_color_set = false;
|
|
|
|
|
|
|
|
updateBackground(false);
|
|
|
|
}
|
|
|
|
|
2006-06-24 14:05:19 +00:00
|
|
|
void FbWindow::invalidateBackground() {
|
|
|
|
m_lastbg_pm = None;
|
|
|
|
m_lastbg_color_set = false;
|
|
|
|
}
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
void FbWindow::updateBackground(bool only_if_alpha) {
|
|
|
|
Pixmap newbg = m_lastbg_pm;
|
2011-02-22 21:07:39 +00:00
|
|
|
int alpha = 255;
|
2005-04-10 18:18:14 +00:00
|
|
|
bool free_newbg = false;
|
2005-04-28 14:20:59 +00:00
|
|
|
|
2005-04-27 17:57:40 +00:00
|
|
|
if (m_lastbg_pm == None && !m_lastbg_color_set)
|
|
|
|
return;
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
if (m_transparent.get() != 0)
|
|
|
|
alpha = m_transparent->alpha();
|
|
|
|
|
|
|
|
if (only_if_alpha && alpha == 255)
|
|
|
|
return;
|
|
|
|
|
2005-05-07 12:59:43 +00:00
|
|
|
// still use bg buffer pixmap if not transparent
|
|
|
|
// cause it does nice caching things, assuming we have a renderer
|
|
|
|
if (m_lastbg_pm != ParentRelative && (m_renderer || alpha != 255)) {
|
2005-04-10 18:18:14 +00:00
|
|
|
// update source and destination if needed
|
|
|
|
Pixmap root = FbPixmap::getRootPixmap(screenNumber());
|
2005-04-26 11:37:29 +00:00
|
|
|
if (alpha != 255 && m_transparent->source() != root)
|
2005-04-10 18:18:14 +00:00
|
|
|
m_transparent->setSource(root, screenNumber());
|
|
|
|
|
2005-04-26 01:41:55 +00:00
|
|
|
FbPixmap newpm = FbPixmap(*this, width(), height(), depth());
|
|
|
|
free_newbg = true; // newpm gets released to newbg at end of block
|
2005-04-10 18:18:14 +00:00
|
|
|
GC gc = XCreateGC(display(), window(), 0, 0);
|
|
|
|
|
|
|
|
if (m_lastbg_pm == None && m_lastbg_color_set) {
|
|
|
|
XSetForeground(display(), gc, m_lastbg_color);
|
2005-04-26 01:41:55 +00:00
|
|
|
newpm.fillRectangle(gc, 0, 0, width(), height());
|
2005-04-10 18:18:14 +00:00
|
|
|
} else {
|
|
|
|
// copy from window if no color and no bg...
|
2005-04-26 01:41:55 +00:00
|
|
|
newpm.copyArea((m_lastbg_pm == None)?drawable():m_lastbg_pm, gc, 0, 0, 0, 0, width(), height());
|
2005-04-10 18:18:14 +00:00
|
|
|
}
|
|
|
|
XFreeGC(display(), gc);
|
2005-04-26 11:37:29 +00:00
|
|
|
|
|
|
|
if (alpha != 255)
|
|
|
|
m_transparent->setDest(newpm.drawable(), screenNumber());
|
2005-04-10 18:18:14 +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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// render background image from root pos to our window
|
2005-04-26 11:37:29 +00:00
|
|
|
if (alpha != 255)
|
|
|
|
m_transparent->render(root_x, root_y,
|
|
|
|
0, 0,
|
|
|
|
width(), height());
|
2005-04-26 01:41:55 +00:00
|
|
|
|
|
|
|
// render any foreground items
|
|
|
|
if (m_renderer)
|
|
|
|
m_renderer->renderForeground(*this, newpm);
|
|
|
|
|
2005-04-26 11:37:29 +00:00
|
|
|
if (alpha != 255)
|
|
|
|
m_transparent->freeDest(); // it's only temporary, don't leave it hanging around
|
2005-04-26 01:41:55 +00:00
|
|
|
newbg = newpm.release();
|
2005-04-10 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (newbg != None)
|
|
|
|
XSetWindowBackgroundPixmap(display(), m_window, newbg);
|
|
|
|
else if (m_lastbg_color_set)
|
|
|
|
XSetWindowBackground(display(), m_window, m_lastbg_color);
|
|
|
|
|
|
|
|
if (free_newbg)
|
|
|
|
XFreePixmap(display(), newbg);
|
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());
|
2008-05-24 08:03:59 +00:00
|
|
|
m_border_color = 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);
|
2006-05-22 15:09:21 +00:00
|
|
|
if (m_lastbg_pm == ParentRelative && m_renderer)
|
|
|
|
m_renderer->renderForeground(*this, *this);
|
|
|
|
|
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) {
|
2005-04-26 01:41:55 +00:00
|
|
|
// TODO: probably could call renderForeground here (with x,y,w,h)
|
2006-05-22 15:09:21 +00:00
|
|
|
if (m_lastbg_pm == ParentRelative && m_renderer)
|
|
|
|
FbWindow::clear();
|
|
|
|
else
|
|
|
|
XClearArea(display(), window(), x, y, width, height, exposures);
|
2003-06-24 10:12:57 +00:00
|
|
|
}
|
|
|
|
|
2005-04-26 01:41:55 +00:00
|
|
|
// If override_is_offset, then dest_override is a pixmap located at the_x, the_y
|
|
|
|
// with size the_width x the_height in the target window.
|
|
|
|
|
|
|
|
void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, unsigned int the_height, Pixmap dest_override, bool override_is_offset) {
|
2003-08-04 12:44:43 +00:00
|
|
|
#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;
|
|
|
|
|
2008-08-16 12:54:07 +00:00
|
|
|
if (!dest_override && ((the_width == 0 && the_height == 0) ||
|
|
|
|
(the_width == width() && the_height == height())) &&
|
2005-04-10 18:18:14 +00:00
|
|
|
the_x <= 0 && the_y <= 0) {
|
|
|
|
// do the whole thing
|
|
|
|
updateBackground(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-26 01:41:55 +00:00
|
|
|
if (!dest_override)
|
|
|
|
dest_override = window();
|
|
|
|
|
2003-08-04 12:44:43 +00:00
|
|
|
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());
|
|
|
|
|
2005-04-26 01:41:55 +00:00
|
|
|
if (m_transparent->dest() != dest_override)
|
|
|
|
m_transparent->setDest(dest_override, screenNumber());
|
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,
|
2005-04-26 01:41:55 +00:00
|
|
|
override_is_offset?0:the_x, override_is_offset?0:the_y,
|
2003-08-04 12:44:43 +00:00
|
|
|
the_width, the_height);
|
|
|
|
#endif // HAVE_XRENDER
|
|
|
|
}
|
|
|
|
|
2011-02-22 21:07:39 +00:00
|
|
|
void FbWindow::setAlpha(int alpha) {
|
2003-08-04 12:44:43 +00:00
|
|
|
#ifdef HAVE_XRENDER
|
2004-09-12 14:56:20 +00:00
|
|
|
if (FbTk::Transparent::haveComposite()) {
|
2006-04-21 16:07:45 +00:00
|
|
|
if (m_transparent.get() != 0) {
|
|
|
|
removeAlphaWin(*this);
|
2004-09-12 14:56:20 +00:00
|
|
|
m_transparent.reset(0);
|
2006-04-21 16:07:45 +00:00
|
|
|
}
|
2004-09-12 14:56:20 +00:00
|
|
|
|
|
|
|
// don't setOpaque, let controlling objects do that
|
|
|
|
// since it's only needed on toplevel windows
|
2005-04-26 11:37:29 +00:00
|
|
|
} else {
|
|
|
|
if (!FbTk::Transparent::haveRender())
|
|
|
|
alpha = 255;
|
|
|
|
|
|
|
|
if (m_transparent.get() == 0 && alpha < 255) {
|
|
|
|
m_transparent.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), window(), alpha, screenNumber()));
|
2006-04-21 16:07:45 +00:00
|
|
|
addAlphaWin(*this);
|
2005-04-26 11:37:29 +00:00
|
|
|
} else if (alpha < 255 && alpha != m_transparent->alpha())
|
|
|
|
m_transparent->setAlpha(alpha);
|
2006-04-21 16:07:45 +00:00
|
|
|
else if (alpha == 255) {
|
|
|
|
removeAlphaWin(*this);
|
2005-04-26 11:37:29 +00:00
|
|
|
m_transparent.reset(0); // destroy transparent object
|
2006-04-21 16:07:45 +00:00
|
|
|
}
|
2005-04-26 11:37:29 +00:00
|
|
|
}
|
2003-08-04 12:44:43 +00:00
|
|
|
#endif // HAVE_XRENDER
|
|
|
|
}
|
|
|
|
|
2011-02-22 21:07:39 +00:00
|
|
|
int FbWindow::alpha() const {
|
2004-06-07 20:24:38 +00:00
|
|
|
#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();
|
2008-05-24 08:03:59 +00:00
|
|
|
m_border_color = win.borderColor();
|
2003-08-04 12:44:43 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2010-09-10 14:36:17 +00:00
|
|
|
|
|
|
|
namespace {
|
2007-05-19 11:42:44 +00:00
|
|
|
struct TextPropPtr {
|
|
|
|
TextPropPtr(XTextProperty& prop):m_prop(prop) {}
|
|
|
|
~TextPropPtr() {
|
|
|
|
if (m_prop.value != 0) {
|
|
|
|
XFree(m_prop.value);
|
|
|
|
m_prop.value = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XTextProperty& m_prop;
|
|
|
|
};
|
2010-09-10 14:36:17 +00:00
|
|
|
}
|
|
|
|
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
long FbWindow::cardinalProperty(Atom prop,bool*exists) const {
|
|
|
|
Atom type;
|
|
|
|
int format;
|
|
|
|
unsigned long nitems, bytes_after;
|
|
|
|
int result;
|
|
|
|
long* num;
|
|
|
|
long ret=0;
|
|
|
|
if (exists) *exists=false;
|
|
|
|
if (property(prop, 0, 1, False, XA_CARDINAL, &type, &format, &nitems, &bytes_after, reinterpret_cast<unsigned char**>(&num))) {
|
|
|
|
if (type == XA_CARDINAL && nitems) {
|
|
|
|
ret = *num;
|
|
|
|
if (exists) *exists=true;
|
|
|
|
}
|
|
|
|
XFree(num);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
FbTk::FbString FbWindow::textProperty(Atom prop,bool*exists) const {
|
2004-04-28 13:04:06 +00:00
|
|
|
XTextProperty text_prop;
|
2007-05-19 11:42:44 +00:00
|
|
|
TextPropPtr helper(text_prop);
|
2006-05-07 10:08:25 +00:00
|
|
|
char ** stringlist = 0;
|
2007-05-05 22:21:35 +00:00
|
|
|
int count = 0;
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
FbTk::FbString ret;
|
2004-04-28 13:04:06 +00:00
|
|
|
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
static const Atom utf8string = XInternAtom(display(), "UTF8_STRING", False);
|
2006-05-07 10:08:25 +00:00
|
|
|
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
if (exists) *exists=false;
|
|
|
|
if (XGetTextProperty(display(), window(), &text_prop, prop) == 0 || text_prop.value == 0 || text_prop.nitems == 0) {
|
2004-04-28 13:04:06 +00:00
|
|
|
return "";
|
2007-05-19 11:42:44 +00:00
|
|
|
}
|
2004-04-28 13:04:06 +00:00
|
|
|
|
|
|
|
|
2006-05-07 10:08:25 +00:00
|
|
|
if (text_prop.encoding == XA_STRING) {
|
2007-05-19 11:42:44 +00:00
|
|
|
if (XTextPropertyToStringList(&text_prop, &stringlist, &count) == 0 || count == 0) {
|
2004-04-28 13:04:06 +00:00
|
|
|
return "";
|
2007-05-19 11:42:44 +00:00
|
|
|
}
|
2006-05-07 10:08:25 +00:00
|
|
|
ret = FbStringUtil::XStrToFb(stringlist[0]);
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
} else if (text_prop.encoding == utf8string && text_prop.format == 8) {
|
2006-05-07 10:08:25 +00:00
|
|
|
#ifdef X_HAVE_UTF8_STRING
|
|
|
|
Xutf8TextPropertyToTextList(display(), &text_prop, &stringlist, &count);
|
2007-05-19 11:42:44 +00:00
|
|
|
if (count == 0 || stringlist == 0) {
|
2006-05-07 10:08:25 +00:00
|
|
|
return "";
|
2007-05-19 11:42:44 +00:00
|
|
|
}
|
2006-05-07 10:08:25 +00:00
|
|
|
#else
|
2007-05-19 11:42:44 +00:00
|
|
|
if (XTextPropertyToStringList(&text_prop, &stringlist, &count) == 0 || count == 0 || stringlist == 0) {
|
2004-04-28 13:04:06 +00:00
|
|
|
return "";
|
2007-05-19 11:42:44 +00:00
|
|
|
}
|
2006-05-07 10:08:25 +00:00
|
|
|
#endif
|
|
|
|
ret = stringlist[0];
|
|
|
|
} else {
|
|
|
|
// still returns a "StringList" despite the different name
|
2007-05-05 22:21:35 +00:00
|
|
|
XmbTextPropertyToTextList(display(), &text_prop, &stringlist, &count);
|
2007-05-19 11:42:44 +00:00
|
|
|
if (count == 0 || stringlist == 0) {
|
2006-05-07 10:08:25 +00:00
|
|
|
return "";
|
2007-05-19 11:42:44 +00:00
|
|
|
}
|
2006-05-07 10:08:25 +00:00
|
|
|
ret = FbStringUtil::LocaleStrToFb(stringlist[0]);
|
2004-04-28 13:04:06 +00:00
|
|
|
}
|
|
|
|
|
2006-05-07 10:08:25 +00:00
|
|
|
// they all use stringlist
|
2007-05-19 11:42:44 +00:00
|
|
|
if (stringlist) {
|
2006-05-07 10:08:25 +00:00
|
|
|
XFreeStringList(stringlist);
|
2007-05-19 11:42:44 +00:00
|
|
|
}
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
if (exists) *exists=true;
|
2004-04-28 13:04:06 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
bool FbWindow::property(Atom prop,
|
2003-05-19 22:38:55 +00:00
|
|
|
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(),
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
prop, 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
|
|
|
}
|
|
|
|
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
void FbWindow::changeProperty(Atom prop, Atom type,
|
2003-05-19 22:38:55 +00:00
|
|
|
int format,
|
|
|
|
int mode,
|
|
|
|
unsigned char *data,
|
|
|
|
int nelements) {
|
2004-12-21 16:12:28 +00:00
|
|
|
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
XChangeProperty(display(), m_window, prop, type,
|
2004-12-21 16:12:28 +00:00
|
|
|
format, mode,
|
2003-05-19 22:38:55 +00:00
|
|
|
data, nelements);
|
|
|
|
}
|
|
|
|
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
void FbWindow::deleteProperty(Atom prop) {
|
|
|
|
XDeleteProperty(display(), m_window, prop);
|
2004-12-21 16:12:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-04 17:14:13 +00:00
|
|
|
void FbWindow::addToSaveSet() {
|
|
|
|
XAddToSaveSet(display(), m_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::removeFromSaveSet() {
|
|
|
|
XRemoveFromSaveSet(display(), m_window);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-02-22 21:07:39 +00:00
|
|
|
void FbWindow::setOpaque(int alpha) {
|
2004-09-12 14:56:20 +00:00
|
|
|
#ifdef HAVE_XRENDER
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
static const Atom alphaatom = XInternAtom(display(), "_NET_WM_WINDOW_OPACITY", False);
|
2007-01-08 21:12:47 +00:00
|
|
|
unsigned long opacity = alpha * 0x1010101;
|
Can check CARDINAL properties in CLIENT PATTERNS
Introduces a new member function, FbWindow::cardinalProperty()
This change also changes other code that previously used
FbWindow::property() to do the same thing as the new function; this
reduces code duplication.
There are still some bits of code (Ewmh.cc, extractNetWmIcon()) that use
FbWindow::property() to retrieve XA_CARDINAL values, but as the new
method is designed for getting a _single_ property, and that code uses
FbWindow::property() to retrieve the number of values present, and then
grab all of them; it's a different use case. I opted to not try to make
cardinalProperty() into some monolithic all-purpose cardinal method;
FbWindow::property() works just fine for that.
This change also adds an optional (default=NULL) boolean to
FbWindow::textProperty and friends that allows the caller to determine
whether or not a value was actually retrieved. This was necessary for
integrating FbWindow::cardinalProperty with the codebase, and it seemed
to fit with FbWindow::textProperty as well. Prior to this change, if
you got a return value of "", you wouldn't know if you successfully
retrieved the value which happened to be blank, or if you failed to
retrieve the value. Now, you can pass the address of a boolean if you
so choose in order to differentiate these situations; the same applies
to the new FbWindow::cardinalProperty().
2011-05-08 02:38:13 +00:00
|
|
|
changeProperty(alphaatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1l);
|
2004-09-12 14:56:20 +00:00
|
|
|
#endif // HAVE_XRENDER
|
|
|
|
}
|
|
|
|
|
2008-10-15 02:40:33 +00:00
|
|
|
bool FbWindow::updateGeometry() {
|
2002-12-03 16:25:27 +00:00
|
|
|
if (m_window == 0)
|
2008-10-15 02:40:33 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
int old_x = m_x, old_y = m_y;
|
|
|
|
unsigned int old_width = m_width, old_height = m_height;
|
2002-12-03 16:25:27 +00:00
|
|
|
|
|
|
|
Window root;
|
2003-02-23 16:52:17 +00:00
|
|
|
unsigned int border_width, depth;
|
2007-07-03 21:08:07 +00:00
|
|
|
if (XGetGeometry(display(), m_window, &root, &m_x, &m_y,
|
2008-10-15 02:40:33 +00:00
|
|
|
&m_width, &m_height, &border_width, &depth))
|
2007-07-03 21:08:07 +00:00
|
|
|
m_depth = depth;
|
2008-10-15 02:40:33 +00:00
|
|
|
|
|
|
|
return (old_x != m_x || old_y != m_y || old_width != m_width ||
|
|
|
|
old_height != m_height);
|
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,
|
2007-12-25 05:15:17 +00:00
|
|
|
bool save_unders, unsigned 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;
|
2008-05-24 08:03:59 +00:00
|
|
|
m_border_color = 0;
|
2003-01-05 22:58:11 +00:00
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2005-04-26 04:18:10 +00:00
|
|
|
|
|
|
|
void FbWindow::sendConfigureNotify(int x, int y,
|
2008-01-02 03:10:38 +00:00
|
|
|
unsigned int width, unsigned int height,
|
|
|
|
unsigned int bw) {
|
2005-04-26 04:18:10 +00:00
|
|
|
Display *disp = FbTk::App::instance()->display();
|
|
|
|
XEvent event;
|
|
|
|
event.type = ConfigureNotify;
|
|
|
|
|
|
|
|
event.xconfigure.display = disp;
|
|
|
|
event.xconfigure.event = window();
|
|
|
|
event.xconfigure.window = window();
|
|
|
|
event.xconfigure.x = x;
|
|
|
|
event.xconfigure.y = y;
|
|
|
|
event.xconfigure.width = width;
|
|
|
|
event.xconfigure.height = height;
|
2008-01-02 03:10:38 +00:00
|
|
|
event.xconfigure.border_width = bw;
|
2005-04-26 04:18:10 +00:00
|
|
|
event.xconfigure.above = None;
|
|
|
|
event.xconfigure.override_redirect = false;
|
|
|
|
|
|
|
|
XSendEvent(disp, window(), False, StructureNotifyMask, &event);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-04-21 16:07:45 +00:00
|
|
|
FbWindow::FbWinList FbWindow::m_alpha_wins;
|
|
|
|
|
|
|
|
void FbWindow::addAlphaWin(FbWindow &win) {
|
|
|
|
m_alpha_wins.insert(&win);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::removeAlphaWin(FbWindow &win) {
|
|
|
|
FbWinList::iterator it = m_alpha_wins.find(&win);
|
|
|
|
if (it != m_alpha_wins.end())
|
|
|
|
m_alpha_wins.erase(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWindow::updatedAlphaBackground(int screen) {
|
|
|
|
FbWinList::iterator it = m_alpha_wins.begin();
|
|
|
|
FbWinList::iterator it_end = m_alpha_wins.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if ((*it)->screenNumber() == screen) {
|
|
|
|
(*it)->updateBackground(false);
|
|
|
|
(*it)->clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-03 16:25:27 +00:00
|
|
|
bool operator == (Window win, const FbWindow &fbwin) {
|
|
|
|
return win == fbwin.window();
|
|
|
|
}
|
|
|
|
|
2009-09-30 19:02:24 +00:00
|
|
|
}
|