CTWM
Loading...
Searching...
No Matches
Macros | Functions | Variables
/usr/src/RPM/BUILD/ctwm-4.1.0/ewmh.c File Reference
#include "ctwm.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
#include <assert.h>
#include <X11/Xatom.h>
#include <X11/extensions/shape.h>
#include "ctwm_atoms.h"
#include "ctwm_shutdown.h"
#include "ewmh_atoms.h"
#include "screen.h"
#include "events.h"
#include "event_handlers.h"
#include "functions_defs.h"
#include "icons.h"
#include "otp.h"
#include "image.h"
#include "list.h"
#include "functions.h"
#include "occupation.h"
#include "r_layout.h"
#include "util.h"
#include "vscreen.h"
#include "win_iconify.h"
#include "win_ops.h"
#include "win_resize.h"
#include "win_utils.h"
#include "workspace_utils.h"
Include dependency graph for ewmh.c:

Go to the source code of this file.

Macros

#define NET_WM_STATE_REMOVE   0 /* remove/unset property */
 
#define NET_WM_STATE_ADD   1 /* add/set property */
 
#define NET_WM_STATE_TOGGLE   2 /* toggle property */
 
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT   0
 
#define _NET_WM_MOVERESIZE_SIZE_TOP   1
 
#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT   2
 
#define _NET_WM_MOVERESIZE_SIZE_RIGHT   3
 
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT   4
 
#define _NET_WM_MOVERESIZE_SIZE_BOTTOM   5
 
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT   6
 
#define _NET_WM_MOVERESIZE_SIZE_LEFT   7
 
#define _NET_WM_MOVERESIZE_MOVE   8 /* movement only */
 
#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD   9 /* size via keyboard */
 
#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD   10 /* move via keyboard */
 
#define _NET_WM_MOVERESIZE_CANCEL   11 /* cancel operation */
 
#define ALL_WORKSPACES   0xFFFFFFFFU
 
#define CRWARN(x)   (void)0
 
#define CHKNRET(st)
 
#define DOBIT(fld)
 

Functions

static ImageExtractIcon (ScreenInfo *scr, unsigned long *prop, int width, int height)
 
static void EwmhClientMessage_NET_WM_DESKTOP (XClientMessageEvent *msg)
 
static void EwmhClientMessage_NET_WM_STATE (XClientMessageEvent *msg)
 
static void EwmhClientMessage_NET_ACTIVE_WINDOW (XClientMessageEvent *msg)
 
static void EwmhClientMessage_NET_WM_MOVERESIZE (XClientMessageEvent *msg)
 
static void EwmhClientMessage_NET_CLOSE_WINDOW (XClientMessageEvent *msg)
 
static XEvent synth_btnevent_for_moveresize (TwmWindow *twm_win)
 
static unsigned long EwmhGetWindowProperty (Window w, Atom name, Atom type)
 
static void EwmhGetStrut (TwmWindow *twm_win, bool update)
 
static void EwmhRemoveStrut (TwmWindow *twm_win)
 
static void EwmhSet_NET_WORKAREA (ScreenInfo *scr)
 
static int EwmhGet_NET_WM_STATE (TwmWindow *twm_win)
 
static void EwmhClientMessage_NET_WM_STATEchange (TwmWindow *twm_win, int change, int newVal)
 
static void SendPropertyMessage (Window to, Window about, Atom messagetype, long l0, long l1, long l2, long l3, long l4, long mask)
 
static void EwmhInitAtoms (void)
 
static int CatchError (Display *display, XErrorEvent *event)
 
void EwmhInit (void)
 
static void GenerateTimestamp (ScreenInfo *scr)
 
static bool EwmhReplaceWM (ScreenInfo *scr)
 
bool EwmhInitScreenEarly (ScreenInfo *scr)
 
void EwmhInitScreenLate (ScreenInfo *scr)
 
static void EwmhTerminateScreen (ScreenInfo *scr)
 
void EwmhTerminate (void)
 
void EwmhSelectionClear (XSelectionClearEvent *sev)
 
bool EwmhClientMessage (XClientMessageEvent *msg)
 
ImageEwmhGetIcon (ScreenInfo *scr, TwmWindow *twm_win)
 
static void convert_for_16 (int w, int x, int y, int argb)
 
