#ifndef WMGR_DECO_H_INCLUDED #define WMGR_DECO_H_INCLUDED /* $Id: wmgr_deco.h,v 1.2 1996/09/25 23:03:55 mb Exp mb $ * * Copyright (c) 1996 Martin Buck * Read COPYING for more information */ /* BTW, after having finished my implementation, I recently noticed that John Ousterhout's * Tk uses similar tricks to find out something about the decoration-window. So if you want * to use these functions in your own projects and would like to get some more insight into * these ugly hacks, you might also want to look at the file TkWm.c from the Tk-4.0 distribution. */ #include #include #define WMGR_OK 0 #define WMGR_ERR -1 #define WMGR_BOGUS -2 #define WMGR_TIMEOUT -3 #define WMGR_NODECO -4 typedef struct wmgr_deco_s { int lb, rb, tb, bb, ofs_x, ofs_y; int orig_x, orig_y; int ignore_xconfigure; time_t orig_set; Window orig_win; } wmgr_deco_t; #define WMGR_CHECK_CALL_OFFSET(win, wmgr) ((wmgr).orig_set && (wmgr).orig_win == win) /* Find out size of the decoration window's borders drawn by the window * manager around a toplevel window. The decoration window must be a direct * child of the (possibly virtual) root window and in the same tree as the * decorated window. Make sure to call this function *after* the wm has * reparented your toplevel-window. If successful, border-sizes will be * stored in wmgr->lb, rb, tb and bb & WMGR_OK will be returned. Returns * WMGR_BOGUS if decoration-sizes look strange or WMGR_NODECO if no * decoration-window can be found. */ int wmgr_get_size(Display *dpy, Window tl_win, wmgr_deco_t *wmgr); /* Prepare computation of wm's XMoveWindow-offset. Some window managers move * the upper left corner of the decoration window to the position given by * a XMoveWindow-call, some move the upper left corner of the managed window * to this position. The calculated offset will tell you how much you have to * add to the position given to the XMoveWindow-call to move the corner of the * managed window to the desired position. Beware: Some window managers use * different corners for the PPosition/USPosition and the XMoveWindow- * position. * You should call wmgr_prepare_get_offset immediately after you issued the * XMoveWindow-command with the same arguments for win, x & y. */ void wmgr_prepare_get_offset(int x, int y, Window win, wmgr_deco_t *wmgr); /* Complete the calculation of the XMoveWindow-offset. You should call this * function after you have received the synthetic XConfigureEvent that * corresponds to your XMoveWindow-call from the window manager. You can use * WMGR_CHECK_CALL_OFFSET to check whether the received event is the right * one, but this test normally isn't enough (cf. below). * If successful, this function stores the offset in wmgr->ofs_x and ofs_y * and returns WMGR_OK. Returns WMGR_BOGUS if offset looks strange or * WMGR_TIMEOUT if XConfigureEvent didn't arrive in time. */ int wmgr_get_offset(int x, int y, Window win, wmgr_deco_t *wmgr); /* wmgr_{inc,dec}_ignore_xconfigure help to find the right XConfigureEvent * that corresponds to an earlier issued XMoveWindow-call. When a window * gets mapped for the first time, you normally get a XConfigureEvent from * the window manager that mustn't be used for the offset-calculation. So * before you map your window, you should call wmgr_inc_ignore_xconfigure * and after you have received a synthetic XConfigureEvent, you should call * wmgr_dec_ignore_xconfigure and check its return-value. If if returns * zero, the event is the right one and you can call wmgr_get_offset, * otherwise you should ignore that event. */ int wmgr_inc_ignore_xconfigure(wmgr_deco_t *wmgr); int wmgr_dec_ignore_xconfigure(wmgr_deco_t *wmgr); #endif /* WMGR_DECO_H_INCLUDED */