2002-01-09 14:11:20 +00:00
|
|
|
// Window.cc for Fluxbox Window Manager
|
2003-01-05 22:22:33 +00:00
|
|
|
// Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
2002-01-09 14:11:20 +00:00
|
|
|
//
|
2001-12-11 20:47:02 +00:00
|
|
|
// Window.cc for Blackbox - an X11 Window manager
|
2003-01-05 22:22:33 +00:00
|
|
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
|
2001-12-11 20:47:02 +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,
|
2003-01-05 22:22:33 +00:00
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
2001-12-11 20:47:02 +00:00
|
|
|
// 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.
|
|
|
|
|
2003-02-17 09:56:00 +00:00
|
|
|
// $Id: Window.cc,v 1.118 2003/02/17 09:56:00 fluxgen Exp $
|
2002-04-04 22:39:52 +00:00
|
|
|
|
|
|
|
#include "Window.hh"
|
2002-01-09 14:11:20 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
#include "i18n.hh"
|
|
|
|
#include "fluxbox.hh"
|
|
|
|
#include "Screen.hh"
|
2002-01-06 11:07:42 +00:00
|
|
|
#include "StringUtil.hh"
|
2002-11-17 11:29:06 +00:00
|
|
|
#include "Netizen.hh"
|
2003-01-05 22:22:33 +00:00
|
|
|
#include "FbWinFrameTheme.hh"
|
2003-01-07 01:34:49 +00:00
|
|
|
#include "MenuTheme.hh"
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-10-13 21:54:36 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
2002-08-11 22:44:29 +00:00
|
|
|
//use GNU extensions
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif // _GNU_SOURCE
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-11 22:44:29 +00:00
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-11 22:44:29 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <cstdio>
|
2002-01-05 10:58:48 +00:00
|
|
|
#include <iostream>
|
2002-08-11 22:44:29 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
using namespace std;
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void grabButton(Display *display, unsigned int button,
|
|
|
|
Window window, Cursor cursor) {
|
|
|
|
|
|
|
|
//numlock
|
|
|
|
XGrabButton(display, button, Mod1Mask|Mod2Mask, window, True,
|
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
|
|
|
GrabModeAsync, None, cursor);
|
|
|
|
//scrolllock
|
|
|
|
XGrabButton(display, button, Mod1Mask|Mod5Mask, window, True,
|
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
|
|
|
GrabModeAsync, None, cursor);
|
|
|
|
|
|
|
|
//capslock
|
|
|
|
XGrabButton(display, button, Mod1Mask|LockMask, window, True,
|
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
|
|
|
GrabModeAsync, None, cursor);
|
|
|
|
|
|
|
|
//capslock+numlock
|
|
|
|
XGrabButton(display, Button1, Mod1Mask|LockMask|Mod2Mask, window, True,
|
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
|
|
|
GrabModeAsync, None, cursor);
|
|
|
|
|
|
|
|
//capslock+scrolllock
|
|
|
|
XGrabButton(display, button, Mod1Mask|LockMask|Mod5Mask, window, True,
|
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
|
|
|
GrabModeAsync, None, cursor);
|
|
|
|
|
|
|
|
//capslock+numlock+scrolllock
|
|
|
|
XGrabButton(display, button, Mod1Mask|LockMask|Mod2Mask|Mod5Mask, window, True,
|
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
|
|
|
GrabModeAsync, None, cursor);
|
|
|
|
|
|
|
|
//numlock+scrollLock
|
|
|
|
XGrabButton(display, button, Mod1Mask|Mod2Mask|Mod5Mask, window, True,
|
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
|
|
|
GrabModeAsync, None, cursor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2003-02-03 13:56:12 +00:00
|
|
|
FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num,
|
|
|
|
FbTk::ImageControl &imgctrl, FbWinFrameTheme &tm,
|
|
|
|
FbTk::MenuTheme &menutheme,
|
|
|
|
FbTk::XLayer &layer):
|
2002-12-01 13:42:15 +00:00
|
|
|
m_hintsig(*this),
|
|
|
|
m_statesig(*this),
|
2003-02-02 16:32:41 +00:00
|
|
|
m_layersig(*this),
|
2002-12-01 13:42:15 +00:00
|
|
|
m_workspacesig(*this),
|
2003-01-05 22:22:33 +00:00
|
|
|
m_diesig(*this),
|
2002-12-01 13:42:15 +00:00
|
|
|
moving(false), resizing(false), shaded(false), maximized(false),
|
|
|
|
visible(false), iconic(false), transient(false), focused(false),
|
2003-01-05 22:22:33 +00:00
|
|
|
stuck(false), modal(false), send_focus_message(false), m_managed(false),
|
|
|
|
screen(s),
|
2002-12-01 13:42:15 +00:00
|
|
|
timer(this),
|
|
|
|
display(0),
|
|
|
|
lastButtonPressTime(0),
|
2003-01-07 01:34:49 +00:00
|
|
|
m_windowmenu(menutheme, screen_num, imgctrl),
|
2003-02-16 15:12:08 +00:00
|
|
|
m_layermenu(menutheme, screen_num, imgctrl),
|
2003-02-02 16:32:41 +00:00
|
|
|
old_decoration(DECOR_NORMAL),
|
2003-01-05 22:22:33 +00:00
|
|
|
tab(0),
|
2003-02-09 14:11:14 +00:00
|
|
|
m_frame(tm, imgctrl, screen_num, 0, 0, 100, 100),
|
|
|
|
m_layeritem(getFrameWindow(), layer),
|
|
|
|
m_layernum(layer.getLayerNum())
|
|
|
|
{
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2003-02-03 13:56:12 +00:00
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// redirect events from frame to us
|
|
|
|
m_frame.setEventHandler(*this);
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
lastFocusTime.tv_sec = lastFocusTime.tv_usec = 0;
|
2002-04-04 11:28:19 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// display connection
|
|
|
|
display = FbTk::App::instance()->display();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
blackbox_attrib.workspace = workspace_number = window_number = -1;
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack = 0;
|
2002-12-01 13:42:15 +00:00
|
|
|
blackbox_attrib.premax_x = blackbox_attrib.premax_y = 0;
|
|
|
|
blackbox_attrib.premax_w = blackbox_attrib.premax_h = 0;
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
//use tab as default
|
|
|
|
decorations.tab = true;
|
2003-01-05 22:22:33 +00:00
|
|
|
// enable decorations
|
2002-12-01 13:42:15 +00:00
|
|
|
decorations.enabled = true;
|
2003-01-05 22:22:33 +00:00
|
|
|
// set client window
|
2002-12-01 13:42:15 +00:00
|
|
|
client.window = w;
|
2003-01-05 22:22:33 +00:00
|
|
|
|
|
|
|
// set default values for decoration
|
2002-12-01 13:42:15 +00:00
|
|
|
decorations.menu = true; //override menu option
|
2003-01-05 22:22:33 +00:00
|
|
|
// all decorations on by default
|
2002-12-01 13:42:15 +00:00
|
|
|
decorations.titlebar = decorations.border = decorations.handle = true;
|
2003-01-05 22:22:33 +00:00
|
|
|
decorations.maximize = decorations.close = decorations.sticky = decorations.shade =
|
|
|
|
decorations.tab = true;
|
|
|
|
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
functions.resize = functions.move = functions.iconify = functions.maximize = true;
|
|
|
|
functions.close = decorations.close = false;
|
|
|
|
|
|
|
|
client.wm_hint_flags = client.normal_hint_flags = 0;
|
|
|
|
client.transient_for = 0;
|
2003-01-05 22:22:33 +00:00
|
|
|
client.mwm_hint = 0;
|
2002-12-01 13:42:15 +00:00
|
|
|
client.blackbox_hint = 0;
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
getBlackboxHints();
|
2003-02-02 16:32:41 +00:00
|
|
|
if (! client.blackbox_hint) {
|
2003-01-05 22:22:33 +00:00
|
|
|
getMWMHints();
|
2003-02-02 16:32:41 +00:00
|
|
|
}
|
2003-01-05 22:22:33 +00:00
|
|
|
|
|
|
|
// get size, aspect, minimum/maximum size and other hints set
|
|
|
|
// by the client
|
2003-02-02 16:32:41 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
getWMProtocols();
|
|
|
|
getWMHints();
|
|
|
|
getWMNormalHints();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
// fetch client size and placement
|
|
|
|
XWindowAttributes wattrib;
|
|
|
|
if ((! XGetWindowAttributes(display, client.window, &wattrib)) ||
|
2003-01-05 22:22:33 +00:00
|
|
|
!wattrib.screen // no screen?
|
|
|
|
|| wattrib.override_redirect) { // override redirect
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// save old border width so we can restore it later
|
|
|
|
client.old_bw = wattrib.border_width;
|
|
|
|
client.x = wattrib.x; client.y = wattrib.y;
|
2002-12-01 13:42:15 +00:00
|
|
|
client.width = wattrib.width;
|
|
|
|
client.height = wattrib.height;
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.move(wattrib.x, wattrib.y);
|
|
|
|
m_frame.resizeForClient(wattrib.width, wattrib.height);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-02-09 14:11:14 +00:00
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
timer.setTimeout(fluxbox->getAutoRaiseDelay());
|
|
|
|
timer.fireOnce(true);
|
|
|
|
|
|
|
|
if (client.initial_state == WithdrawnState) {
|
|
|
|
return;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
m_managed = true; //this window is managed
|
|
|
|
|
|
|
|
// update transient infomation
|
|
|
|
updateTransientInfo();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
// adjust the window decorations based on transience and window sizes
|
|
|
|
if (transient) {
|
|
|
|
decorations.maximize = functions.maximize = false;
|
|
|
|
decorations.handle = decorations.border = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((client.normal_hint_flags & PMinSize) &&
|
|
|
|
(client.normal_hint_flags & PMaxSize) &&
|
|
|
|
client.max_width != 0 && client.max_width <= client.min_width &&
|
|
|
|
client.max_height != 0 && client.max_height <= client.min_height) {
|
|
|
|
decorations.maximize = decorations.handle =
|
|
|
|
functions.resize = functions.maximize = false;
|
|
|
|
decorations.tab = false; //no tab for this window
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
upsize();
|
2003-02-02 16:32:41 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
bool place_window = true;
|
|
|
|
if (fluxbox->isStartup() || transient ||
|
|
|
|
client.normal_hint_flags & (PPosition|USPosition)) {
|
|
|
|
setGravityOffsets();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (! fluxbox->isStartup()) {
|
2001-12-17 00:46:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
int real_x = m_frame.x();
|
|
|
|
int real_y = m_frame.y();
|
2001-12-17 00:46:15 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (decorations.tab) {
|
|
|
|
if (screen->getTabPlacement() == Tab::PTOP) {
|
|
|
|
real_y -= screen->getTabHeight();
|
|
|
|
} else if (screen->getTabPlacement() == Tab::PLEFT) {
|
|
|
|
real_x -= (screen->isTabRotateVertical())
|
|
|
|
? screen->getTabHeight()
|
|
|
|
: screen->getTabWidth();
|
|
|
|
}
|
|
|
|
}
|
2001-12-17 00:46:15 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (real_x >= 0 &&
|
2003-01-05 22:22:33 +00:00
|
|
|
real_y + m_frame.y() >= 0 &&
|
2002-12-01 13:42:15 +00:00
|
|
|
real_x <= (signed) screen->getWidth() &&
|
|
|
|
real_y <= (signed) screen->getHeight())
|
|
|
|
place_window = false;
|
2002-03-19 14:30:43 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
} else
|
|
|
|
place_window = false;
|
2001-12-17 00:46:15 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
associateClientWindow();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
grabButtons();
|
2003-02-02 16:32:41 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
positionWindows();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-02-03 13:56:12 +00:00
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (workspace_number < 0 || workspace_number >= screen->getCount())
|
2003-02-02 16:32:41 +00:00
|
|
|
workspace_number = screen->getCurrentWorkspaceID();
|
|
|
|
|
2003-02-16 17:57:54 +00:00
|
|
|
restoreAttributes();
|
2003-02-02 16:32:41 +00:00
|
|
|
|
2003-02-09 14:11:14 +00:00
|
|
|
moveToLayer(m_layernum);
|
2003-02-02 16:32:41 +00:00
|
|
|
screen->getWorkspace(workspace_number)->addWindow(this, place_window);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (shaded) { // start shaded
|
2002-12-01 13:42:15 +00:00
|
|
|
shaded = false;
|
|
|
|
shade();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (maximized && functions.maximize) { // start maximized
|
2002-12-01 13:42:15 +00:00
|
|
|
maximized = false;
|
2003-01-05 22:22:33 +00:00
|
|
|
maximize();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2002-09-12 14:55:11 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (stuck) {
|
|
|
|
stuck = false;
|
|
|
|
stick();
|
2003-01-05 22:22:33 +00:00
|
|
|
deiconify(); //we're omnipresent and visible
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
setState(current_state);
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// no focus default
|
2002-12-01 13:42:15 +00:00
|
|
|
setFocusFlag(false);
|
2002-02-07 14:41:52 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
FluxboxWindow::~FluxboxWindow() {
|
2003-01-05 22:22:33 +00:00
|
|
|
// notify die
|
|
|
|
m_diesig.notify();
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (screen == 0) //the window wasn't created
|
|
|
|
return;
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
timer.stop();
|
|
|
|
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
|
|
|
|
if (moving || resizing) {
|
|
|
|
screen->hideGeometry();
|
|
|
|
XUngrabPointer(display, CurrentTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!iconic) {
|
|
|
|
Workspace *workspace = screen->getWorkspace(workspace_number);
|
|
|
|
if (workspace)
|
|
|
|
workspace->removeWindow(this);
|
|
|
|
} else //it's iconic
|
|
|
|
screen->removeIcon(this);
|
|
|
|
|
|
|
|
if (tab != 0) {
|
|
|
|
delete tab;
|
|
|
|
tab = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client.mwm_hint != 0) {
|
|
|
|
XFree(client.mwm_hint);
|
|
|
|
client.mwm_hint = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client.blackbox_hint != 0) {
|
|
|
|
XFree(client.blackbox_hint);
|
|
|
|
client.blackbox_hint = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (client.transient_for != 0) {
|
|
|
|
if (client.transient_for == this) {
|
|
|
|
client.transient_for = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fluxbox->setFocusedWindow(client.transient_for);
|
|
|
|
|
|
|
|
if (client.transient_for) {
|
|
|
|
client.transient_for->client.transients.remove(this);
|
|
|
|
client.transient_for->setInputFocus();
|
|
|
|
client.transient_for = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!client.transients.empty()) {
|
|
|
|
client.transients.back()->client.transient_for = 0;
|
|
|
|
client.transients.pop_back();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client.window_group) {
|
|
|
|
fluxbox->removeGroupSearch(client.window_group);
|
|
|
|
client.window_group = 0;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (client.window)
|
|
|
|
fluxbox->removeWindowSearch(client.window);
|
2002-01-27 13:13:33 +00:00
|
|
|
|
2002-09-08 19:51:30 +00:00
|
|
|
#ifdef DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl;
|
2002-09-08 19:51:30 +00:00
|
|
|
#endif // DEBUG
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-10-22 14:39:21 +00:00
|
|
|
bool FluxboxWindow::isGroupable() const {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (isResizable() && isMaximizable() && !isTransient())
|
|
|
|
return true;
|
|
|
|
return false;
|
2002-10-22 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::associateClientWindow() {
|
2002-12-01 13:42:15 +00:00
|
|
|
XSetWindowBorderWidth(display, client.window, 0);
|
2003-01-05 22:22:33 +00:00
|
|
|
updateTitleFromClient();
|
|
|
|
updateIconNameFromClient();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.setClientWindow(client.window);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// make sure the frame reconfigures
|
|
|
|
m_frame.reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-16 11:25:41 +00:00
|
|
|
void FluxboxWindow::grabButtons() {
|
2002-12-01 13:42:15 +00:00
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
2002-02-16 11:25:41 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XGrabButton(display, Button1, AnyModifier,
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.clientArea().window(), True, ButtonPressMask,
|
2002-02-16 11:25:41 +00:00
|
|
|
GrabModeSync, GrabModeSync, None, None);
|
2003-01-05 22:22:33 +00:00
|
|
|
XUngrabButton(display, Button1, Mod1Mask|Mod2Mask|Mod3Mask, m_frame.clientArea().window());
|
2002-08-02 12:58:37 +00:00
|
|
|
|
2002-02-16 11:25:41 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
XGrabButton(display, Button1, Mod1Mask, m_frame.window().window(), True,
|
2002-02-16 11:25:41 +00:00
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
|
|
|
GrabModeAsync, None, fluxbox->getMoveCursor());
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
//----grab with "all" modifiers
|
2003-01-05 22:22:33 +00:00
|
|
|
grabButton(display, Button1, m_frame.window().window(), fluxbox->getMoveCursor());
|
2002-02-16 11:25:41 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
XGrabButton(display, Button2, Mod1Mask, m_frame.window().window(), True,
|
2002-08-02 12:58:37 +00:00
|
|
|
ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);
|
2002-02-16 11:25:41 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
XGrabButton(display, Button3, Mod1Mask, m_frame.window().window(), True,
|
2002-02-16 11:25:41 +00:00
|
|
|
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
|
|
|
|
GrabModeAsync, None, fluxbox->getLowerRightAngleCursor());
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
//---grab with "all" modifiers
|
2003-01-05 22:22:33 +00:00
|
|
|
grabButton(display, Button3, m_frame.window().window(), fluxbox->getLowerRightAngleCursor());
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::reconfigure() {
|
2003-01-07 01:34:49 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
upsize();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
positionWindows();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
setFocusFlag(focused);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height());
|
2002-10-13 21:54:36 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
grabButtons();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-07 01:34:49 +00:00
|
|
|
m_frame.setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval());
|
|
|
|
|
|
|
|
m_windowmenu.reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::positionWindows() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.window().setBorderWidth(screen->getBorderWidth());
|
|
|
|
m_frame.clientArea().setBorderWidth(screen->getFrameWidth());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (decorations.titlebar) {
|
|
|
|
m_frame.titlebar().setBorderWidth(screen->getBorderWidth());
|
|
|
|
m_frame.showTitlebar();
|
|
|
|
} else
|
|
|
|
m_frame.hideTitlebar();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (decorations.handle) {
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.handle().setBorderWidth(screen->getBorderWidth());
|
|
|
|
m_frame.gripLeft().setBorderWidth(screen->getBorderWidth());
|
|
|
|
m_frame.gripRight().setBorderWidth(screen->getBorderWidth());
|
|
|
|
m_frame.showHandle();
|
|
|
|
} else
|
|
|
|
m_frame.hideHandle();
|
|
|
|
|
|
|
|
m_frame.reconfigure();
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (tab)
|
|
|
|
tab->setPosition();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::updateTitleFromClient() {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XTextProperty text_prop;
|
|
|
|
char **list;
|
|
|
|
int num;
|
|
|
|
I18n *i18n = I18n::instance();
|
2002-04-04 22:39:52 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (XGetWMName(display, client.window, &text_prop)) {
|
|
|
|
if (text_prop.value && text_prop.nitems > 0) {
|
|
|
|
if (text_prop.encoding != XA_STRING) {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
text_prop.nitems = strlen((char *) text_prop.value);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if ((XmbTextPropertyToTextList(display, &text_prop,
|
|
|
|
&list, &num) == Success) &&
|
|
|
|
(num > 0) && *list) {
|
|
|
|
client.title = static_cast<char *>(*list);
|
|
|
|
XFreeStringList(list);
|
|
|
|
} else
|
|
|
|
client.title = (char *)text_prop.value;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
} else
|
|
|
|
client.title = (char *)text_prop.value;
|
|
|
|
XFree((char *) text_prop.value);
|
2003-01-05 22:22:33 +00:00
|
|
|
} else { // ok, we don't have a name, set default name
|
2002-12-01 13:42:15 +00:00
|
|
|
client.title = i18n->getMessage(
|
2003-01-05 22:22:33 +00:00
|
|
|
FBNLS::WindowSet, FBNLS::WindowUnnamed,
|
|
|
|
"Unnamed");
|
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
|
|
|
client.title = i18n->getMessage(
|
2003-01-05 22:22:33 +00:00
|
|
|
FBNLS::WindowSet, FBNLS::WindowUnnamed,
|
|
|
|
"Unnamed");
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-01-05 22:22:33 +00:00
|
|
|
|
|
|
|
m_frame.setTitle(client.title);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::updateIconNameFromClient() {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XTextProperty text_prop;
|
|
|
|
char **list;
|
|
|
|
int num;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (XGetWMIconName(display, client.window, &text_prop)) {
|
|
|
|
if (text_prop.value && text_prop.nitems > 0) {
|
|
|
|
if (text_prop.encoding != XA_STRING) {
|
|
|
|
text_prop.nitems = strlen((char *) text_prop.value);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if ((XmbTextPropertyToTextList(display, &text_prop,
|
|
|
|
&list, &num) == Success) &&
|
|
|
|
(num > 0) && *list) {
|
|
|
|
client.icon_title = (char *)*list;
|
|
|
|
XFreeStringList(list);
|
|
|
|
} else
|
|
|
|
client.icon_title = (char *)text_prop.value;
|
|
|
|
} else
|
|
|
|
client.icon_title = (char *)text_prop.value;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XFree((char *) text_prop.value);
|
|
|
|
} else
|
|
|
|
client.icon_title = getTitle();
|
|
|
|
} else
|
|
|
|
client.icon_title = getTitle();
|
2002-04-04 22:39:52 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::getWMProtocols() {
|
2003-01-05 22:22:33 +00:00
|
|
|
Atom *proto = 0;
|
2002-12-01 13:42:15 +00:00
|
|
|
int num_return = 0;
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
|
|
|
|
if (XGetWMProtocols(display, client.window, &proto, &num_return)) {
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
for (int i = 0; i < num_return; ++i) {
|
|
|
|
if (proto[i] == fluxbox->getWMDeleteAtom())
|
2003-01-05 22:22:33 +00:00
|
|
|
functions.close = true;
|
2002-12-01 13:42:15 +00:00
|
|
|
else if (proto[i] == fluxbox->getWMTakeFocusAtom())
|
|
|
|
send_focus_message = true;
|
|
|
|
else if (proto[i] == fluxbox->getFluxboxStructureMessagesAtom())
|
|
|
|
screen->addNetizen(new Netizen(screen, client.window));
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree(proto);
|
2003-01-05 22:22:33 +00:00
|
|
|
} else {
|
|
|
|
cerr<<"Warning: Failed to read WM Protocols"<<endl;
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::getWMHints() {
|
2002-12-01 13:42:15 +00:00
|
|
|
XWMHints *wmhint = XGetWMHints(display, client.window);
|
|
|
|
if (! wmhint) {
|
|
|
|
visible = true;
|
|
|
|
iconic = false;
|
|
|
|
focus_mode = F_PASSIVE;
|
|
|
|
client.window_group = None;
|
|
|
|
client.initial_state = NormalState;
|
|
|
|
} else {
|
|
|
|
client.wm_hint_flags = wmhint->flags;
|
|
|
|
if (wmhint->flags & InputHint) {
|
|
|
|
if (wmhint->input) {
|
|
|
|
if (send_focus_message)
|
|
|
|
focus_mode = F_LOCALLYACTIVE;
|
|
|
|
else
|
|
|
|
focus_mode = F_PASSIVE;
|
|
|
|
} else {
|
|
|
|
if (send_focus_message)
|
|
|
|
focus_mode = F_GLOBALLYACTIVE;
|
|
|
|
else
|
|
|
|
focus_mode = F_NOINPUT;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
focus_mode = F_PASSIVE;
|
|
|
|
|
|
|
|
if (wmhint->flags & StateHint)
|
|
|
|
client.initial_state = wmhint->initial_state;
|
|
|
|
else
|
|
|
|
client.initial_state = NormalState;
|
|
|
|
|
|
|
|
if (wmhint->flags & WindowGroupHint) {
|
|
|
|
if (! client.window_group) {
|
|
|
|
client.window_group = wmhint->window_group;
|
|
|
|
Fluxbox::instance()->saveGroupSearch(client.window_group, this);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
client.window_group = None;
|
|
|
|
|
|
|
|
XFree(wmhint);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::getWMNormalHints() {
|
2002-12-01 13:42:15 +00:00
|
|
|
long icccm_mask;
|
|
|
|
XSizeHints sizehint;
|
|
|
|
if (! XGetWMNormalHints(display, client.window, &sizehint, &icccm_mask)) {
|
|
|
|
client.min_width = client.min_height =
|
|
|
|
client.base_width = client.base_height =
|
|
|
|
client.width_inc = client.height_inc = 1;
|
|
|
|
client.max_width = 0; // unbounded
|
|
|
|
client.max_height = 0;
|
|
|
|
client.min_aspect_x = client.min_aspect_y =
|
|
|
|
client.max_aspect_x = client.max_aspect_y = 1;
|
|
|
|
client.win_gravity = NorthWestGravity;
|
|
|
|
} else {
|
|
|
|
client.normal_hint_flags = sizehint.flags;
|
|
|
|
|
|
|
|
if (sizehint.flags & PMinSize) {
|
|
|
|
client.min_width = sizehint.min_width;
|
|
|
|
client.min_height = sizehint.min_height;
|
|
|
|
} else
|
|
|
|
client.min_width = client.min_height = 1;
|
|
|
|
|
|
|
|
if (sizehint.flags & PMaxSize) {
|
|
|
|
client.max_width = sizehint.max_width;
|
|
|
|
client.max_height = sizehint.max_height;
|
|
|
|
} else {
|
|
|
|
client.max_width = 0; // unbounded
|
|
|
|
client.max_height = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sizehint.flags & PResizeInc) {
|
|
|
|
client.width_inc = sizehint.width_inc;
|
|
|
|
client.height_inc = sizehint.height_inc;
|
|
|
|
} else
|
|
|
|
client.width_inc = client.height_inc = 1;
|
|
|
|
|
|
|
|
if (sizehint.flags & PAspect) {
|
|
|
|
client.min_aspect_x = sizehint.min_aspect.x;
|
|
|
|
client.min_aspect_y = sizehint.min_aspect.y;
|
|
|
|
client.max_aspect_x = sizehint.max_aspect.x;
|
|
|
|
client.max_aspect_y = sizehint.max_aspect.y;
|
|
|
|
} else
|
|
|
|
client.min_aspect_x = client.min_aspect_y =
|
|
|
|
client.max_aspect_x = client.max_aspect_y = 1;
|
|
|
|
|
|
|
|
if (sizehint.flags & PBaseSize) {
|
|
|
|
client.base_width = sizehint.base_width;
|
|
|
|
client.base_height = sizehint.base_height;
|
|
|
|
} else
|
|
|
|
client.base_width = client.base_height = 0;
|
|
|
|
|
|
|
|
if (sizehint.flags & PWinGravity)
|
|
|
|
client.win_gravity = sizehint.win_gravity;
|
|
|
|
else
|
|
|
|
client.win_gravity = NorthWestGravity;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::getMWMHints() {
|
2002-12-01 13:42:15 +00:00
|
|
|
int format;
|
|
|
|
Atom atom_return;
|
|
|
|
unsigned long num, len;
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
if (!XGetWindowProperty(display, client.window,
|
|
|
|
fluxbox->getMotifWMHintsAtom(), 0,
|
|
|
|
PropMwmHintsElements, false,
|
|
|
|
fluxbox->getMotifWMHintsAtom(), &atom_return,
|
|
|
|
&format, &num, &len,
|
|
|
|
(unsigned char **) &client.mwm_hint) == Success &&
|
|
|
|
client.mwm_hint) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (num != PropMwmHintsElements)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (client.mwm_hint->flags & MwmHintsDecorations) {
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorAll) {
|
|
|
|
decorations.titlebar = decorations.handle = decorations.border =
|
|
|
|
decorations.iconify = decorations.maximize =
|
|
|
|
decorations.close = decorations.menu = true;
|
|
|
|
} else {
|
|
|
|
decorations.titlebar = decorations.handle = decorations.border =
|
|
|
|
decorations.iconify = decorations.maximize =
|
|
|
|
decorations.close = decorations.tab = false;
|
|
|
|
decorations.menu = true;
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorBorder)
|
|
|
|
decorations.border = true;
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorHandle)
|
|
|
|
decorations.handle = true;
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorTitle)
|
|
|
|
decorations.titlebar = decorations.tab = true; //only tab on windows with titlebar
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorMenu)
|
|
|
|
decorations.menu = true;
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorIconify)
|
|
|
|
decorations.iconify = true;
|
|
|
|
if (client.mwm_hint->decorations & MwmDecorMaximize)
|
|
|
|
decorations.maximize = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client.mwm_hint->flags & MwmHintsFunctions) {
|
|
|
|
if (client.mwm_hint->functions & MwmFuncAll) {
|
|
|
|
functions.resize = functions.move = functions.iconify =
|
|
|
|
functions.maximize = functions.close = true;
|
|
|
|
} else {
|
|
|
|
functions.resize = functions.move = functions.iconify =
|
|
|
|
functions.maximize = functions.close = false;
|
|
|
|
|
|
|
|
if (client.mwm_hint->functions & MwmFuncResize)
|
|
|
|
functions.resize = true;
|
|
|
|
if (client.mwm_hint->functions & MwmFuncMove)
|
|
|
|
functions.move = true;
|
|
|
|
if (client.mwm_hint->functions & MwmFuncIconify)
|
|
|
|
functions.iconify = true;
|
|
|
|
if (client.mwm_hint->functions & MwmFuncMaximize)
|
|
|
|
functions.maximize = true;
|
|
|
|
if (client.mwm_hint->functions & MwmFuncClose)
|
|
|
|
functions.close = true;
|
|
|
|
}
|
|
|
|
}
|
2002-05-30 00:46:22 +00:00
|
|
|
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::getBlackboxHints() {
|
2002-12-01 13:42:15 +00:00
|
|
|
int format;
|
|
|
|
Atom atom_return;
|
|
|
|
unsigned long num, len;
|
2003-01-05 22:22:33 +00:00
|
|
|
FbAtoms *atoms = FbAtoms::instance();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (XGetWindowProperty(display, client.window,
|
2003-01-05 22:22:33 +00:00
|
|
|
atoms->getFluxboxHintsAtom(), 0,
|
2002-12-01 13:42:15 +00:00
|
|
|
PropBlackboxHintsElements, False,
|
2003-01-05 22:22:33 +00:00
|
|
|
atoms->getFluxboxHintsAtom(), &atom_return,
|
2002-12-01 13:42:15 +00:00
|
|
|
&format, &num, &len,
|
|
|
|
(unsigned char **) &client.blackbox_hint) == Success &&
|
|
|
|
client.blackbox_hint) {
|
|
|
|
|
|
|
|
if (num == PropBlackboxHintsElements) {
|
|
|
|
if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_SHADED)
|
|
|
|
shaded = (client.blackbox_hint->attrib & BaseDisplay::ATTRIB_SHADED);
|
|
|
|
|
|
|
|
if ((client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXHORIZ) &&
|
|
|
|
(client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXVERT))
|
|
|
|
maximized = ((client.blackbox_hint->attrib &
|
|
|
|
(BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT)) ? 1 : 0);
|
|
|
|
else if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXVERT)
|
|
|
|
maximized = ((client.blackbox_hint->attrib & BaseDisplay::ATTRIB_MAXVERT) ? 2 : 0);
|
|
|
|
else if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXHORIZ)
|
|
|
|
maximized = ((client.blackbox_hint->attrib & BaseDisplay::ATTRIB_MAXHORIZ) ? 3 : 0);
|
|
|
|
|
|
|
|
if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_OMNIPRESENT)
|
|
|
|
stuck = (client.blackbox_hint->attrib & BaseDisplay::ATTRIB_OMNIPRESENT);
|
|
|
|
|
|
|
|
if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_WORKSPACE)
|
|
|
|
workspace_number = client.blackbox_hint->workspace;
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_STACK)
|
|
|
|
workspace_number = client.blackbox_hint->stack;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_DECORATION) {
|
|
|
|
old_decoration = static_cast<Decoration>(client.blackbox_hint->decoration);
|
|
|
|
setDecoration(old_decoration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::move(int x, int y) {
|
|
|
|
moveResize(x, y, m_frame.width(), m_frame.height());
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::resize(unsigned int width, unsigned int height) {
|
|
|
|
moveResize(m_frame.x(), m_frame.y(), width, height);
|
|
|
|
}
|
2002-08-14 22:52:06 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::moveResize(int new_x, int new_y,
|
|
|
|
unsigned int new_width, unsigned int new_height) {
|
2002-02-04 06:53:14 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
bool send_event = (m_frame.x() != new_x || m_frame.y() != new_y);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (new_width != m_frame.width() || new_height != m_frame.height()) {
|
|
|
|
if ((((signed) m_frame.width()) + new_x) < 0)
|
|
|
|
new_x = 0;
|
|
|
|
if ((((signed) m_frame.height()) + new_y) < 0)
|
|
|
|
new_y = 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
downsize();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.moveResize(new_x, new_y, new_width, new_height);
|
|
|
|
if (tab)
|
|
|
|
tab->resize();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
positionWindows();
|
|
|
|
setFocusFlag(focused);
|
|
|
|
shaded = false;
|
2003-01-05 22:22:33 +00:00
|
|
|
send_event = true;
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.move(new_x, new_y);
|
2002-12-01 13:42:15 +00:00
|
|
|
//move the tab and the chain
|
|
|
|
if (tab)
|
|
|
|
tab->setPosition();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-10 20:20:37 +00:00
|
|
|
// if (! moving)
|
2003-01-05 22:22:33 +00:00
|
|
|
send_event = true;
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (send_event && ! moving) {
|
2003-01-05 22:22:33 +00:00
|
|
|
/*
|
|
|
|
Send event telling where the root position
|
|
|
|
of the client window is. (ie frame pos + client pos inside the frame = send pos)
|
|
|
|
*/
|
|
|
|
|
|
|
|
client.width = m_frame.clientArea().width();
|
|
|
|
client.height = m_frame.clientArea().height();
|
|
|
|
client.x = m_frame.x();
|
|
|
|
client.y = m_frame.y();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XEvent event;
|
|
|
|
event.type = ConfigureNotify;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
event.xconfigure.display = display;
|
|
|
|
event.xconfigure.event = client.window;
|
|
|
|
event.xconfigure.window = client.window;
|
2003-01-05 22:22:33 +00:00
|
|
|
event.xconfigure.x = m_frame.x() + m_frame.clientArea().x();
|
|
|
|
event.xconfigure.y = m_frame.y() + m_frame.clientArea().y();
|
2002-12-01 13:42:15 +00:00
|
|
|
event.xconfigure.width = client.width;
|
|
|
|
event.xconfigure.height = client.height;
|
|
|
|
event.xconfigure.border_width = client.old_bw;
|
2003-01-05 22:22:33 +00:00
|
|
|
event.xconfigure.above = m_frame.window().window();
|
2002-12-01 13:42:15 +00:00
|
|
|
event.xconfigure.override_redirect = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XSendEvent(display, client.window, False, StructureNotifyMask, &event);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
screen->updateNetizenConfigNotify(&event);
|
|
|
|
}
|
2003-01-05 22:22:33 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
bool FluxboxWindow::setInputFocus() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
//TODO hint skip focus
|
|
|
|
if (((signed) (m_frame.x() + m_frame.width())) < 0) {
|
|
|
|
if (((signed) (m_frame.y() + m_frame.height())) < 0) {
|
|
|
|
moveResize(screen->getBorderWidth(), screen->getBorderWidth(),
|
|
|
|
m_frame.width(), m_frame.height());
|
|
|
|
} else if (m_frame.y() > (signed) screen->getHeight()) {
|
|
|
|
moveResize(screen->getBorderWidth(), screen->getHeight() - m_frame.height(),
|
|
|
|
m_frame.width(), m_frame.height());
|
|
|
|
} else {
|
|
|
|
moveResize(screen->getBorderWidth(), m_frame.y() + screen->getBorderWidth(),
|
|
|
|
m_frame.width(), m_frame.height());
|
|
|
|
}
|
|
|
|
} else if (m_frame.x() > (signed) screen->getWidth()) {
|
|
|
|
if (((signed) (m_frame.y() + m_frame.height())) < 0) {
|
|
|
|
moveResize(screen->getWidth() - m_frame.width(), screen->getBorderWidth(),
|
|
|
|
m_frame.width(), m_frame.height());
|
|
|
|
} else if (m_frame.y() > (signed) screen->getHeight()) {
|
|
|
|
moveResize(screen->getWidth() - m_frame.width(),
|
|
|
|
screen->getHeight() - m_frame.height(), m_frame.width(), m_frame.height());
|
|
|
|
} else {
|
|
|
|
moveResize(screen->getWidth() - m_frame.width(),
|
|
|
|
m_frame.y() + screen->getBorderWidth(), m_frame.width(), m_frame.height());
|
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! validateClient())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
if (client.transients.size() && modal) {
|
|
|
|
std::list<FluxboxWindow *>::iterator it = client.transients.begin();
|
|
|
|
std::list<FluxboxWindow *>::iterator it_end = client.transients.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if ((*it)->modal)
|
|
|
|
return (*it)->setInputFocus();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (focus_mode == F_LOCALLYACTIVE || focus_mode == F_PASSIVE) {
|
|
|
|
XSetInputFocus(display, client.window,
|
|
|
|
RevertToPointerRoot, CurrentTime);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2003-01-05 22:22:33 +00:00
|
|
|
|
|
|
|
m_frame.setFocus(true);
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
Fluxbox *fb = Fluxbox::instance();
|
|
|
|
fb->setFocusedWindow(this);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (send_focus_message) {
|
|
|
|
XEvent ce;
|
|
|
|
ce.xclient.type = ClientMessage;
|
|
|
|
ce.xclient.message_type = fb->getWMProtocolsAtom();
|
|
|
|
ce.xclient.display = display;
|
|
|
|
ce.xclient.window = client.window;
|
|
|
|
ce.xclient.format = 32;
|
|
|
|
ce.xclient.data.l[0] = fb->getWMTakeFocusAtom();
|
|
|
|
ce.xclient.data.l[1] = fb->getLastTime();
|
|
|
|
ce.xclient.data.l[2] = 0l;
|
|
|
|
ce.xclient.data.l[3] = 0l;
|
|
|
|
ce.xclient.data.l[4] = 0l;
|
|
|
|
XSendEvent(display, client.window, false, NoEventMask, &ce);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((screen->isSloppyFocus() || screen->isSemiSloppyFocus())
|
|
|
|
&& screen->doAutoRaise())
|
|
|
|
timer.start();
|
|
|
|
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Enables or disables the tab on the window
|
|
|
|
*/
|
2001-12-11 20:47:02 +00:00
|
|
|
void FluxboxWindow::setTab(bool flag) {
|
2003-01-05 22:22:33 +00:00
|
|
|
/* if (flag) {
|
|
|
|
if (!tab && isGroupable())
|
|
|
|
tab = new Tab(this, 0, 0);
|
2002-11-17 12:50:20 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (tab) {
|
|
|
|
tab->focus(); // draws the tab with correct texture
|
|
|
|
tab->setPosition(); // set tab windows position
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (tab) {
|
|
|
|
delete tab;
|
|
|
|
tab = 0;
|
|
|
|
}
|
|
|
|
decorations.tab = flag;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2003-02-16 17:57:54 +00:00
|
|
|
void FluxboxWindow::hide() {
|
|
|
|
m_windowmenu.hide();
|
|
|
|
m_frame.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FluxboxWindow::show() {
|
|
|
|
m_frame.show();
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Unmaps the window and removes it from workspace list
|
|
|
|
*/
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::iconify() {
|
2002-01-18 01:25:58 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (iconic) // no need to iconify if we're already
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-07 01:34:49 +00:00
|
|
|
m_windowmenu.hide();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
setState(IconicState);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XSelectInput(display, client.window, NoEventMask);
|
|
|
|
XUnmapWindow(display, client.window);
|
|
|
|
XSelectInput(display, client.window,
|
|
|
|
PropertyChangeMask | StructureNotifyMask | FocusChangeMask);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.hide();
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
visible = false;
|
|
|
|
iconic = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
screen->getWorkspace(workspace_number)->removeWindow(this);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (client.transient_for) {
|
|
|
|
if (! client.transient_for->iconic)
|
|
|
|
client.transient_for->iconify();
|
|
|
|
}
|
|
|
|
screen->addIcon(this);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (tab) //if this window got a tab then iconify it too
|
|
|
|
tab->iconify();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (client.transients.size()) {
|
|
|
|
std::list<FluxboxWindow *>::iterator it = client.transients.begin();
|
|
|
|
std::list<FluxboxWindow *>::iterator it_end = client.transients.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if (! (*it)->iconic)
|
|
|
|
(*it)->iconify();
|
|
|
|
}
|
|
|
|
}
|
2002-08-12 17:32:52 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::deiconify(bool reassoc, bool do_raise) {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (iconic || reassoc) {
|
|
|
|
screen->reassociateWindow(this, screen->getCurrentWorkspace()->workspaceID(), false);
|
|
|
|
} else if (workspace_number != screen->getCurrentWorkspace()->workspaceID())
|
|
|
|
return;
|
|
|
|
|
|
|
|
setState(NormalState);
|
|
|
|
|
|
|
|
XSelectInput(display, client.window, NoEventMask);
|
|
|
|
XMapWindow(display, client.window);
|
|
|
|
XSelectInput(display, client.window,
|
|
|
|
PropertyChangeMask | StructureNotifyMask | FocusChangeMask);
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.show();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (iconic && screen->doFocusNew())
|
|
|
|
setInputFocus();
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (focused != m_frame.focused())
|
|
|
|
m_frame.setFocus(focused);
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
visible = true;
|
|
|
|
iconic = false;
|
|
|
|
|
|
|
|
if (reassoc && client.transients.size()) {
|
|
|
|
// deiconify all transients
|
|
|
|
std::list<FluxboxWindow *>::iterator it = client.transients.begin();
|
|
|
|
std::list<FluxboxWindow *>::iterator it_end = client.transients.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
(*it)->deiconify(true, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tab)
|
|
|
|
tab->deiconify();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (do_raise)
|
|
|
|
raise();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Send close request to client window
|
|
|
|
*/
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::close() {
|
2003-01-05 22:22:33 +00:00
|
|
|
// fill in XClientMessage structure for delete message
|
2002-12-01 13:42:15 +00:00
|
|
|
XEvent ce;
|
|
|
|
ce.xclient.type = ClientMessage;
|
2003-01-05 22:22:33 +00:00
|
|
|
ce.xclient.message_type = FbAtoms::instance()->getWMProtocolsAtom();
|
|
|
|
ce.xclient.display = FbTk::App::instance()->display();
|
2002-12-01 13:42:15 +00:00
|
|
|
ce.xclient.window = client.window;
|
|
|
|
ce.xclient.format = 32;
|
2003-01-05 22:22:33 +00:00
|
|
|
ce.xclient.data.l[0] = FbAtoms::instance()->getWMDeleteAtom();
|
2002-12-01 13:42:15 +00:00
|
|
|
ce.xclient.data.l[1] = CurrentTime;
|
|
|
|
ce.xclient.data.l[2] = 0l;
|
|
|
|
ce.xclient.data.l[3] = 0l;
|
|
|
|
ce.xclient.data.l[4] = 0l;
|
2003-01-05 22:22:33 +00:00
|
|
|
// send event delete message to client window
|
2002-12-01 13:42:15 +00:00
|
|
|
XSendEvent(display, client.window, false, NoEventMask, &ce);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Set window in withdrawn state
|
|
|
|
*/
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::withdraw() {
|
2002-12-01 13:42:15 +00:00
|
|
|
visible = false;
|
|
|
|
iconic = false;
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (isMoving())
|
|
|
|
stopMoving();
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (isResizing())
|
|
|
|
stopResizing();
|
2002-02-17 18:48:22 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.hide();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-07 01:34:49 +00:00
|
|
|
m_windowmenu.hide();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (tab)
|
|
|
|
tab->withdraw();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Maximize window both horizontal and vertical
|
|
|
|
*/
|
|
|
|
void FluxboxWindow::maximize() {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (isIconic())
|
|
|
|
deiconify();
|
2002-08-12 03:28:17 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (!maximized) {
|
|
|
|
// save old values
|
|
|
|
m_old_width = frame().width();
|
|
|
|
m_old_height = frame().height();
|
|
|
|
m_old_pos_x = frame().x();
|
|
|
|
m_old_pos_y = frame().y();
|
|
|
|
unsigned int left_x = screen->getMaxLeft();
|
|
|
|
unsigned int max_width = screen->getMaxRight();
|
|
|
|
unsigned int max_top = screen->getMaxTop();
|
|
|
|
moveResize(left_x, max_top,
|
|
|
|
max_width - left_x, screen->getMaxBottom() - max_top - m_frame.window().borderWidth());
|
|
|
|
} else { // demaximize, restore to old values
|
|
|
|
moveResize(m_old_pos_x, m_old_pos_y,
|
|
|
|
m_old_width, m_old_height);
|
|
|
|
}
|
|
|
|
// toggle maximize
|
|
|
|
maximized = !maximized;
|
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::maximizeHorizontal() {
|
|
|
|
unsigned int left_x = screen->getMaxLeft();
|
|
|
|
unsigned int max_width = screen->getMaxRight();
|
|
|
|
moveResize(left_x, m_frame.y(),
|
|
|
|
max_width - left_x, m_frame.height() - m_frame.window().borderWidth());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Maximize window horizontal
|
|
|
|
*/
|
|
|
|
void FluxboxWindow::maximizeVertical() {
|
|
|
|
unsigned int max_top = screen->getMaxTop();
|
|
|
|
moveResize(m_frame.x(), max_top,
|
|
|
|
m_frame.width() - m_frame.window().borderWidth(), screen->getMaxBottom() - max_top);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FluxboxWindow::setWorkspace(int n) {
|
2003-02-16 17:57:54 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
workspace_number = n;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
blackbox_attrib.flags |= BaseDisplay::ATTRIB_WORKSPACE;
|
|
|
|
blackbox_attrib.workspace = workspace_number;
|
2002-09-07 20:16:43 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// notify workspace change
|
2002-09-07 20:16:43 +00:00
|
|
|
#ifdef DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
cerr<<this<<" notify workspace signal"<<endl;
|
2002-09-07 20:16:43 +00:00
|
|
|
#endif // DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
m_workspacesig.notify();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
void FluxboxWindow::setLayerNum(int layernum) {
|
|
|
|
m_layernum = layernum;
|
|
|
|
|
|
|
|
blackbox_attrib.flags |= BaseDisplay::ATTRIB_STACK;
|
|
|
|
blackbox_attrib.stack = layernum;
|
|
|
|
saveBlackboxHints();
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<this<<" notify layer signal"<<endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
m_layersig.notify();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::shade() {
|
2003-02-17 09:56:00 +00:00
|
|
|
if (!decorations.titlebar)
|
|
|
|
return;
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2003-02-17 09:56:00 +00:00
|
|
|
// toggle shade on tab and frame
|
|
|
|
m_frame.shade();
|
|
|
|
if (tab)
|
|
|
|
tab->shade();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-02-17 09:56:00 +00:00
|
|
|
if (shaded) {
|
|
|
|
shaded = false;
|
|
|
|
blackbox_attrib.flags ^= BaseDisplay::ATTRIB_SHADED;
|
|
|
|
blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_SHADED;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-02-17 09:56:00 +00:00
|
|
|
setState(NormalState);
|
|
|
|
} else {
|
|
|
|
shaded = true;
|
|
|
|
blackbox_attrib.flags |= BaseDisplay::ATTRIB_SHADED;
|
|
|
|
blackbox_attrib.attrib |= BaseDisplay::ATTRIB_SHADED;
|
|
|
|
|
|
|
|
setState(IconicState);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-02-17 09:56:00 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::stick() {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (tab) //if it got a tab then do tab's stick on all of the objects in the list
|
|
|
|
tab->stick(); //this window will stick too.
|
|
|
|
else if (stuck) {
|
|
|
|
blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT;
|
|
|
|
blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
stuck = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
|
|
|
stuck = true;
|
|
|
|
if (screen->getCurrentWorkspaceID() != workspace_number) {
|
|
|
|
screen->reassociateWindow(this,screen->getCurrentWorkspaceID(), true);
|
|
|
|
}
|
2002-09-12 14:55:11 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
blackbox_attrib.flags |= BaseDisplay::ATTRIB_OMNIPRESENT;
|
|
|
|
blackbox_attrib.attrib |= BaseDisplay::ATTRIB_OMNIPRESENT;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
}
|
|
|
|
//TODO: make sure any button that listens to this state gets updated
|
|
|
|
|
|
|
|
setState(current_state);
|
|
|
|
}
|
|
|
|
|
2003-02-09 14:11:14 +00:00
|
|
|
void FluxboxWindow::raise() {
|
2003-01-05 22:22:33 +00:00
|
|
|
if (isIconic())
|
|
|
|
deiconify();
|
|
|
|
|
2003-02-09 14:11:14 +00:00
|
|
|
FluxboxWindow *win = this;
|
|
|
|
|
|
|
|
while (win->getTransientFor()) {
|
|
|
|
win = win->getTransientFor();
|
|
|
|
assert(win != win->getTransientFor());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (win == 0)
|
|
|
|
win = this;
|
|
|
|
|
|
|
|
if (!win->isIconic()) {
|
|
|
|
screen->updateNetizenWindowRaise(win->getClientWindow());
|
|
|
|
win->getLayerItem().raise();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<FluxboxWindow *>::const_iterator it = win->getTransients().begin();
|
|
|
|
std::list<FluxboxWindow *>::const_iterator it_end = win->getTransients().end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if (!(*it)->isIconic()) {
|
|
|
|
screen->updateNetizenWindowRaise((*it)->getClientWindow());
|
|
|
|
(*it)->getLayerItem().raise();
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-02-09 14:11:14 +00:00
|
|
|
void FluxboxWindow::lower() {
|
2003-01-05 22:22:33 +00:00
|
|
|
if (isIconic())
|
|
|
|
deiconify();
|
2003-02-09 14:11:14 +00:00
|
|
|
|
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = this;
|
|
|
|
|
|
|
|
while (bottom->getTransientFor()) {
|
|
|
|
bottom = bottom->getTransientFor();
|
|
|
|
assert(bottom != bottom->getTransientFor());
|
|
|
|
}
|
|
|
|
|
|
|
|
win = bottom;
|
|
|
|
|
|
|
|
if (!win->isIconic()) {
|
|
|
|
screen->updateNetizenWindowLower(win->getClientWindow());
|
|
|
|
win->getLayerItem().lower();
|
|
|
|
}
|
|
|
|
std::list<FluxboxWindow *>::const_iterator it = win->getTransients().begin();
|
|
|
|
std::list<FluxboxWindow *>::const_iterator it_end = win->getTransients().end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if (!(*it)->isIconic()) {
|
|
|
|
screen->updateNetizenWindowLower((*it)->getClientWindow());
|
|
|
|
(*it)->getLayerItem().lower();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-02-09 14:11:14 +00:00
|
|
|
void FluxboxWindow::raiseLayer() {
|
|
|
|
// don't let it up to menu layer
|
|
|
|
if (getLayerNum() == (Fluxbox::instance()->getMenuLayer()+1))
|
|
|
|
return;
|
|
|
|
|
|
|
|
FluxboxWindow *win = this;
|
|
|
|
|
|
|
|
while (win->getTransientFor()) {
|
|
|
|
win = win->getTransientFor();
|
|
|
|
assert(win != win->getTransientFor());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!win->isIconic()) {
|
|
|
|
screen->updateNetizenWindowRaise(win->getClientWindow());
|
|
|
|
win->getLayerItem().raiseLayer();
|
|
|
|
win->setLayerNum(win->getLayerItem().getLayerNum());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<FluxboxWindow *>::const_iterator it = win->getTransients().begin();
|
|
|
|
std::list<FluxboxWindow *>::const_iterator it_end = win->getTransients().end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if (!(*it)->isIconic()) {
|
|
|
|
screen->updateNetizenWindowRaise((*it)->getClientWindow());
|
|
|
|
(*it)->getLayerItem().raiseLayer();
|
|
|
|
(*it)->setLayerNum((*it)->getLayerItem().getLayerNum());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FluxboxWindow::lowerLayer() {
|
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = this;
|
|
|
|
|
|
|
|
while (bottom->getTransientFor()) {
|
|
|
|
bottom = bottom->getTransientFor();
|
|
|
|
assert(bottom != bottom->getTransientFor());
|
|
|
|
}
|
|
|
|
|
|
|
|
win = bottom;
|
|
|
|
|
|
|
|
if (!win->isIconic()) {
|
|
|
|
screen->updateNetizenWindowLower(win->getClientWindow());
|
|
|
|
win->getLayerItem().lowerLayer();
|
|
|
|
win->setLayerNum(win->getLayerItem().getLayerNum());
|
|
|
|
}
|
|
|
|
std::list<FluxboxWindow *>::const_iterator it = win->getTransients().begin();
|
|
|
|
std::list<FluxboxWindow *>::const_iterator it_end = win->getTransients().end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if (!(*it)->isIconic()) {
|
|
|
|
screen->updateNetizenWindowLower((*it)->getClientWindow());
|
|
|
|
(*it)->getLayerItem().lowerLayer();
|
|
|
|
(*it)->setLayerNum((*it)->getLayerItem().getLayerNum());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void FluxboxWindow::moveToLayer(int layernum) {
|
|
|
|
Fluxbox * fluxbox = Fluxbox::instance();
|
|
|
|
|
|
|
|
FluxboxWindow *win = this;
|
|
|
|
|
|
|
|
// don't let it set its layer into menu area
|
|
|
|
if (layernum <= fluxbox->getMenuLayer()) {
|
|
|
|
layernum = fluxbox->getMenuLayer() + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (win->getTransientFor()) {
|
|
|
|
win = win->getTransientFor();
|
|
|
|
assert(win != win->getTransientFor());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!win->isIconic()) {
|
|
|
|
screen->updateNetizenWindowRaise(win->getClientWindow());
|
|
|
|
win->getLayerItem().moveToLayer(layernum);
|
|
|
|
win->setLayerNum(win->getLayerItem().getLayerNum());
|
|
|
|
}
|
|
|
|
std::list<FluxboxWindow *>::const_iterator it = win->getTransients().begin();
|
|
|
|
std::list<FluxboxWindow *>::const_iterator it_end = win->getTransients().end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if (!(*it)->isIconic()) {
|
|
|
|
screen->updateNetizenWindowRaise((*it)->getClientWindow());
|
|
|
|
(*it)->getLayerItem().moveToLayer(layernum);
|
|
|
|
(*it)->setLayerNum((*it)->getLayerItem().getLayerNum());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
void FluxboxWindow::setFocusFlag(bool focus) {
|
2002-12-01 13:42:15 +00:00
|
|
|
focused = focus;
|
|
|
|
|
|
|
|
// Record focus timestamp for window cycling enhancements, such as skipping lower tabs
|
|
|
|
if (focused)
|
|
|
|
gettimeofday(&lastFocusTime, 0);
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.setFocus(focus);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (tab)
|
|
|
|
tab->focus();
|
|
|
|
|
|
|
|
if ((screen->isSloppyFocus() || screen->isSemiSloppyFocus()) &&
|
|
|
|
screen->doAutoRaise())
|
|
|
|
timer.stop();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FluxboxWindow::installColormap(bool install) {
|
2002-12-01 13:42:15 +00:00
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
fluxbox->grab();
|
|
|
|
if (! validateClient()) return;
|
|
|
|
|
|
|
|
int i = 0, ncmap = 0;
|
|
|
|
Colormap *cmaps = XListInstalledColormaps(display, client.window, &ncmap);
|
|
|
|
XWindowAttributes wattrib;
|
|
|
|
if (cmaps) {
|
|
|
|
if (XGetWindowAttributes(display, client.window, &wattrib)) {
|
|
|
|
if (install) {
|
2003-01-05 22:22:33 +00:00
|
|
|
// install the window's colormap
|
2002-12-01 13:42:15 +00:00
|
|
|
for (i = 0; i < ncmap; i++) {
|
|
|
|
if (*(cmaps + i) == wattrib.colormap) {
|
|
|
|
// this window is using an installed color map... do not install
|
|
|
|
install = false;
|
|
|
|
break; //end for-loop (we dont need to check more)
|
|
|
|
}
|
|
|
|
}
|
2003-01-05 22:22:33 +00:00
|
|
|
// otherwise, install the window's colormap
|
2002-12-01 13:42:15 +00:00
|
|
|
if (install)
|
|
|
|
XInstallColormap(display, wattrib.colormap);
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < ncmap; i++) // uninstall the window's colormap
|
|
|
|
if (*(cmaps + i) == wattrib.colormap)
|
|
|
|
XUninstallColormap(display, wattrib.colormap); // we found the colormap to uninstall
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XFree(cmaps);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
fluxbox->ungrab();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
void FluxboxWindow::saveBlackboxHints() {
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
XChangeProperty(display, client.window, fluxbox->getFluxboxAttributesAtom(),
|
|
|
|
fluxbox->getFluxboxAttributesAtom(), 32, PropModeReplace,
|
|
|
|
(unsigned char *) &blackbox_attrib, PropBlackboxAttributesElements);
|
|
|
|
}
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
void FluxboxWindow::setState(unsigned long new_state) {
|
2002-12-01 13:42:15 +00:00
|
|
|
current_state = new_state;
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
unsigned long state[2];
|
|
|
|
state[0] = (unsigned long) current_state;
|
|
|
|
state[1] = (unsigned long) None;
|
|
|
|
XChangeProperty(display, client.window, fluxbox->getWMStateAtom(),
|
|
|
|
fluxbox->getWMStateAtom(), 32, PropModeReplace,
|
|
|
|
(unsigned char *) state, 2);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
saveBlackboxHints();
|
2002-12-01 13:42:15 +00:00
|
|
|
//notify state changed
|
|
|
|
m_statesig.notify();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
bool FluxboxWindow::getState() {
|
2002-12-01 13:42:15 +00:00
|
|
|
current_state = 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
Atom atom_return;
|
|
|
|
bool ret = false;
|
|
|
|
int foo;
|
|
|
|
unsigned long *state, ulfoo, nitems;
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
if ((XGetWindowProperty(display, client.window, fluxbox->getWMStateAtom(),
|
|
|
|
0l, 2l, false, fluxbox->getWMStateAtom(),
|
|
|
|
&atom_return, &foo, &nitems, &ulfoo,
|
|
|
|
(unsigned char **) &state) != Success) ||
|
|
|
|
(! state)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nitems >= 1) {
|
|
|
|
current_state = static_cast<unsigned long>(state[0]);
|
|
|
|
ret = true;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XFree(static_cast<void *>(state));
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
return ret;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
//TODO: this functions looks odd
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::setGravityOffsets() {
|
2003-01-05 22:22:33 +00:00
|
|
|
int newx = m_frame.x();
|
|
|
|
int newy = m_frame.y();
|
2002-12-01 13:42:15 +00:00
|
|
|
// translate x coordinate
|
|
|
|
switch (client.win_gravity) {
|
|
|
|
// handle Westward gravity
|
|
|
|
case NorthWestGravity:
|
|
|
|
case WestGravity:
|
|
|
|
case SouthWestGravity:
|
|
|
|
default:
|
2003-01-05 22:22:33 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<__FILE__<<": Default gravity: SouthWest, NorthWest, West"<<endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
newx = m_frame.x();
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// handle Eastward gravity
|
|
|
|
case NorthEastGravity:
|
|
|
|
case EastGravity:
|
|
|
|
case SouthEastGravity:
|
2003-01-05 22:22:33 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<__FILE__<<": Gravity: SouthEast, NorthEast, East"<<endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
newx = m_frame.x() + m_frame.clientArea().width() - m_frame.width();
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// no x translation desired - default
|
|
|
|
case StaticGravity:
|
|
|
|
case ForgetGravity:
|
|
|
|
case CenterGravity:
|
2003-01-05 22:22:33 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<__FILE__<<": Gravity: Center, Forget, Static"<<endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
newx = m_frame.x();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// translate y coordinate
|
|
|
|
switch (client.win_gravity) {
|
|
|
|
// handle Northbound gravity
|
|
|
|
case NorthWestGravity:
|
|
|
|
case NorthGravity:
|
|
|
|
case NorthEastGravity:
|
|
|
|
default:
|
2003-01-05 22:22:33 +00:00
|
|
|
newy = m_frame.y();
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// handle Southbound gravity
|
|
|
|
case SouthWestGravity:
|
|
|
|
case SouthGravity:
|
|
|
|
case SouthEastGravity:
|
2003-01-05 22:22:33 +00:00
|
|
|
newy = m_frame.y() + m_frame.clientArea().height() - m_frame.height();
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// no y translation desired - default
|
|
|
|
case StaticGravity:
|
|
|
|
case ForgetGravity:
|
|
|
|
case CenterGravity:
|
2003-01-05 22:22:33 +00:00
|
|
|
newy = m_frame.y();
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-01-05 22:22:33 +00:00
|
|
|
// finaly move the frame
|
|
|
|
if (m_frame.x() != newx || m_frame.y() != newy)
|
|
|
|
m_frame.move(newx, newy);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
/*
|
|
|
|
* restoreAttributes sets the attributes to what they should be
|
|
|
|
* but doesn't change the actual state
|
|
|
|
* (so the caller can set defaults etc as well)
|
|
|
|
*/
|
2003-02-16 17:57:54 +00:00
|
|
|
void FluxboxWindow::restoreAttributes() {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (!getState())
|
|
|
|
current_state = NormalState;
|
|
|
|
|
|
|
|
Atom atom_return;
|
|
|
|
int foo;
|
|
|
|
unsigned long ulfoo, nitems;
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
|
|
|
|
BaseDisplay::BlackboxAttributes *net;
|
|
|
|
if (XGetWindowProperty(display, client.window,
|
|
|
|
fluxbox->getFluxboxAttributesAtom(), 0l,
|
|
|
|
PropBlackboxAttributesElements, false,
|
|
|
|
fluxbox->getFluxboxAttributesAtom(), &atom_return, &foo,
|
|
|
|
&nitems, &ulfoo, (unsigned char **) &net) ==
|
|
|
|
Success && net && nitems == PropBlackboxAttributesElements) {
|
|
|
|
blackbox_attrib.flags = net->flags;
|
|
|
|
blackbox_attrib.attrib = net->attrib;
|
|
|
|
blackbox_attrib.workspace = net->workspace;
|
|
|
|
blackbox_attrib.stack = net->stack;
|
|
|
|
blackbox_attrib.premax_x = net->premax_x;
|
|
|
|
blackbox_attrib.premax_y = net->premax_y;
|
|
|
|
blackbox_attrib.premax_w = net->premax_w;
|
|
|
|
blackbox_attrib.premax_h = net->premax_h;
|
|
|
|
|
|
|
|
XFree(static_cast<void *>(net));
|
|
|
|
} else
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (blackbox_attrib.flags & BaseDisplay::ATTRIB_SHADED &&
|
|
|
|
blackbox_attrib.attrib & BaseDisplay::ATTRIB_SHADED) {
|
|
|
|
int save_state =
|
|
|
|
((current_state == IconicState) ? NormalState : current_state);
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
shaded = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
current_state = save_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (( blackbox_attrib.workspace != screen->getCurrentWorkspaceID()) &&
|
|
|
|
( blackbox_attrib.workspace < screen->getCount())) {
|
2003-02-02 16:32:41 +00:00
|
|
|
workspace_number = blackbox_attrib.workspace;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (current_state == NormalState) current_state = WithdrawnState;
|
|
|
|
} else if (current_state == WithdrawnState)
|
|
|
|
current_state = NormalState;
|
|
|
|
|
|
|
|
if (blackbox_attrib.flags & BaseDisplay::ATTRIB_OMNIPRESENT &&
|
|
|
|
blackbox_attrib.attrib & BaseDisplay::ATTRIB_OMNIPRESENT) {
|
2003-02-02 16:32:41 +00:00
|
|
|
stuck = true;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
current_state = NormalState;
|
|
|
|
}
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
if (blackbox_attrib.flags & BaseDisplay::ATTRIB_STACK) {
|
|
|
|
//TODO check value?
|
|
|
|
m_layernum = blackbox_attrib.stack;
|
|
|
|
}
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if ((blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) ||
|
|
|
|
(blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT)) {
|
|
|
|
int x = blackbox_attrib.premax_x, y = blackbox_attrib.premax_y;
|
|
|
|
unsigned int w = blackbox_attrib.premax_w, h = blackbox_attrib.premax_h;
|
|
|
|
maximized = false;
|
|
|
|
if ((blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) &&
|
|
|
|
(blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT))
|
2003-02-02 16:32:41 +00:00
|
|
|
maximized = true;
|
2002-12-01 13:42:15 +00:00
|
|
|
else if (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT)
|
2003-01-05 22:22:33 +00:00
|
|
|
maximizeVertical();
|
2002-12-01 13:42:15 +00:00
|
|
|
else if (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ)
|
2003-01-05 22:22:33 +00:00
|
|
|
maximizeHorizontal();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
blackbox_attrib.premax_x = x;
|
|
|
|
blackbox_attrib.premax_y = y;
|
|
|
|
blackbox_attrib.premax_w = w;
|
|
|
|
blackbox_attrib.premax_h = h;
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(current_state);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Show the window menu at pos mx, my
|
|
|
|
*/
|
2002-08-12 03:28:17 +00:00
|
|
|
void FluxboxWindow::showMenu(int mx, int my) {
|
2003-01-07 01:34:49 +00:00
|
|
|
m_windowmenu.move(mx, my);
|
|
|
|
m_windowmenu.show();
|
|
|
|
m_windowmenu.raise();
|
|
|
|
// m_windowmenu.getSendToMenu().raise();
|
|
|
|
// m_windowmenu.getSendGroupToMenu().raise();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Moves the menu to last button press position and shows it,
|
|
|
|
if it's already visible it'll be hidden
|
|
|
|
*/
|
|
|
|
void FluxboxWindow::popupMenu() {
|
|
|
|
if (m_windowmenu.isVisible()) {
|
|
|
|
m_windowmenu.hide();
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
2003-01-07 01:34:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_windowmenu.move(m_last_button_x, m_frame.y() + m_frame.titlebar().height() + m_frame.titlebar().borderWidth()*2);
|
|
|
|
m_windowmenu.show();
|
|
|
|
m_windowmenu.raise();
|
2002-08-12 03:28:17 +00:00
|
|
|
}
|
2003-01-07 01:34:49 +00:00
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::restoreGravity() {
|
2002-12-01 13:42:15 +00:00
|
|
|
// restore x coordinate
|
|
|
|
switch (client.win_gravity) {
|
|
|
|
// handle Westward gravity
|
|
|
|
case NorthWestGravity:
|
|
|
|
case WestGravity:
|
|
|
|
case SouthWestGravity:
|
|
|
|
default:
|
2003-01-05 22:22:33 +00:00
|
|
|
client.x = m_frame.x();
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// handle Eastward gravity
|
|
|
|
case NorthEastGravity:
|
|
|
|
case EastGravity:
|
|
|
|
case SouthEastGravity:
|
2003-01-05 22:22:33 +00:00
|
|
|
client.x = (m_frame.x() + m_frame.width()) - client.width;
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// restore y coordinate
|
|
|
|
switch (client.win_gravity) {
|
|
|
|
// handle Northbound gravity
|
|
|
|
case NorthWestGravity:
|
|
|
|
case NorthGravity:
|
|
|
|
case NorthEastGravity:
|
|
|
|
default:
|
2003-01-05 22:22:33 +00:00
|
|
|
client.y = m_frame.y();
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// handle Southbound gravity
|
|
|
|
case SouthWestGravity:
|
|
|
|
case SouthGravity:
|
|
|
|
case SouthEastGravity:
|
2003-01-05 22:22:33 +00:00
|
|
|
client.y = (m_frame.y() + m_frame.height()) - client.height;
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Determine if this is the lowest tab of them all
|
|
|
|
*/
|
2002-05-30 00:46:22 +00:00
|
|
|
bool FluxboxWindow::isLowerTab() const {
|
2002-12-01 13:42:15 +00:00
|
|
|
Tab* chkTab = (tab ? tab->first() : 0);
|
|
|
|
while (chkTab) {
|
|
|
|
const FluxboxWindow* chkWin = chkTab->getWindow();
|
|
|
|
if (chkWin && chkWin != this &&
|
|
|
|
timercmp(&chkWin->lastFocusTime, &lastFocusTime, >))
|
|
|
|
return true;
|
|
|
|
chkTab = chkTab->next();
|
|
|
|
}
|
|
|
|
return false;
|
2002-03-18 19:58:06 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Redirect any unhandled event to our handlers
|
|
|
|
*/
|
|
|
|
void FluxboxWindow::handleEvent(XEvent &event) {
|
|
|
|
switch (event.type) {
|
|
|
|
case ConfigureRequest:
|
|
|
|
configureRequestEvent(event.xconfigurerequest);
|
|
|
|
case MapNotify:
|
|
|
|
mapNotifyEvent(event.xmap);
|
|
|
|
case MapRequest:
|
|
|
|
mapRequestEvent(event.xmaprequest);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) {
|
|
|
|
// we're only conserned about client window event
|
|
|
|
if (re.window != client.window)
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
|
|
|
|
bool get_state_ret = getState();
|
|
|
|
if (! (get_state_ret && fluxbox->isStartup())) {
|
|
|
|
if ((client.wm_hint_flags & StateHint) &&
|
|
|
|
(! (current_state == NormalState || current_state == IconicState))) {
|
|
|
|
current_state = client.initial_state;
|
|
|
|
} else
|
|
|
|
current_state = NormalState;
|
|
|
|
} else if (iconic)
|
|
|
|
current_state = NormalState;
|
2002-08-11 22:44:29 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
switch (current_state) {
|
|
|
|
case IconicState:
|
|
|
|
iconify();
|
2002-08-11 22:44:29 +00:00
|
|
|
break;
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
case WithdrawnState:
|
|
|
|
withdraw();
|
2002-08-11 22:44:29 +00:00
|
|
|
break;
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
case NormalState:
|
2003-01-05 22:22:33 +00:00
|
|
|
// check WM_CLASS only when we changed state to NormalState from
|
2002-12-01 13:42:15 +00:00
|
|
|
// WithdrawnState (ICCC 4.1.2.5)
|
2002-08-11 22:44:29 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XClassHint ch;
|
|
|
|
|
|
|
|
if (XGetClassHint(display, getClientWindow(), &ch) == 0) {
|
|
|
|
cerr<<"Failed to read class hint!"<<endl;
|
|
|
|
} else {
|
|
|
|
if (ch.res_name != 0) {
|
|
|
|
m_instance_name = const_cast<char *>(ch.res_name);
|
|
|
|
XFree(ch.res_name);
|
|
|
|
} else
|
|
|
|
m_instance_name = "";
|
|
|
|
|
|
|
|
if (ch.res_class != 0) {
|
|
|
|
m_class_name = const_cast<char *>(ch.res_class);
|
|
|
|
XFree(ch.res_class);
|
|
|
|
} else
|
|
|
|
m_class_name = "";
|
|
|
|
|
|
|
|
Workspace *wsp = screen->getWorkspace(workspace_number);
|
|
|
|
// we must be resizable AND maximizable to be autogrouped
|
|
|
|
// TODO: there should be an isGroupable() function
|
|
|
|
if (wsp != 0 && isResizable() && isMaximizable()) {
|
|
|
|
wsp->checkGrouping(*this);
|
|
|
|
}
|
|
|
|
}
|
2002-08-11 22:44:29 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
deiconify(false);
|
2002-08-11 22:44:29 +00:00
|
|
|
|
|
|
|
break;
|
2002-12-01 13:42:15 +00:00
|
|
|
case InactiveState:
|
|
|
|
case ZoomState:
|
|
|
|
default:
|
|
|
|
deiconify(false);
|
|
|
|
break;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::mapNotifyEvent(XMapEvent &ne) {
|
2003-01-10 20:20:37 +00:00
|
|
|
if (ne.window == client.window && !ne.override_redirect && visible) {
|
2002-12-01 13:42:15 +00:00
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
fluxbox->grab();
|
|
|
|
if (! validateClient())
|
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
setState(NormalState);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (transient || screen->doFocusNew())
|
|
|
|
setInputFocus();
|
|
|
|
else
|
|
|
|
setFocusFlag(false);
|
2003-01-05 22:22:33 +00:00
|
|
|
|
|
|
|
if (focused)
|
|
|
|
m_frame.setFocus(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
visible = true;
|
|
|
|
iconic = false;
|
2002-08-02 12:58:37 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// Auto-group from tab?
|
|
|
|
if (!transient) {
|
|
|
|
// Grab and clear the auto-group window
|
|
|
|
FluxboxWindow* autoGroupWindow = screen->useAutoGroupWindow();
|
|
|
|
if (autoGroupWindow) {
|
|
|
|
Tab *groupTab = autoGroupWindow->getTab();
|
|
|
|
if (groupTab)
|
|
|
|
groupTab->addWindowToGroup(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fluxbox->ungrab();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Unmaps frame window and client window if
|
|
|
|
event.window == client.window
|
|
|
|
Returns true if *this should die
|
|
|
|
else false
|
|
|
|
*/
|
|
|
|
void FluxboxWindow::unmapNotifyEvent(XUnmapEvent &ue) {
|
|
|
|
if (ue.window != client.window)
|
|
|
|
return;
|
2002-08-16 10:50:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2003-01-05 22:22:33 +00:00
|
|
|
cerr<<__FILE__<<": unmapNotifyEvent() 0x"<<hex<<client.window<<dec<<endl;
|
2002-08-16 10:50:20 +00:00
|
|
|
#endif // DEBUG
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
restore(false);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-16 11:25:41 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/**
|
|
|
|
Checks if event is for client.window.
|
|
|
|
*/
|
|
|
|
void FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent &de) {
|
|
|
|
if (de.window == client.window) {
|
2002-08-16 10:50:20 +00:00
|
|
|
#ifdef DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): DestroyNotifyEvent this="<<this<<endl;
|
2002-08-16 10:50:20 +00:00
|
|
|
#endif // DEBUG
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.hide();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FluxboxWindow::propertyNotifyEvent(Atom atom) {
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
switch(atom) {
|
|
|
|
case XA_WM_CLASS:
|
|
|
|
case XA_WM_CLIENT_MACHINE:
|
|
|
|
case XA_WM_COMMAND:
|
|
|
|
break;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
case XA_WM_TRANSIENT_FOR:
|
2003-01-05 22:22:33 +00:00
|
|
|
updateTransientInfo();
|
2002-12-01 13:42:15 +00:00
|
|
|
reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
case XA_WM_HINTS:
|
|
|
|
getWMHints();
|
|
|
|
break;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
case XA_WM_ICON_NAME:
|
2003-01-05 22:22:33 +00:00
|
|
|
updateIconNameFromClient();
|
2002-12-01 13:42:15 +00:00
|
|
|
if (iconic)
|
|
|
|
screen->iconUpdate();
|
|
|
|
updateIcon();
|
|
|
|
break;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
case XA_WM_NAME:
|
2003-01-05 22:22:33 +00:00
|
|
|
updateTitleFromClient();
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (hasTab()) // update tab
|
|
|
|
getTab()->draw(false);
|
2002-01-04 21:21:43 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (! iconic)
|
|
|
|
screen->getWorkspace(workspace_number)->update();
|
|
|
|
else
|
|
|
|
updateIcon();
|
2002-04-04 22:39:52 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
case XA_WM_NORMAL_HINTS: {
|
|
|
|
getWMNormalHints();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if ((client.normal_hint_flags & PMinSize) &&
|
|
|
|
(client.normal_hint_flags & PMaxSize)) {
|
2002-09-14 12:31:18 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (client.max_width != 0 && client.max_width <= client.min_width &&
|
|
|
|
client.max_height != 0 && client.max_height <= client.min_height) {
|
|
|
|
decorations.maximize = false;
|
|
|
|
decorations.handle = false;
|
|
|
|
functions.resize=false;
|
|
|
|
functions.maximize=false;
|
|
|
|
} else {
|
|
|
|
if (! isTransient()) {
|
|
|
|
decorations.maximize = true;
|
|
|
|
decorations.handle = true;
|
|
|
|
functions.maximize = true;
|
|
|
|
}
|
|
|
|
functions.resize = true;
|
|
|
|
}
|
2002-09-14 12:31:18 +00:00
|
|
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// save old values
|
|
|
|
int x = m_frame.x(), y = m_frame.y();
|
|
|
|
unsigned int w = m_frame.width(), h = m_frame.height();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
upsize();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// reconfigure if the old values changed
|
|
|
|
if ((x != m_frame.x()) || (y != m_frame.y()) ||
|
|
|
|
(w != m_frame.width()) || (h != m_frame.height()))
|
2002-12-01 13:42:15 +00:00
|
|
|
reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
default:
|
2003-01-05 22:22:33 +00:00
|
|
|
if (atom == FbAtoms::instance()->getWMProtocolsAtom()) {
|
2002-12-01 13:42:15 +00:00
|
|
|
getWMProtocols();
|
2003-01-05 22:22:33 +00:00
|
|
|
// reset window actions
|
|
|
|
screen->setupWindowActions(*this);
|
|
|
|
//!!TODO check this area
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::exposeEvent(XExposeEvent &ee) {
|
|
|
|
m_frame.exposeEvent(ee);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) {
|
2003-01-10 20:20:37 +00:00
|
|
|
if (cr.window != client.window)
|
|
|
|
return;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-10 20:20:37 +00:00
|
|
|
if (! validateClient())
|
|
|
|
return;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-10 20:20:37 +00:00
|
|
|
int cx = m_frame.x(), cy = m_frame.y();
|
|
|
|
unsigned int cw = m_frame.width(), ch = m_frame.height();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-10 20:20:37 +00:00
|
|
|
if (cr.value_mask & CWBorderWidth)
|
|
|
|
client.old_bw = cr.border_width;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-10 20:20:37 +00:00
|
|
|
if (cr.value_mask & CWX)
|
|
|
|
cx = cr.x;// - frame_mwm_border_w - screen->getBorderWidth();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-10 20:20:37 +00:00
|
|
|
if (cr.value_mask & CWY)
|
|
|
|
cy = cr.y - m_frame.titlebar().height(); // - frame_mwm_border_w - screen->getBorderWidth();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-10 20:20:37 +00:00
|
|
|
if (cr.value_mask & CWWidth)
|
|
|
|
cw = cr.width;// + (frame_mwm_border_w * 2);
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2003-01-10 20:20:37 +00:00
|
|
|
if (cr.value_mask & CWHeight)
|
|
|
|
ch = cr.height;
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2003-01-10 20:20:37 +00:00
|
|
|
if (m_frame.x() != cx || m_frame.y() != cy ||
|
|
|
|
m_frame.width() != cw || m_frame.height() != ch) {
|
|
|
|
// the request is for client window so we resize the frame to it first
|
|
|
|
frame().resizeForClient(cw, ch);
|
|
|
|
move(cx, cy);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cr.value_mask & CWStackMode) {
|
|
|
|
switch (cr.detail) {
|
|
|
|
case Above:
|
|
|
|
case TopIf:
|
|
|
|
default:
|
|
|
|
raise();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Below:
|
|
|
|
case BottomIf:
|
|
|
|
lower();
|
|
|
|
break;
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2003-01-10 20:20:37 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
|
2003-01-07 01:34:49 +00:00
|
|
|
m_last_button_x = be.x_root;
|
|
|
|
m_last_button_y = be.y_root;
|
|
|
|
|
|
|
|
// check frame events first
|
|
|
|
m_frame.buttonPressEvent(be);
|
2003-01-05 22:22:33 +00:00
|
|
|
|
|
|
|
if (be.button == 1 || (be.button == 3 && be.state == Mod1Mask)) {
|
|
|
|
if ((! focused) && (! screen->isSloppyFocus())) { //check focus
|
2002-12-01 13:42:15 +00:00
|
|
|
setInputFocus();
|
|
|
|
}
|
2002-11-12 22:04:16 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (m_frame.clientArea() == be.window) {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-07 01:34:49 +00:00
|
|
|
if (m_windowmenu.isVisible()) //hide menu if its visible
|
|
|
|
m_windowmenu.hide();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
raise();
|
|
|
|
|
|
|
|
XAllowEvents(display, ReplayPointer, be.time);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-01-07 01:34:49 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
button_grab_x = be.x_root - m_frame.x() - screen->getBorderWidth();
|
|
|
|
button_grab_y = be.y_root - m_frame.y() - screen->getBorderWidth();
|
2003-01-07 01:34:49 +00:00
|
|
|
if (m_windowmenu.isVisible())
|
|
|
|
m_windowmenu.hide();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2003-01-07 01:34:49 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-07 01:34:49 +00:00
|
|
|
void FluxboxWindow::shapeEvent(XShapeEvent *) { }
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) {
|
2003-01-07 01:34:49 +00:00
|
|
|
m_frame.buttonReleaseEvent(re); // let the frame handle the event first
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (isMoving())
|
|
|
|
stopMoving();
|
|
|
|
else if (isResizing())
|
|
|
|
stopResizing();
|
2003-01-05 22:22:33 +00:00
|
|
|
else if (re.window == m_frame.window()) {
|
|
|
|
if (re.button == 2 && re.state == Mod1Mask)
|
2002-12-01 13:42:15 +00:00
|
|
|
XUngrabPointer(display, CurrentTime);
|
|
|
|
}
|
2003-01-07 01:34:49 +00:00
|
|
|
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
|
|
|
|
if ((me.state & Button1Mask) && functions.move &&
|
|
|
|
(m_frame.titlebar() == me.window || m_frame.label() == me.window ||
|
|
|
|
m_frame.handle() == me.window || m_frame.window() == me.window) && !isResizing()) {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (! isMoving()) {
|
2003-01-05 22:22:33 +00:00
|
|
|
startMoving(me.window);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-01-05 22:22:33 +00:00
|
|
|
int dx = me.x_root - button_grab_x,
|
|
|
|
dy = me.y_root - button_grab_y;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
dx -= screen->getBorderWidth();
|
|
|
|
dy -= screen->getBorderWidth();
|
|
|
|
|
|
|
|
// Warp to next or previous workspace?, must have moved sideways some
|
2003-01-05 22:22:33 +00:00
|
|
|
int moved_x = me.x_root - last_resize_x;
|
2002-12-01 13:42:15 +00:00
|
|
|
// save last event point
|
2003-01-05 22:22:33 +00:00
|
|
|
last_resize_x = me.x_root;
|
|
|
|
last_resize_y = me.y_root;
|
2002-12-01 13:42:15 +00:00
|
|
|
if (moved_x && screen->isWorkspaceWarping()) {
|
|
|
|
int cur_id = screen->getCurrentWorkspaceID();
|
|
|
|
int new_id = cur_id;
|
|
|
|
const int warpPad = screen->getEdgeSnapThreshold();
|
2003-01-05 22:22:33 +00:00
|
|
|
if (me.x_root >= int(screen->getWidth()) - warpPad - 1 &&
|
|
|
|
m_frame.x() < int(me.x_root - button_grab_x - screen->getBorderWidth())) {
|
2002-12-01 13:42:15 +00:00
|
|
|
//warp right
|
|
|
|
new_id = (cur_id + 1) % screen->getCount();
|
2003-01-05 22:22:33 +00:00
|
|
|
dx = - me.x_root;
|
|
|
|
} else if (me.x_root <= warpPad &&
|
|
|
|
m_frame.x() > int(me.x_root - button_grab_x - screen->getBorderWidth())) {
|
2002-12-01 13:42:15 +00:00
|
|
|
//warp left
|
|
|
|
new_id = (cur_id - 1 + screen->getCount()) % screen->getCount();
|
2003-01-05 22:22:33 +00:00
|
|
|
dx = screen->getWidth() - me.x_root-1;
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (new_id != cur_id) {
|
|
|
|
XWarpPointer(display, None, None, 0, 0, 0, 0, dx, 0);
|
|
|
|
|
|
|
|
screen->changeWorkspaceID(new_id);
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
last_resize_x = me.x_root + dx;
|
|
|
|
|
|
|
|
dx += m_frame.x(); // for window in correct position
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/*
|
|
|
|
if (! screen->doOpaqueMove()) {
|
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.move_x, frame.move_y, frame.resize_w, frame.resize_h);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
frame.move_x = dx;
|
|
|
|
frame.move_y = dy;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.move_x, frame.move_y, frame.resize_w,
|
|
|
|
frame.resize_h);
|
|
|
|
} else {
|
|
|
|
*/
|
|
|
|
moveResize(dx, dy, m_frame.width(), m_frame.height());
|
|
|
|
// }
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (screen->doShowWindowPos())
|
|
|
|
screen->showPosition(dx, dy);
|
|
|
|
} // end if moving
|
|
|
|
} else if (functions.resize &&
|
2003-01-05 22:22:33 +00:00
|
|
|
(((me.state & Button1Mask) && (me.window == m_frame.gripRight() ||
|
|
|
|
me.window == m_frame.gripLeft())) ||
|
|
|
|
me.window == m_frame.window())) {
|
|
|
|
|
|
|
|
bool left = (me.window == m_frame.gripLeft());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (! resizing) {
|
2003-01-05 22:22:33 +00:00
|
|
|
startResizing(me.window, me.x, me.y, left);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else if (resizing) {
|
2003-01-05 22:22:33 +00:00
|
|
|
// draw over old rect
|
2002-12-01 13:42:15 +00:00
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
2003-01-05 22:22:33 +00:00
|
|
|
last_resize_x, last_resize_y,
|
|
|
|
last_resize_w - 1, last_resize_h-1);
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// move rectangle
|
|
|
|
int gx = 0, gy = 0;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
last_resize_h = m_frame.height() + (me.y - button_grab_y);
|
|
|
|
if (last_resize_h < 1)
|
|
|
|
last_resize_h = 1;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (left) {
|
2003-01-05 22:22:33 +00:00
|
|
|
last_resize_x = me.x_root - button_grab_x;
|
|
|
|
if (last_resize_x > (signed) (m_frame.x() + m_frame.width()))
|
|
|
|
last_resize_x = last_resize_x + m_frame.width() - 1;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
left_fixsize(&gx, &gy);
|
|
|
|
} else {
|
2003-01-05 22:22:33 +00:00
|
|
|
last_resize_w = m_frame.width() + (me.x - button_grab_x);
|
|
|
|
if (last_resize_w < 1) // clamp to 1
|
|
|
|
last_resize_w = 1;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
right_fixsize(&gx, &gy);
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// draw resize rectangle
|
2002-12-01 13:42:15 +00:00
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
2003-01-05 22:22:33 +00:00
|
|
|
last_resize_x, last_resize_y,
|
|
|
|
last_resize_w - 1, last_resize_h - 1);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (screen->doShowWindowPos())
|
|
|
|
screen->showGeometry(gx, gy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-11-17 12:50:20 +00:00
|
|
|
// TODO: functions should not be affected by decoration
|
2002-04-04 14:23:30 +00:00
|
|
|
void FluxboxWindow::setDecoration(Decoration decoration) {
|
2002-12-01 13:42:15 +00:00
|
|
|
switch (decoration) {
|
|
|
|
case DECOR_NONE:
|
|
|
|
decorations.titlebar = decorations.border = decorations.handle =
|
|
|
|
decorations.iconify = decorations.maximize =
|
|
|
|
decorations.tab = false; //tab is also a decor
|
|
|
|
decorations.menu = true; // menu is present
|
2002-11-17 12:50:20 +00:00
|
|
|
// functions.iconify = functions.maximize = true;
|
|
|
|
// functions.move = true; // We need to move even without decor
|
|
|
|
// functions.resize = true; // We need to resize even without decor
|
2003-01-07 01:34:49 +00:00
|
|
|
frame().hideAllDecorations();
|
2002-04-04 14:23:30 +00:00
|
|
|
break;
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
default:
|
|
|
|
case DECOR_NORMAL:
|
|
|
|
decorations.titlebar = decorations.border = decorations.handle =
|
|
|
|
decorations.iconify = decorations.maximize =
|
|
|
|
decorations.menu = true;
|
|
|
|
functions.resize = functions.move = functions.iconify =
|
|
|
|
functions.maximize = true;
|
2003-01-07 01:34:49 +00:00
|
|
|
m_frame.showAllDecorations();
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.show();
|
2003-01-07 01:34:49 +00:00
|
|
|
|
2002-04-04 14:23:30 +00:00
|
|
|
break;
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
case DECOR_TINY:
|
|
|
|
decorations.titlebar = decorations.iconify = decorations.menu =
|
|
|
|
functions.move = functions.iconify = true;
|
|
|
|
decorations.border = decorations.handle = decorations.maximize =
|
|
|
|
functions.resize = functions.maximize = false;
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.show();
|
2002-04-04 14:23:30 +00:00
|
|
|
break;
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
case DECOR_TOOL:
|
|
|
|
decorations.titlebar = decorations.menu = functions.move = true;
|
|
|
|
decorations.iconify = decorations.border = decorations.handle =
|
|
|
|
decorations.maximize = functions.resize = functions.maximize =
|
|
|
|
functions.iconify = false;
|
2002-04-04 14:23:30 +00:00
|
|
|
break;
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2002-04-04 14:23:30 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
reconfigure();
|
2002-04-04 14:23:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void FluxboxWindow::toggleDecoration() {
|
2002-12-01 13:42:15 +00:00
|
|
|
//don't toggle decor if the window is shaded
|
|
|
|
if (isShaded())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (decorations.enabled) { //remove decorations
|
|
|
|
setDecoration(DECOR_NONE);
|
|
|
|
decorations.enabled = false;
|
|
|
|
} else { //revert back to old decoration
|
2002-12-09 14:17:50 +00:00
|
|
|
if (old_decoration == DECOR_NONE) { // make sure something happens
|
|
|
|
setDecoration(DECOR_NORMAL);
|
|
|
|
} else {
|
|
|
|
setDecoration(old_decoration);
|
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
decorations.enabled = true;
|
|
|
|
}
|
2002-04-04 14:23:30 +00:00
|
|
|
}
|
2002-05-21 21:25:10 +00:00
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
bool FluxboxWindow::validateClient() {
|
2002-12-01 13:42:15 +00:00
|
|
|
XSync(display, false);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XEvent e;
|
|
|
|
if (XCheckTypedWindowEvent(display, client.window, DestroyNotify, &e) ||
|
|
|
|
XCheckTypedWindowEvent(display, client.window, UnmapNotify, &e)) {
|
|
|
|
XPutBackEvent(display, &e);
|
|
|
|
Fluxbox::instance()->ungrab();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
return true;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-04-04 13:19:10 +00:00
|
|
|
void FluxboxWindow::startMoving(Window win) {
|
2002-12-01 13:42:15 +00:00
|
|
|
moving = true;
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
XGrabPointer(display, win, False, Button1MotionMask |
|
|
|
|
ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
|
|
|
|
None, fluxbox->getMoveCursor(), CurrentTime);
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2003-01-07 01:34:49 +00:00
|
|
|
if (m_windowmenu.isVisible())
|
|
|
|
m_windowmenu.hide();
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
fluxbox->maskWindowEvents(client.window, this);
|
2003-01-05 22:22:33 +00:00
|
|
|
/* TODO: opaque moving
|
|
|
|
if (! screen->doOpaqueMove()) {
|
|
|
|
fluxbox->grab();
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
frame.move_x = frame.x;
|
|
|
|
frame.move_y = frame.y;
|
|
|
|
frame.move_ws = screen->getCurrentWorkspaceID();
|
|
|
|
frame.resize_w = frame.width + screen->getBorderWidth2x();
|
|
|
|
frame.resize_h = ((shaded) ? frame.title_h : frame.height) +
|
|
|
|
screen->getBorderWidth2x();
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (screen->doShowWindowPos())
|
|
|
|
screen->showPosition(frame.x, frame.y);
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.move_x, frame.move_y,
|
|
|
|
frame.resize_w, frame.resize_h);
|
|
|
|
}*/
|
2002-04-04 13:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FluxboxWindow::stopMoving() {
|
2002-12-01 13:42:15 +00:00
|
|
|
moving = false;
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
fluxbox->maskWindowEvents(0, (FluxboxWindow *) 0);
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
/* TODO: non opaque moving
|
|
|
|
if (! screen->doOpaqueMove()) {
|
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
|
|
|
frame.move_x, frame.move_y, frame.resize_w,
|
|
|
|
frame.resize_h);
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
configure(frame.move_x, frame.move_y, frame.width, frame.height);
|
|
|
|
fluxbox->ungrab();
|
|
|
|
} else
|
|
|
|
*/
|
|
|
|
moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height());
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
screen->hideGeometry();
|
|
|
|
XUngrabPointer(display, CurrentTime);
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XSync(display, False); //make sure the redraw is made before we continue
|
2002-04-04 13:19:10 +00:00
|
|
|
}
|
|
|
|
|
2002-08-30 14:06:40 +00:00
|
|
|
void FluxboxWindow::pauseMoving() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2002-08-30 14:06:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FluxboxWindow::resumeMoving() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2002-08-30 14:06:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::startResizing(Window win, int x, int y, bool left) {
|
2002-12-01 13:42:15 +00:00
|
|
|
resizing = true;
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
2003-01-05 22:22:33 +00:00
|
|
|
XGrabPointer(display, win, false, ButtonMotionMask | ButtonReleaseMask,
|
2002-12-01 13:42:15 +00:00
|
|
|
GrabModeAsync, GrabModeAsync, None,
|
2003-01-05 22:22:33 +00:00
|
|
|
(left ? fluxbox->getLowerLeftAngleCursor() : fluxbox->getLowerRightAngleCursor()),
|
2002-12-01 13:42:15 +00:00
|
|
|
CurrentTime);
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
int gx = 0, gy = 0;
|
|
|
|
button_grab_x = x - screen->getBorderWidth();
|
|
|
|
button_grab_y = y - screen->getBorderWidth2x();
|
|
|
|
last_resize_x = m_frame.x();
|
|
|
|
last_resize_y = m_frame.y();
|
|
|
|
last_resize_w = m_frame.width() + screen->getBorderWidth2x();
|
|
|
|
last_resize_h = m_frame.height() + screen->getBorderWidth2x();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (left)
|
|
|
|
left_fixsize(&gx, &gy);
|
|
|
|
else
|
|
|
|
right_fixsize(&gx, &gy);
|
|
|
|
|
|
|
|
if (screen->doShowWindowPos())
|
|
|
|
screen->showGeometry(gx, gy);
|
|
|
|
|
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
2003-01-05 22:22:33 +00:00
|
|
|
last_resize_x, last_resize_y,
|
|
|
|
last_resize_w - 1, last_resize_h - 1);
|
2002-04-04 13:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FluxboxWindow::stopResizing(Window win) {
|
2002-12-01 13:42:15 +00:00
|
|
|
resizing = false;
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
|
2003-01-05 22:22:33 +00:00
|
|
|
last_resize_x, last_resize_y,
|
|
|
|
last_resize_w - 1, last_resize_h - 1);
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
screen->hideGeometry();
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (win && win == m_frame.gripLeft())
|
2002-12-01 13:42:15 +00:00
|
|
|
left_fixsize();
|
|
|
|
else
|
|
|
|
right_fixsize();
|
2002-04-04 13:19:10 +00:00
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
moveResize(last_resize_x, last_resize_y,
|
|
|
|
last_resize_w - screen->getBorderWidth2x(),
|
|
|
|
last_resize_h - screen->getBorderWidth2x());
|
2002-04-04 13:19:10 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XUngrabPointer(display, CurrentTime);
|
2002-04-04 13:19:10 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-04 22:39:52 +00:00
|
|
|
//finds and redraw the icon label
|
|
|
|
void FluxboxWindow::updateIcon() {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (Fluxbox::instance()->useIconBar()) {
|
|
|
|
const IconBar *iconbar = 0;
|
|
|
|
const IconBarObj *icon = 0;
|
|
|
|
if ((iconbar = screen->getToolbar()->iconBar()) != 0) {
|
|
|
|
if ((icon = iconbar->findIcon(this)) != 0)
|
|
|
|
iconbar->draw(icon, icon->width());
|
|
|
|
}
|
|
|
|
}
|
2002-04-04 22:39:52 +00:00
|
|
|
}
|
2002-04-04 14:23:30 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::updateTransientInfo() {
|
2002-12-01 13:42:15 +00:00
|
|
|
// remove us from parent
|
|
|
|
if (client.transient_for != 0) {
|
|
|
|
client.transient_for->client.transients.remove(this);
|
|
|
|
}
|
|
|
|
client.transient_for = 0;
|
2002-08-30 16:07:17 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// determine if this is a transient window
|
2002-12-01 13:42:15 +00:00
|
|
|
Window win;
|
|
|
|
if (!XGetTransientForHint(display, client.window, &win))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (win == client.window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (win == screen->getRootWindow() && win != 0) {
|
|
|
|
modal = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
client.transient_for = Fluxbox::instance()->searchWindow(win);
|
|
|
|
if (client.transient_for != 0 &&
|
|
|
|
client.window_group != None && win == client.window_group) {
|
|
|
|
client.transient_for = Fluxbox::instance()->searchGroup(win, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// make sure we don't have deadlock loop in transient chain
|
|
|
|
for (FluxboxWindow *w = this; w != 0; w = w->client.transient_for) {
|
|
|
|
if (w == w->client.transient_for) {
|
|
|
|
w->client.transient_for = 0;
|
2002-09-10 10:55:34 +00:00
|
|
|
#ifdef DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
cerr<<"w = client.transient_for";
|
2002-09-10 10:55:34 +00:00
|
|
|
#endif // DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-09-08 19:51:30 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (client.transient_for != 0) {
|
|
|
|
client.transient_for->client.transients.push_back(this);
|
|
|
|
// make sure we only have on instance of this
|
|
|
|
client.transient_for->client.transients.unique();
|
|
|
|
stuck = client.transient_for->stuck;
|
|
|
|
}
|
2002-09-10 10:55:34 +00:00
|
|
|
|
2002-05-21 21:25:10 +00:00
|
|
|
}
|
|
|
|
|
2002-08-16 10:50:20 +00:00
|
|
|
void FluxboxWindow::restore(bool remap) {
|
2002-12-01 13:42:15 +00:00
|
|
|
XChangeSaveSet(display, client.window, SetModeDelete);
|
|
|
|
XSelectInput(display, client.window, NoEventMask);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
restoreGravity();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.hide();
|
|
|
|
// make sure the frame doesn't change client window anymore
|
|
|
|
m_frame.removeClient();
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XUnmapWindow(display, client.window);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// restore old border width
|
2002-12-01 13:42:15 +00:00
|
|
|
XSetWindowBorderWidth(display, client.window, client.old_bw);
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XEvent dummy;
|
|
|
|
if (! XCheckTypedWindowEvent(display, client.window, ReparentNotify,
|
|
|
|
&dummy)) {
|
2002-08-16 10:50:20 +00:00
|
|
|
#ifdef DEBUG
|
2003-02-02 16:32:41 +00:00
|
|
|
cerr<<"FluxboxWindow::restore: reparent 0x"<<hex<<client.window<<dec<<" to root"<<endl;
|
2002-08-16 10:50:20 +00:00
|
|
|
#endif // DEBUG
|
2003-01-05 22:22:33 +00:00
|
|
|
|
|
|
|
// reparent to screen window
|
2002-12-01 13:42:15 +00:00
|
|
|
XReparentWindow(display, client.window, screen->getRootWindow(),
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.x(), m_frame.y());
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2002-08-16 10:50:20 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (remap)
|
|
|
|
XMapWindow(display, client.window);
|
2002-08-16 10:50:20 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::timeout() {
|
2003-01-05 22:22:33 +00:00
|
|
|
raise();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
void FluxboxWindow::changeBlackboxHints(const BaseDisplay::BlackboxHints &net) {
|
|
|
|
if ((net.flags & BaseDisplay::ATTRIB_SHADED) &&
|
2002-12-01 13:42:15 +00:00
|
|
|
((blackbox_attrib.attrib & BaseDisplay::ATTRIB_SHADED) !=
|
2003-01-05 22:22:33 +00:00
|
|
|
(net.attrib & BaseDisplay::ATTRIB_SHADED)))
|
2002-12-01 13:42:15 +00:00
|
|
|
shade();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if ((net.flags & (BaseDisplay::ATTRIB_MAXVERT | BaseDisplay::ATTRIB_MAXHORIZ)) &&
|
2002-12-01 13:42:15 +00:00
|
|
|
((blackbox_attrib.attrib & (BaseDisplay::ATTRIB_MAXVERT | BaseDisplay::ATTRIB_MAXHORIZ)) !=
|
2003-01-05 22:22:33 +00:00
|
|
|
(net.attrib & (BaseDisplay::ATTRIB_MAXVERT | BaseDisplay::ATTRIB_MAXHORIZ)))) {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (maximized) {
|
2003-01-05 22:22:33 +00:00
|
|
|
maximize();
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-01-05 22:22:33 +00:00
|
|
|
if ((net.flags & BaseDisplay::ATTRIB_MAXHORIZ) && (net.flags & BaseDisplay::ATTRIB_MAXVERT))
|
|
|
|
maximize();
|
|
|
|
else if (net.flags & BaseDisplay::ATTRIB_MAXVERT)
|
|
|
|
maximizeVertical();
|
|
|
|
else if (net.flags & BaseDisplay::ATTRIB_MAXHORIZ)
|
|
|
|
maximizeHorizontal();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2002-09-10 16:46:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if ((net.flags & BaseDisplay::ATTRIB_OMNIPRESENT) &&
|
2002-12-01 13:42:15 +00:00
|
|
|
((blackbox_attrib.attrib & BaseDisplay::ATTRIB_OMNIPRESENT) !=
|
2003-01-05 22:22:33 +00:00
|
|
|
(net.attrib & BaseDisplay::ATTRIB_OMNIPRESENT)))
|
2002-12-01 13:42:15 +00:00
|
|
|
stick();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if ((net.flags & BaseDisplay::ATTRIB_WORKSPACE) &&
|
|
|
|
(workspace_number != net.workspace)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (getTab()) // disconnect from tab chain before sending it to another workspace
|
|
|
|
getTab()->disconnect();
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
screen->reassociateWindow(this, net.workspace, true);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (screen->getCurrentWorkspaceID() != net.workspace)
|
2002-12-01 13:42:15 +00:00
|
|
|
withdraw();
|
|
|
|
else
|
|
|
|
deiconify();
|
|
|
|
}
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
if (net.flags & BaseDisplay::ATTRIB_STACK) {
|
|
|
|
if ((unsigned int) m_layernum != net.stack) {
|
2003-02-09 14:11:14 +00:00
|
|
|
moveToLayer(net.stack);
|
2003-02-02 16:32:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
if (net.flags & BaseDisplay::ATTRIB_DECORATION) {
|
|
|
|
old_decoration = static_cast<Decoration>(net.decoration);
|
2002-12-01 13:42:15 +00:00
|
|
|
setDecoration(old_decoration);
|
|
|
|
}
|
2002-04-04 14:23:30 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::upsize() {
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.setBevel(screen->getBevelWidth());
|
|
|
|
m_frame.handle().resize(m_frame.handle().width(), screen->getHandleWidth());
|
|
|
|
m_frame.gripLeft().resize(m_frame.buttonHeight(), screen->getHandleWidth());
|
|
|
|
m_frame.gripRight().resize(m_frame.gripLeft().width(), m_frame.gripLeft().height());
|
2002-12-01 13:42:15 +00:00
|
|
|
// convert client.width/height into frame sizes
|
2003-01-05 22:22:33 +00:00
|
|
|
m_frame.resizeForClient(client.width, client.height);
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
///TODO
|
2002-05-30 00:46:22 +00:00
|
|
|
void FluxboxWindow::downsize() {
|
2003-01-05 22:22:33 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FluxboxWindow::right_fixsize(int *gx, int *gy) {
|
2002-12-01 13:42:15 +00:00
|
|
|
// calculate the size of the client window and conform it to the
|
|
|
|
// size specified by the size hints of the client window...
|
2003-01-05 22:22:33 +00:00
|
|
|
int dx = last_resize_w - client.base_width;
|
|
|
|
int dy = last_resize_h - client.base_height;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (dx < (signed) client.min_width)
|
|
|
|
dx = client.min_width;
|
|
|
|
if (dy < (signed) client.min_height)
|
|
|
|
dy = client.min_height;
|
|
|
|
if (client.max_width > 0 && (unsigned) dx > client.max_width)
|
|
|
|
dx = client.max_width;
|
|
|
|
if (client.max_height > 0 && (unsigned) dy > client.max_height)
|
|
|
|
dy = client.max_height;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// make it snap
|
2002-12-01 13:42:15 +00:00
|
|
|
dx /= client.width_inc;
|
|
|
|
dy /= client.height_inc;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (gx) *gx = dx;
|
|
|
|
if (gy) *gy = dy;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
dx = (dx * client.width_inc) + client.base_width;
|
|
|
|
dy = (dy * client.height_inc) + client.base_height;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
last_resize_w = dx;
|
|
|
|
last_resize_h = dy;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FluxboxWindow::left_fixsize(int *gx, int *gy) {
|
2003-01-05 22:22:33 +00:00
|
|
|
int dx = m_frame.width() + m_frame.x() - last_resize_x;
|
|
|
|
int dy = last_resize_h - client.base_height;
|
|
|
|
|
|
|
|
// check minimum size
|
|
|
|
if (dx < static_cast<signed int>(client.min_width))
|
|
|
|
dx = client.min_width;
|
|
|
|
if (dy < static_cast<signed int>(client.min_height))
|
|
|
|
dy = client.min_height;
|
|
|
|
|
|
|
|
// check maximum size
|
|
|
|
if (client.max_width > 0 && dx > static_cast<signed int>(client.max_width))
|
|
|
|
dx = client.max_width;
|
|
|
|
if (client.max_height > 0 && dy > static_cast<signed int>(client.max_height))
|
|
|
|
dy = client.max_height;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// make sure we have valid increment
|
|
|
|
if (client.width_inc == 0)
|
|
|
|
client.width_inc = 1;
|
|
|
|
if (client.height_inc == 0)
|
|
|
|
client.height_inc = 1;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// set snaping
|
2002-12-01 13:42:15 +00:00
|
|
|
dx /= client.width_inc;
|
|
|
|
dy /= client.height_inc;
|
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// set return values
|
|
|
|
if (gx != 0)
|
|
|
|
*gx = dx;
|
|
|
|
if (gy != 0)
|
|
|
|
*gy = dy;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// snapping
|
|
|
|
dx = dx * client.width_inc + client.base_width;
|
|
|
|
dy = dy * client.height_inc + client.base_height;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-05 22:22:33 +00:00
|
|
|
// update last resize
|
|
|
|
last_resize_w = dx;
|
|
|
|
last_resize_h = dy;
|
|
|
|
last_resize_x = m_frame.x() + m_frame.width() - last_resize_w;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|