[prev in list] [next in list] [prev in thread] [next in thread]
List: openbox
Subject: [openbox] Ignore size hint for specific applications
From: a.thyssen () griffith ! edu ! au (Anthony Thyssen)
Date: 2018-11-06 6:57:01
Message-ID: SYXPR01MB20301433BD13020CF2C1857AB2CB0 () SYXPR01MB2030 ! ausprd01 ! prod ! outlook ! com
[Download RAW message or body]
That is quite normal. Many older terminal programs (urxvt, xterm) define there size \
based on the number of rows and columns of characters, rather than on a pixel \
dimension.
I myself had to deail with this as I wanted to place xterms in specific tile-like \
layout on a display that automatically adjusts according to the physical display \
size.
For this I ended up actually picking the font the xterm's is to use and from that \
calculating the pixel dimensions that would result for that window, so I can either \
define window positions, or adjust the row count (fixed 80 column width) to fit the \
desired height space available. The script once made has been in general use for \
more than ten years, only being tweeked occasionally due to window manager changes \
(title bar size and window border settings).
The script does all the calculations, sets xresources for the terminal windows, and \
exports some environment variables for the xterm geometry (size and position) on \
screen.
Some code extracts (watch out for unicode substitutions by mailers)....
stored in a script "xset_resources" and run using eval `xset_resources` as part \
of the x window client start up sequence.
# ----- Collect Server information -----
# Get Display width and height...
eval `xrdb -symbols -screen | sed -n '/^-D\(WIDTH\|HEIGHT\)/{s/-D/X_/gp;}'`
# ----- Basic Positionings of terminals -----
#
# These values may also depend on my window manager setup
x1pos=5 # position of first (left) xterm window (gap for left gnome-panel)
y1pos=100 # space above xterm window, for other popup applications.
x2pos='' # X location of right xterm windows calculated below
y2pos=$y1pos # Y location of right xterm is same as the first
wgap=5 # window gaps (5) -- not used if $x2pos is defined
hbot=2 # enforced space at bottom of display (above a panel)
hgap=0 # an exact vertical gap between terminals (if non-zero)
# XTerm application extras
wapp=15 # xterms extra width (scrollbar (9+2), text sep (2x2)
happ=4 # xterm extra height: internal seperation of text to window edge
# OpenBox Decorations ( title is display DPI dependant? )
openbox_wdcr=4 # borders (2) X 2
openbox_hdcr=31 # titlebar (20) + handle (3) + borders (2) X 4 => 31
# other previous window manager constants left out.
xfce_left=60 # icons=48 2*( margin=3 box=1 magrin=2 )
xfce_bottom=28 # icons=16 2*( margin=3 box=1 magrin=2 )
# ----- Display Size (Font and position changes) -----
# this gets quite complex... one example shown...
if [ "$X_WIDTH" -gt "1600" ]; then # ------ Wide Laptop Display ------
[ "$VERBOSE" ] && echo "HDMI or Multi Screen Displays (Width>1600)"
font_w=9; font_h=15 # Standard xterm "large" font
x1pos=50; wgap=30 # increase intra-window gaps
elif [ "$X_WIDTH" -eq "1400" ] ||
[ "$X_WIDTH" -eq "1280" ]; then # ------- Solaris/PC Display --------
[ "$VERBOSE" ] && echo "PC Display (Width=1400 or Width=1280)"
font_w=7; font_h=13 # Slightly bigger font
#...
else # ------- unknown display size ------
echo >&2 "x_set_resources: unknown display size ${X_WIDTH}x${X_HEIGHT}"
font_w=6; font_h=13 # Default font
fi
# Font selection also complex...
# Font selection using the pixel width and height... (Actually this is also quite \
complex) FONT="-misc-fixed-medium-r-*-*-${font_h}-*-75-75-c-${font_w}0-iso10646-1"
BFONT="-misc-fixed-bold-r-*-*-${font_h}-*-75-75-c-${font_w}0-iso10646-1"
# ----- Adjustments for window manager and panels -----
# Assume no panels will be in use
X_LEFT_MARGIN=0
X_TOP_MARGIN=0
X_BOTTOM_MARGIN=0
# Assume openbox decorations for windows
wdcr=$openbox_wdcr
hdcr=$openbox_hdcr
# xfce4-panel
X_LEFT_MARGIN=$xfce_left
X_BOTTOM_MARGIN=$xfce_bottom
# add margins to the windows appropriatally
x1pos=`expr $x1pos + $X_LEFT_MARGIN`
y1pos=`expr $y1pos + $X_TOP_MARGIN`
hbot=`expr $hbot + $X_BOTTOM_MARGIN`
# ----- XTerm Size Calculations -----
#
# Calculate placement xterm windows to fit font and display settings
width="`expr $font_w \* 80 + $wapp `" # width = 80 columns + app width
height="`expr "$X_HEIGHT" - $y1pos - $hdcr - $happ - $hbot`"
# height space available to use
rows=`expr $height / $font_h` # number of rows for large xterm
[ ! "$x2pos" ] && # calc for side by side arrangment?
x2pos="`expr $x1pos + $width + $wdcr + $wgap`" # x2pos = width + window gaps
STDGEOM="${width}x${height}" # standard window size (pixels)
XTERMGEOM_L="80x${rows}+${x1pos}+${y1pos}" # left side xterm
XTERMGEOM_R="80x${rows}+${x2pos}+${y2pos}" # right side xterm
# Set up a two vertically stacked windows on the left hand side
height="`expr $height - $hdcr - $happ - $hgap`" # space lost by extra xterm
rows=`expr $height / $font_h` # rows to divide between two terms
rows2=`expr $rows \* 1 / 4` # divide text over two windows
rows1=`expr $rows - $rows2`
XTERMGEOM_L1="80x${rows1}+${x1pos}+${y1pos}" # left top xterm window geometry
# If no gap given, center lower window in the space left
height=`expr $height - $rows \* $font_h ` # more space lost to the text
[ "$hgap" -eq 0 ] && hgap=`expr $height / 2` # gap is half the remaining space
y2pos=`expr $y1pos + $rows1 \* $font_h + $hdcr + $happ + $hgap`
XTERMGEOM_L2="80x${rows2}+${x1pos}+${y2pos}"
# use the upper left window size for default xterm size (with minimum)
[ ${rows1} -lt 25 ] && rows1=25
XTERMGEOM="80x${rows1}"
# ------ Set Resources and Output Environmnt ------
#
# Set X resources, including the font I picked above...
#
# Do NOT let xrdb use "mcpp" for preprocessing.
# As mcpp adds a space at end of defines, unless an option - at old or - at kr is
# added (which cannot be added by users)
#
( cd; # go home in a sub-shell as a precaution
xrdb -cpp /bin/cpp \
-DHOME="$HOME" -DSTDGEOM="$STDGEOM" \
-DFONT="$FONT" -DBFONT="$BFONT" \
-merge .Xresources
)
echo "X_WIDTH=\"$X_WIDTH\""
echo "X_HEIGHT=\"$X_HEIGHT\""
echo "STDGEOM=\"$STDGEOM\""
echo "XTERMGEOM=\"$XTERMGEOM\""
echo "XTERMGEOM_L=\"$XTERMGEOM_L\""
echo "XTERMGEOM_R=\"$XTERMGEOM_R\""
echo "XTERMGEOM_L1=\"$XTERMGEOM_L1\""
echo "XTERMGEOM_L2=\"$XTERMGEOM_L2\""
[ "$VERBOSE" ] && echo "FONT=\"$FONT\""
[ "$VERBOSE" ] && echo "BFONT=\"$BFONT\""
echo 'export X_WIDTH X_HEIGHT STDGEOM XTERMGEOM'
echo 'export XTERMGEOM_L XTERMGEOM_R XTERMGEOM_L1 XTERMGEOM_L2'
Enjoy...
________________________________
From: openbox <openbox-bounces at icculus.org> on behalf of sunnycemetery at \
gmail.com <sunnycemetery at gmail.com>
Sent: Thursday, 1 November 2018 10:39:01 PM
To: openbox at icculus.org
Subject: Re: [openbox] Ignore size hint for specific applications
> I'm using OpenBox as my window manager, and I have some hot keys configured to move \
> windows into certain areas of the screen with a specified window size. All windows \
> are respecting this, except urxvt which is calculating its size based on the font \
> size of the characters it is displaying.
Have you tried using percentages in your resize actions? XTerm (and most terminal \
emulators, I imagine) reports its window size as $COLUMNS × $LINES, yet sizing it \
to, say, 50% of the screen results in the correct pixel size. Example:
<action name="MoveResizeTo"> <width>50%</width> <height>50%</height> <x>-0</x> \
<y>-0</y> </action>
This is one of those quirks that initially bothered me but has since become \
irrelevant. _______________________________________________
openbox mailing list
openbox at icculus.org
http://icculus.org/mailman/listinfo/openbox<http://icculus.org/mailman/listinfo/openbox>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/openbox/attachments/20181106/e301ca3e/attachment-0001.html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic