xmonad-contrib-0.18.0.9: Community-maintained extensions for xmonad
Copyright(c) 2007 Andrea Rossato 2009 Jan Vornberger 2023 Ilya Portnov
LicenseBSD-style (see xmonad/LICENSE)
Maintainerportnov84@rambler.ru
Stabilityunstable
Portabilityunportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

XMonad.Layout.DecorationEx.Engine

Description

This module defines DecorationEngine type class, and default implementation for it.

Synopsis

DecorationEngine class

class (Read (engine widget a), Show (engine widget a), Eq a, DecorationWidget widget, HasWidgets (Theme engine) widget, ClickHandler (Theme engine) widget, ThemeAttributes (Theme engine widget)) => DecorationEngine engine widget a where Source #

Decoration engines type class. Decoration engine is responsible for drawing something inside decoration rectangle. It is also responsible for handling X11 events (such as clicks) which happen within decoration rectangle. Decoration rectangles are defined by DecorationGeometry implementation.

Associated Types

type Theme engine :: Type -> Type Source #

Type of themes used by decoration engine. This type must be parameterized over a widget type, because a theme will contain a list of widgets.

type DecorationPaintingContext engine Source #

Type of data used by engine as a context during painting; for plain X11-based implementation this is Display, Pixmap and GC.

type DecorationEngineState engine Source #

Type of state used by the decoration engine. This can contain some resources that should be initialized and released at time, such as X11 fonts.

Methods

describeEngine :: engine widget a -> String Source #

Give a name to decoration engine.

initializeState Source #

Arguments

:: engine widget a

Decoration engine instance

-> geom a

Decoration geometry instance

-> Theme engine widget

Theme to be used

-> X (DecorationEngineState engine) 

Initialize state of the engine.

releaseStateResources Source #

Arguments

:: engine widget a

Decoration engine instance

-> DecorationEngineState engine

Engine state

-> X () 

Release resources held in engine state.

calcWidgetPlace Source #

Arguments

:: engine widget a

Decoration engine instance

-> DrawData engine widget

Information about window and decoration

-> widget

Widget to be placed

-> X WidgetPlace 

Calculate place which will be occupied by one widget. NB: X coordinate of the returned rectangle will be ignored, because the rectangle will be moved to the right or to the left for proper alignment of widgets.

placeWidgets Source #

Arguments

:: Shrinker shrinker 
=> engine widget a

Decoration engine instance

-> Theme engine widget

Theme to be used

-> shrinker

Strings shrinker

-> DecorationEngineState engine

Current state of the engine

-> Rectangle

Decoration rectangle

-> Window

Original window to be decorated

-> WidgetLayout widget

Widgets layout

-> X (WidgetLayout WidgetPlace) 

Place widgets along the decoration bar.

getShrinkedWindowName Source #

Arguments

:: Shrinker shrinker 
=> engine widget a

Decoration engine instance

-> shrinker

Strings shrinker

-> DecorationEngineState engine

State of decoration engine

-> String

Original window title

-> Dimension

Width of rectangle in which the title should fit

-> Dimension

Height of rectangle in which the title should fit

-> X String 

Shrink window title so that it would fit in decoration.

default getShrinkedWindowName :: (Shrinker shrinker, DecorationEngineState engine ~ XMonadFont) => engine widget a -> shrinker -> DecorationEngineState engine -> String -> Dimension -> Dimension -> X String Source #

decorationXEventMask :: engine widget a -> EventMask Source #

Mask of X11 events on which the decoration engine should do something. exposureMask should be included here so that decoration engine could repaint decorations when they are shown on screen. buttonPressMask should be included so that decoration engine could response to mouse clicks. Other events can be added to custom implementations of DecorationEngine.

propsToRepaintDecoration :: engine widget a -> X [Atom] Source #

List of X11 window property atoms of original (client) windows, change of which should trigger repainting of decoration. For example, if WM_NAME changes it means that we have to redraw window title.

decorationEventHookEx :: Shrinker shrinker => engine widget a -> Theme engine widget -> DecorationLayoutState engine -> shrinker -> Event -> X () Source #

Generic event handler, which recieves X11 events on decoration window. Default implementation handles mouse clicks and drags.

handleDecorationClick Source #

Arguments

:: engine widget a

Decoration engine instance

-> Theme engine widget

Decoration theme

-> Rectangle

Decoration rectangle

-> [Rectangle]

Rectangles where widgets are placed

-> Window

Original (client) window

-> Int

Mouse click X coordinate

-> Int

Mouse click Y coordinate

-> Int

Mouse button number

-> X Bool 

Event handler for clicks on decoration window. This is called from default implementation of "decorationEventHookEx". This should return True, if the click was handled (something happened because of that click). If this returns False, the click can be considered as a beginning of mouse drag.

decorationWhileDraggingHook Source #

Arguments

:: engine widget a

Decoration engine instance

-> CInt

Event X coordinate

-> CInt

Event Y coordinate

-> (Window, Rectangle)

Original window and it's rectangle

-> Position

X coordinate of new pointer position during dragging

-> Position

Y coordinate of new pointer position during dragging

-> X () 

Event handler which is called during mouse dragging. This is called from default implementation of "decorationEventHookEx".