static void convert_for_32 (int w, int x, int y, int argb)
 
static void EwmhHandle_NET_WM_ICONNotify (XPropertyEvent *event, TwmWindow *twm_win)
 
static void EwmhHandle_NET_WM_STRUTNotify (XPropertyEvent *event, TwmWindow *twm_win)
 
static int atomToFlag (Atom a)
 
int EwmhHandlePropertyNotify (XPropertyEvent *event, TwmWindow *twm_win)
 
void EwmhSet_NET_WM_DESKTOP (TwmWindow *twm_win)
 
void EwmhSet_NET_WM_DESKTOP_ws (TwmWindow *twm_win, WorkSpace *ws)
 
static unsigned longEwmhGetWindowProperties (Window w, Atom name, Atom type, unsigned long *nitems_return)
 
int EwmhGetOccupation (TwmWindow *twm_win)
 
void EwmhUnmapNotify (TwmWindow *twm_win)
 
void EwmhAddClientWindow (TwmWindow *new_win)
 
void EwmhDeleteClientWindow (TwmWindow *old_win)
 
void EwmhSet_NET_CLIENT_LIST_STACKING (void)
 
void EwmhSet_NET_ACTIVE_WINDOW (Window w)
 
void EwmhGetProperties (TwmWindow *twm_win)
 
int EwmhGetInitPriority (TwmWindow *twm_win)
 
bool EwmhHasBorder (TwmWindow *twm_win)
 
bool EwmhHasTitle (TwmWindow *twm_win)
 
bool EwmhOnWindowRing (TwmWindow *twm_win)
 
static void EwmhRecalculateStrut (void)
 
void EwmhSet_NET_FRAME_EXTENTS (TwmWindow *twm_win)
 Set _NET_FRAME_EXTENTS property.
 
void EwmhSet_NET_SHOWING_DESKTOP (int state)
 
void EwmhSet_NET_WM_STATE (TwmWindow *twm_win, int changes)
 

Variables

Atom XEWMHAtom [NUM_EWMH_XATOMS]
 
static bool caughtError
 
static uint16_tbuffer_16bpp
 
static uint32_tbuffer_32bpp
 

Macro Definition Documentation

◆ _NET_WM_MOVERESIZE_CANCEL

#define _NET_WM_MOVERESIZE_CANCEL   11 /* cancel operation */

Definition at line 78 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_MOVE

#define _NET_WM_MOVERESIZE_MOVE   8 /* movement only */

Definition at line 75 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_MOVE_KEYBOARD

#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD   10 /* move via keyboard */

Definition at line 77 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_SIZE_BOTTOM

#define _NET_WM_MOVERESIZE_SIZE_BOTTOM   5

Definition at line 72 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT

#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT   6

Definition at line 73 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT

#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT   4

Definition at line 71 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_SIZE_KEYBOARD

#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD   9 /* size via keyboard */

Definition at line 76 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_SIZE_LEFT

#define _NET_WM_MOVERESIZE_SIZE_LEFT   7

Definition at line 74 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_SIZE_RIGHT

#define _NET_WM_MOVERESIZE_SIZE_RIGHT   3

Definition at line 70 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_SIZE_TOP

#define _NET_WM_MOVERESIZE_SIZE_TOP   1

Definition at line 68 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_SIZE_TOPLEFT

#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT   0

Definition at line 67 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ _NET_WM_MOVERESIZE_SIZE_TOPRIGHT

#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT   2

Definition at line 69 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_MOVERESIZE().

◆ ALL_WORKSPACES

#define ALL_WORKSPACES   0xFFFFFFFFU

◆ CHKNRET

