Toplevel::frameId() becomes virtual

The frameId only makes sense for a Client, in case of Unmanaged the
same window id is used as for the window() handle. Client creates the
frame and destroys it.

Given that it makes sense to let Client manage the frame properly.
The ::frameId() is therefore virtual and as base implementation it
returns the client id. Client reimplements it and returns the proper
frame id.

Method is also implemented in Deleted as it used to be passed to
deleted.
icc-effect-5.14.5
Martin Gräßlin 2013-09-10 08:13:33 +02:00
parent 4e5a44e23c
commit cfd93246b3
8 changed files with 30 additions and 17 deletions

View File

@ -88,6 +88,7 @@ Client::Client()
: Toplevel()
, m_client()
, m_wrapper()
, m_frame()
, decoration(NULL)
, bridge(new Bridge(this))
, m_activityUpdatesBlocked(false)
@ -299,7 +300,7 @@ void Client::releaseWindow(bool on_shutdown)
m_client.unmap();
m_client.reset();
m_wrapper.reset();
XDestroyWindow(display(), frameId());
m_frame.reset();
//frame = None;
--block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry
if (!on_shutdown) {
@ -340,7 +341,7 @@ void Client::destroyClient()
workspace()->removeClient(this);
m_client.reset(); // invalidate
m_wrapper.reset();
XDestroyWindow(display(), frameId());
m_frame.reset();
//frame = None;
--block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry
disownDataPassedToDeleted();
@ -2500,6 +2501,11 @@ void Client::cancelFocusOutTimer()
}
}
xcb_window_t Client::frameId() const
{
return m_frame;
}
} // namespace
#include "client.moc"

View File

@ -270,6 +270,7 @@ public:
xcb_window_t wrapperId() const;
xcb_window_t decorationId() const;
xcb_window_t inputId() const { return m_decoInputExtent; }
virtual xcb_window_t frameId() const override;
const Client* transientFor() const;
Client* transientFor();
@ -831,6 +832,7 @@ private:
Xcb::Window m_client;
Xcb::Window m_wrapper;
Xcb::Window m_frame;
KDecoration* decoration;
Bridge* bridge;
int desk;

View File

@ -34,6 +34,7 @@ namespace KWin
Deleted::Deleted()
: Toplevel()
, delete_refcount(1)
, m_frame(XCB_WINDOW_NONE)
, no_border(true)
, padding_left(0)
, padding_top(0)
@ -80,6 +81,7 @@ void Deleted::copyToDeleted(Toplevel* c)
contentsRect = QRect(c->clientPos(), c->clientSize());
transparent_rect = c->transparentRect();
m_layer = c->layer();
m_frame = c->frameId();
if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info))
cinfo->disable();
Client* client = dynamic_cast<Client*>(c);
@ -185,6 +187,11 @@ void Deleted::mainClientClosed(Toplevel *client)
m_mainClients.removeAll(static_cast<Client*>(client));
}
xcb_window_t Deleted::frameId() const
{
return m_frame;
}
} // namespace
#include "deleted.moc"

View File

@ -45,6 +45,7 @@ public:
virtual QSize clientSize() const;
virtual QRect transparentRect() const;
virtual bool isDeleted() const;
virtual xcb_window_t frameId() const override;
bool noBorder() const {
return no_border;
}
@ -84,6 +85,7 @@ private:
QStringList activityList;
QRect contentsRect; // for clientPos()/clientSize()
QRect transparent_rect;
xcb_window_t m_frame;
bool no_border;
QRect decoration_left;

View File

@ -677,8 +677,9 @@ void Client::embedClient(xcb_window_t w, const XWindowAttributes& attr)
xcb_window_t frame = xcb_generate_id(conn);
xcb_create_window(conn, attr.depth, frame, rootWindow(), 0, 0, 1, 1, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, visualid, cw_mask, cw_values);
m_frame.reset(frame);
setWindowHandles(m_client, frame);
setWindowHandles(m_client);
// Create the wrapper window
xcb_window_t wrapperId = xcb_generate_id(conn);

View File

@ -42,7 +42,6 @@ Toplevel::Toplevel()
, ready_for_painting(true)
, m_isDamaged(false)
, m_client()
, frame(None)
, damage_handle(None)
, is_shape(false)
, effect_window(NULL)
@ -111,7 +110,6 @@ void Toplevel::copyToDeleted(Toplevel* c)
bit_depth = c->bit_depth;
info = c->info;
m_client.reset(c->m_client, false);
frame = c->frame;
ready_for_painting = c->ready_for_painting;
damage_handle = None;
damage_region = c->damage_region;
@ -461,6 +459,11 @@ pid_t Toplevel::pid() const
return info->pid();
}
xcb_window_t Toplevel::frameId() const
{
return m_client;
}
} // namespace
#include "toplevel.moc"

View File

@ -166,7 +166,7 @@ class Toplevel
Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged)
public:
explicit Toplevel();
Window frameId() const;
virtual xcb_window_t frameId() const;
xcb_window_t window() const;
QRect geometry() const;
QSize size() const;
@ -347,7 +347,7 @@ protected Q_SLOTS:
protected:
virtual ~Toplevel();
void setWindowHandles(xcb_window_t client, xcb_window_t frame);
void setWindowHandles(xcb_window_t client);
void detectShape(Window id);
virtual void propertyNotifyEvent(xcb_property_notify_event_t *e);
virtual void damageNotifyEvent();
@ -391,7 +391,6 @@ private:
static xcb_window_t staticWmClientLeader(xcb_window_t);
// when adding new data members, check also copyToDeleted()
Xcb::Window m_client;
Window frame;
xcb_damage_damage_t damage_handle;
QRegion damage_region; // damage is really damaged window (XDamage) and texture needs
bool is_shape;
@ -415,17 +414,10 @@ inline xcb_window_t Toplevel::window() const
return m_client;
}
inline Window Toplevel::frameId() const
{
return frame;
}
inline void Toplevel::setWindowHandles(xcb_window_t w, xcb_window_t f)
inline void Toplevel::setWindowHandles(xcb_window_t w)
{
assert(!m_client.isValid() && w != XCB_WINDOW_NONE);
m_client.reset(w, false);
assert(frame == None && f != None);
frame = f;
}
inline QRect Toplevel::geometry() const

View File

@ -57,7 +57,7 @@ bool Unmanaged::track(Window w)
ungrabXServer();
return false;
}
setWindowHandles(w, w); // the window is also the frame
setWindowHandles(w); // the window is also the frame
Xcb::selectInput(w, attr.your_event_mask | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE);
geom = QRect(attr.x, attr.y, attr.width, attr.height);
checkScreen();