decorationAfterDraggingHook Source #

Arguments

:: engine widget a

Decoration engine instance

-> (Window, Rectangle)

Original window and its rectangle

-> Window

Decoration window

-> X () 

This hoook is called after a window has been dragged using the decoration. This is called from default implementation of "decorationEventHookEx".

paintDecoration Source #

Arguments

:: Shrinker shrinker 
=> engine widget a

Decoration engine instance

-> a

Decoration window

-> Dimension

Decoration window width

-> Dimension

Decoration window height

-> shrinker

Strings shrinker instance

-> DrawData engine widget

Details about what to draw

-> Bool

True when this method is called during Expose event

-> X () 

Draw everything required on the decoration window. This method should draw background (flat or gradient or whatever), borders, and call paintWidget method to draw window widgets (buttons and title).

paintWidget Source #

Arguments

:: Shrinker shrinker 
=> engine widget a

Decoration engine instance

-> DecorationPaintingContext engine

Decoration painting context

-> WidgetPlace

Place (rectangle) where the widget should be drawn

-> shrinker

Strings shrinker instance

-> DrawData engine widget

Details about window decoration

-> widget

Widget to be drawn

-> Bool

True when this method is called during Expose event

-> X () 

Paint one widget on the decoration window.

Instances

Instances details
(TextWidget widget, ClickHandler (GenericTheme SimpleStyle) widget) => DecorationEngine TextDecoration widget Window Source # 
Instance details

Defined in XMonad.Layout.DecorationEx.TextEngine

Methods

describeEngine :: TextDecoration widget Window -> String Source #

initializeState :: TextDecoration widget Window -> geom Window -> Theme TextDecoration widget -> X (DecorationEngineState TextDecoration) Source #

releaseStateResources :: TextDecoration widget Window -> DecorationEngineState TextDecoration -> X () Source #

calcWidgetPlace :: TextDecoration widget Window -> DrawData TextDecoration widget -> widget -> X WidgetPlace Source #

placeWidgets :: Shrinker shrinker => TextDecoration widget Window -> Theme TextDecoration widget -> shrinker -> DecorationEngineState TextDecoration -> Rectangle -> Window -> WidgetLayout widget -> X (WidgetLayout WidgetPlace) Source #

getShrinkedWindowName :: Shrinker shrinker => TextDecoration widget Window -> shrinker -> DecorationEngineState TextDecoration -> String -> Dimension -> Dimension -> X String Source #

decorationXEventMask :: TextDecoration widget Window -> EventMask Source #

propsToRepaintDecoration :: TextDecoration widget Window -> X [Atom] Source #

decorationEventHookEx :: Shrinker shrinker => TextDecoration widget Window -> Theme TextDecoration widget -> DecorationLayoutState TextDecoration -> shrinker -> Event -> X () Source #

handleDecorationClick :: TextDecoration widget Window -> Theme TextDecoration widget -> Rectangle -> [Rectangle] -> Window -> Int -> Int -> Int -> X Bool Source #

decorationWhileDraggingHook :: TextDecoration widget Window -> CInt -> CInt -> (Window, Rectangle) -> Position -> Position -> X () Source #

decorationAfterDraggingHook :: TextDecoration widget Window -> (Window, Rectangle) -> Window -> X () Source #

paintDecoration :: Shrinker shrinker => TextDecoration widget Window -> Window -> Dimension -> Dimension -> shrinker -> DrawData TextDecoration widget -> Bool -> X () Source #

paintWidget :: Shrinker shrinker => TextDecoration widget Window -> DecorationPaintingContext TextDecoration -> WidgetPlace -> shrinker -> DrawData TextDecoration widget -> widget -> Bool -> X () Source #

Auxiliary data types

data DrawData engine widget Source #

Auxiliary type for data which are passed from decoration layout modifier to decoration engine.

Constructors

DrawData 

Fields

data DecorationLayoutState engine Source #

State of decoration engine

Constructors

DecorationLayoutState 

Fields

Re-exports from X.L.Decoration

class (Read s, Show s) => Shrinker s where Source #

Methods

shrinkIt :: s -> String -> [String] Source #

Instances

Instances details
Shrinker CustomShrink Source # 
Instance details

Defined in XMonad.Config.Droundy

Shrinker DefaultShrinker Source # 
Instance details

Defined in XMonad.Layout.Decoration

Utility functions

mkDrawData Source #

Arguments

:: (DecorationEngine engine widget a, ThemeAttributes (Theme engine widget), HasWidgets (Theme engine) widget) 
=> engine widget a 
-> Theme engine widget

Decoration theme

-> DecorationEngineState engine

State of decoration engine

-> Window

Original window (to be decorated)

-> Rectangle

Decoration rectangle

-> X (DrawData engine widget) 

Build an instance of DrawData type.

paintDecorationSimple :: forall engine shrinker widget. (DecorationEngine engine widget Window, DecorationPaintingContext engine ~ XPaintingContext, Shrinker shrinker, Style (Theme engine widget) ~ SimpleStyle) => engine widget Window -> Window -> Dimension -> Dimension -> shrinker -> DrawData engine widget -> Bool -> X () Source #

Simple implementation of paintDecoration method. This is used by TextEngine and can be re-used by other decoration engines.