#define CHKNRET ( st)
Value:
if(a == XA__NET_WM_##st) { \
if(LookInNameList(Scr->EWMHIgnore, #st)) { \
return 0; \
} \
return EWMH_##st; \
}
static int PlaceX
Definition add_window.c:82
#define Scr
void * LookInNameList(name_list *list_head, const char *name)
Definition list.c:130

◆ CRWARN

#define CRWARN ( x)    (void)0

◆ DOBIT

#define DOBIT ( fld)
Value:
do { \
} while(0)

◆ NET_WM_STATE_ADD

#define NET_WM_STATE_ADD   1 /* add/set property */

Definition at line 64 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_STATE().

◆ NET_WM_STATE_REMOVE

#define NET_WM_STATE_REMOVE   0 /* remove/unset property */

Definition at line 63 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_STATE().

◆ NET_WM_STATE_TOGGLE

#define NET_WM_STATE_TOGGLE   2 /* toggle property */

Definition at line 65 of file ewmh.c.

Referenced by EwmhClientMessage_NET_WM_STATE().

Function Documentation

◆ atomToFlag()

static int atomToFlag ( Atom a)
static

Definition at line 1027 of file ewmh.c.

References CHKNRET, and PlaceX.

Referenced by EwmhClientMessage_NET_WM_STATE(), and EwmhGet_NET_WM_STATE().

◆ CatchError()

static int CatchError ( Display * display,
XErrorEvent * event )
static

Definition at line 126 of file ewmh.c.

References caughtError.

Referenced by EwmhReplaceWM().

◆ convert_for_16()

static void convert_for_16 ( int w,
int x,
int y,
int argb )
static

Definition at line 838 of file ewmh.c.

References buffer_16bpp, PlaceX, x, and y.

Referenced by ExtractIcon().

◆ convert_for_32()

static void convert_for_32 ( int w,
int x,
int y,
int argb )
static

Definition at line 846 of file ewmh.c.

References buffer_32bpp, PlaceX, x, and y.

Referenced by ExtractIcon().

◆ EwmhAddClientWindow()

void EwmhAddClientWindow ( TwmWindow * new_win)

Definition at line 1701 of file ewmh.c.

References dpy, PlaceX, and Scr.

Referenced by HandleMapRequest().

◆ EwmhClientMessage()

bool EwmhClientMessage ( XClientMessageEvent * msg)

◆ EwmhClientMessage_NET_ACTIVE_WINDOW()

static void EwmhClientMessage_NET_ACTIVE_WINDOW ( XClientMessageEvent * msg)
static

◆ EwmhClientMessage_NET_CLOSE_WINDOW()

static void EwmhClientMessage_NET_CLOSE_WINDOW ( XClientMessageEvent * msg)
static

Definition at line 1387 of file ewmh.c.

References ButtonPressed, C_NO_CONTEXT, ExecuteFunction(), GetTwmWindow(), and PlaceX.

Referenced by EwmhClientMessage().

◆ EwmhClientMessage_NET_WM_DESKTOP()

static void EwmhClientMessage_NET_WM_DESKTOP ( XClientMessageEvent * msg)
static

◆ EwmhClientMessage_NET_WM_MOVERESIZE()

static void EwmhClientMessage_NET_WM_MOVERESIZE ( XClientMessageEvent * msg)
static

◆ EwmhClientMessage_NET_WM_STATE()

static void EwmhClientMessage_NET_WM_STATE ( XClientMessageEvent * msg)
static

◆ EwmhClientMessage_NET_WM_STATEchange()

static void EwmhClientMessage_NET_WM_STATEchange ( TwmWindow * twm_win,
int change,
int newVal )
static

◆ EwmhDeleteClientWindow()

void EwmhDeleteClientWindow ( TwmWindow * old_win)

Definition at line 1738 of file ewmh.c.

References dpy, EWMH_HAS_STRUT, EwmhRemoveStrut(), PlaceX, and Scr.

Referenced by HandleDestroyNotify().

◆ EwmhGet_NET_WM_STATE()

static int EwmhGet_NET_WM_STATE ( TwmWindow * twm_win)
static

Definition at line 2237 of file ewmh.c.

References atomToFlag(), EwmhGetWindowProperties(), PlaceX, and TwmWindow::w.

Referenced by EwmhGetProperties().

◆ EwmhGetIcon()

Image * EwmhGetIcon ( ScreenInfo * scr,
TwmWindow * twm_win )

Definition at line 637 of file ewmh.c.

References ALLOW_DEAD_STORE, dpy, ExtractIcon(), PlaceX, Scr, and TwmWindow::w.

Referenced by CreateIconWindow(), and EwmhHandle_NET_WM_ICONNotify().

◆ EwmhGetInitPriority()

int EwmhGetInitPriority ( TwmWindow * twm_win)

Definition at line 1864 of file ewmh.c.

References EWMH_PRI_DESKTOP, EWMH_PRI_DOCK, wt_Desktop, and wt_Dock.

Referenced by AddNewOwl().

◆ EwmhGetOccupation()

int EwmhGetOccupation ( TwmWindow * twm_win)

Definition at line 1602 of file ewmh.c.

References ALL_WORKSPACES, EwmhGetWindowProperties(), fullOccupation, PlaceX, Scr, and TwmWindow::w.

Referenced by SetupOccupation().

◆ EwmhGetProperties()

void EwmhGetProperties ( TwmWindow * twm_win)

◆ EwmhGetStrut()

static void EwmhGetStrut ( TwmWindow * twm_win,
bool update )
static

◆ EwmhGetWindowProperties()

static unsigned long * EwmhGetWindowProperties ( Window w,
Atom name,
Atom type,
unsigned long * nitems_return )
static

Definition at line 1577 of file ewmh.c.

References dpy, and PlaceX.

Referenced by EwmhGet_NET_WM_STATE(), EwmhGetOccupation(), and EwmhGetStrut().

◆ EwmhGetWindowProperty()

static unsigned long EwmhGetWindowProperty ( Window w,
Atom name,
Atom type )
static

Definition at line 1541 of file ewmh.c.

References dpy, and PlaceX.

Referenced by EwmhGetProperties().

◆ EwmhHandle_NET_WM_ICONNotify()

static void EwmhHandle_NET_WM_ICONNotify ( XPropertyEvent * event,
TwmWindow * twm_win )
static

◆ EwmhHandle_NET_WM_STRUTNotify()

static void EwmhHandle_NET_WM_STRUTNotify ( XPropertyEvent * event,
TwmWindow * twm_win )
static

Definition at line 1018 of file ewmh.c.

References EwmhGetStrut().

Referenced by EwmhHandlePropertyNotify().

◆ EwmhHandlePropertyNotify()

int EwmhHandlePropertyNotify ( XPropertyEvent * event,
TwmWindow * twm_win )

◆ EwmhHasBorder()

bool EwmhHasBorder ( TwmWindow * twm_win)

Definition at line 1876 of file ewmh.c.

References wt_Desktop, and wt_Dock.

Referenced by AddWindow().

◆ EwmhHasTitle()

bool EwmhHasTitle ( TwmWindow * twm_win)

Definition at line 1887 of file ewmh.c.

References wt_Desktop, and wt_Dock.

Referenced by AddWindow().

◆ EwmhInit()

void EwmhInit ( void )

Definition at line 132 of file ewmh.c.

References EwmhInitAtoms().

Referenced by ctwm_main().

◆ EwmhInitAtoms()

static void EwmhInitAtoms ( void )
static

Definition at line 119 of file ewmh.c.

References dpy, PlaceX, and XEWMHAtom.

Referenced by EwmhInit().

◆ EwmhInitScreenEarly()

bool EwmhInitScreenEarly ( ScreenInfo * scr)

Definition at line 307 of file ewmh.c.

References dpy, EwmhReplaceWM(), PlaceX, and ScreenInfo::XineramaRoot.

Referenced by takeover_screen().

◆ EwmhInitScreenLate()

void EwmhInitScreenLate ( ScreenInfo * scr)

◆ EwmhOnWindowRing()

bool EwmhOnWindowRing ( TwmWindow * twm_win)

Definition at line 1898 of file ewmh.c.

References wt_Desktop, and wt_Dock.

Referenced by AddWindow().

◆ EwmhRecalculateStrut()

static void EwmhRecalculateStrut ( void )
static

Definition at line 1915 of file ewmh.c.

References EwmhSet_NET_WORKAREA(), max(), PlaceX, RLayoutCopyCropped(), and Scr.

Referenced by EwmhGetStrut(), and EwmhRemoveStrut().

◆ EwmhRemoveStrut()

static void EwmhRemoveStrut ( TwmWindow * twm_win)
static

Definition at line 2069 of file ewmh.c.

References EwmhRecalculateStrut(), EwmhStrut::next, PlaceX, and Scr.

Referenced by EwmhDeleteClientWindow().

◆ EwmhReplaceWM()

static bool EwmhReplaceWM ( ScreenInfo * scr)
static

◆ EwmhSelectionClear()

void EwmhSelectionClear ( XSelectionClearEvent * sev)

Definition at line 546 of file ewmh.c.

References DoShutdown(), and PlaceX.

◆ EwmhSet_NET_ACTIVE_WINDOW()

void EwmhSet_NET_ACTIVE_WINDOW ( Window w)

Definition at line 1823 of file ewmh.c.

References dpy, PlaceX, and Scr.

Referenced by SetFocus().

◆ EwmhSet_NET_CLIENT_LIST_STACKING()

void EwmhSet_NET_CLIENT_LIST_STACKING ( void )

◆ EwmhSet_NET_FRAME_EXTENTS()

void EwmhSet_NET_FRAME_EXTENTS ( TwmWindow * twm_win)

Set _NET_FRAME_EXTENTS property.

This tells the client how much space is being taken up by the window decorations. Some clients may need this information to position other windows on top of themselves. e.g., Firefox's form autofill and context menu will be positioned a bit wrong (high, by the height of the titlebar) without this.

Definition at line 2099 of file ewmh.c.

References dpy, TwmWindow::frame_bw, TwmWindow::frame_bw3D, PlaceX, TwmWindow::title_height, and TwmWindow::w.

Referenced by AddWindow().

◆ EwmhSet_NET_SHOWING_DESKTOP()

void EwmhSet_NET_SHOWING_DESKTOP ( int state)

Definition at line 2116 of file ewmh.c.

References dpy, PlaceX, and Scr.

Referenced by EwmhInitScreenLate(), and ShowBackground().

◆ EwmhSet_NET_WM_DESKTOP()

void EwmhSet_NET_WM_DESKTOP ( TwmWindow * twm_win)

◆ EwmhSet_NET_WM_DESKTOP_ws()

void EwmhSet_NET_WM_DESKTOP_ws ( TwmWindow * twm_win,
WorkSpace * ws )

◆ EwmhSet_NET_WM_STATE()

void EwmhSet_NET_WM_STATE ( TwmWindow * twm_win,
int changes )

◆ EwmhSet_NET_WORKAREA()

static void EwmhSet_NET_WORKAREA ( ScreenInfo * scr)
static

◆ EwmhTerminate()

void EwmhTerminate ( void )

Definition at line 528 of file ewmh.c.

References EwmhTerminateScreen(), NumScreens, PlaceX, and ScreenList.

Referenced by DoShutdown().

◆ EwmhTerminateScreen()

static void EwmhTerminateScreen ( ScreenInfo * scr)
static

Definition at line 512 of file ewmh.c.

References dpy, PlaceX, and ScreenInfo::XineramaRoot.

Referenced by EwmhTerminate().

◆ EwmhUnmapNotify()

void EwmhUnmapNotify ( TwmWindow * twm_win)

Definition at line 1689 of file ewmh.c.

References dpy, PlaceX, and TwmWindow::w.

Referenced by HandleUnmapNotify().

◆ ExtractIcon()

static Image * ExtractIcon ( ScreenInfo * scr,
unsigned long * prop,
int width,
int height )
static

◆ GenerateTimestamp()

static void GenerateTimestamp ( ScreenInfo * scr)
static

Definition at line 144 of file ewmh.c.

References dpy, EventTime, and PlaceX.

Referenced by EwmhReplaceWM().

◆ SendPropertyMessage()

static void SendPropertyMessage ( Window to,
Window about,
Atom messagetype,
long l0,
long l1,
long l2,
long l3,
long l4,
long mask )
static

Definition at line 98 of file ewmh.c.

References dpy, and PlaceX.

Referenced by EwmhReplaceWM().

◆ synth_btnevent_for_moveresize()

static XEvent synth_btnevent_for_moveresize ( TwmWindow * twm_win)
static

Variable Documentation

◆ buffer_16bpp

uint16_t* buffer_16bpp
static

Definition at line 835 of file ewmh.c.

Referenced by convert_for_16(), and ExtractIcon().

◆ buffer_32bpp

uint32_t* buffer_32bpp
static

Definition at line 836 of file ewmh.c.

Referenced by convert_for_32(), and ExtractIcon().

◆ caughtError

bool caughtError
static

Definition at line 124 of file ewmh.c.

Referenced by CatchError(), and EwmhReplaceWM().

◆ XEWMHAtom

Atom XEWMHAtom[NUM_EWMH_XATOMS]

Definition at line 61 of file ewmh.c.

Referenced by EwmhInitAtoms().