2002-11-17 09:41:58 +00:00
|
|
|
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2002-11-16 14:30:18 +00:00
|
|
|
#include "appwidget.hh"
|
|
|
|
#include "application.hh"
|
2003-01-16 08:47:21 +00:00
|
|
|
#include "property.hh"
|
2002-11-16 14:30:18 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace otk {
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
AppWidget::AppWidget(Application *app, Direction direction,
|
2003-01-22 22:46:16 +00:00
|
|
|
Cursor cursor, int bevel_width)
|
2003-01-11 19:17:13 +00:00
|
|
|
: Widget(app, app->getStyle(), direction, cursor, bevel_width),
|
2002-11-16 14:30:18 +00:00
|
|
|
_application(app)
|
|
|
|
{
|
|
|
|
assert(app);
|
|
|
|
|
|
|
|
// set WM Protocols on the window
|
|
|
|
Atom protocols[2];
|
2003-01-18 00:09:05 +00:00
|
|
|
protocols[0] = Property::atoms.wm_protocols;
|
|
|
|
protocols[1] = Property::atoms.wm_delete_window;
|
2003-01-13 08:48:03 +00:00
|
|
|
XSetWMProtocols(**display, window(), protocols, 2);
|
2002-11-16 14:30:18 +00:00
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
AppWidget::~AppWidget()
|
2002-11-16 14:30:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
void AppWidget::show(void)
|
2002-11-16 14:30:18 +00:00
|
|
|
{
|
2003-01-11 19:17:13 +00:00
|
|
|
Widget::show(true);
|
2002-11-16 14:30:18 +00:00
|
|
|
|
|
|
|
_application->_appwidget_count++;
|
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
void AppWidget::hide(void)
|
2002-11-16 14:30:18 +00:00
|
|
|
{
|
2003-01-11 19:17:13 +00:00
|
|
|
Widget::hide();
|
2002-11-16 14:30:18 +00:00
|
|
|
|
|
|
|
_application->_appwidget_count--;
|
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
void AppWidget::clientMessageHandler(const XClientMessageEvent &e)
|
2002-11-16 14:30:18 +00:00
|
|
|
{
|
2003-01-11 19:17:13 +00:00
|
|
|
EventHandler::clientMessageHandler(e);
|
2003-01-18 00:09:05 +00:00
|
|
|
if (e.message_type == Property::atoms.wm_protocols &&
|
|
|
|
static_cast<Atom>(e.data.l[0]) == Property::atoms.wm_delete_window)
|
2002-11-16 14:30:18 +00:00
|
|
|
hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|