How to make a window always on top?
the EWMH specification explicitly states that:
_NET_WM_STATE_ABOVE and _NET_WM_STATE_BELOW are mainly meant for user preferences and should not be used by applications e.g. for drawing attention to their dialogs (the Urgency hint should be used in that case, see the section called “Urgency”).
so window managers have no responsibility to respect applications which set this property directly (i.e by XChangeProperty) by themselves. this property can be changed only by sending a client message to the root window
which window managers listens on.
i don't know how to do it in high-level gui toolkits like Qt, but here is how to do it in plain X11.(see EWMH spec, or _wnck_change_state for a sample implementation).
//file: test.c
//to build it, run
//shell> gcc test.c -lX11
#include <X11/Xlib.h>
#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 */
// change a window's _NET_WM_STATE property so that it can be kept on top.
// @display: x11 display singleton.
// @xid : the window to set on top.
Status x11_window_set_on_top (Display* display, Window xid)
{
XEvent event;
event.xclient.type = ClientMessage;
event.xclient.serial = 0;
event.xclient.send_event = True;
event.xclient.display = display;
event.xclient.window = xid;
event.xclient.message_type = XInternAtom (display, "_NET_WM_STATE", False);
event.xclient.format = 32;
event.xclient.data.l[0] = _NET_WM_STATE_ADD;
event.xclient.data.l[1] = XInternAtom (display, "_NET_WM_STATE_ABOVE", False);
event.xclient.data.l[2] = 0; //unused.
event.xclient.data.l[3] = 0;
event.xclient.data.l[4] = 0;
return XSendEvent (display, DefaultRootWindow(display), False,
SubstructureRedirectMask|SubstructureNotifyMask, &event);
}
// a sample main function for testing.
// shell> ./a.out window_xid
int main (int argc, char** argv)
{
Window xid = strtol (argv[1], NULL, 0);
Display* display = XOpenDisplay (NULL);
x11_window_set_on_top (display, xid);
XFlush (display); //for simplicity, no event loops here.
XCloseDisplay (display);
}
also note that in some x11 environment(e.g. compiz), system menus are provided by a separate decorator program instead of the compositing window manager.
how to make rxvt start as fullscreen?
Install wmctrl
$ sudo apt-get install wmctrl
Create the extension directory
$ mkdir -p ~/.urxvt/ext/
Create a plugin for Rxvt
$ vi ~/.urxvt/ext/fullscreen
#!perl
sub on_user_command {
my ($self, $cmd) = @_;
if ($cmd eq "fullscreen:switch") {
my $dummy = `wmctrl -r :ACTIVE: -b toggle,fullscreen` ;
}
}Enable the plugin
$ vi ~/.Xdefaults
...
" Fullscreen switch
URxvt.perl-ext-common: fullscreen
URxvt.keysym.F11: perl:fullscreen:switch
Now, you can toggle fullscreen with the F11 key.
Reference:
- [SOLVED] rxvt-unicode not switching to fullscreen / Arch Linux Forums
- my .Xdefaults
X11. How to know the full size of a window (with the size of its decorations)
$ cat allborders.sh
# assumptions:
# windows ids are at least 5 digits long
# we dont need to bother with windows that have no name
# "first argument" from the pipe is east (could be west)
#
WINDOW_IDS=`xwininfo -int -root -tree |\
grep '[0-9]*\ (has no name)' -v |\
grep -Eo '[0-9]{5,}'`
for win in $WINDOW_IDS;
do
xprop -id $win |\
grep -Ee '^(_NET_FRAME_EXTENTS|WM_CLASS)' |\
sed 's/.*=\ //' |\
sed -e :a -e '/$/N;s/\n/ /;ta' |\
grep ^[0-9] |\
while read line;
do
set -- $line
E=`echo $1|sed 's/,$//'`
W=`echo $2|sed 's/,$//'`
N=`echo $3|sed 's/,$//'`
S=`echo $4|sed 's/,$//'`
NAME=`echo $5|sed 's/,$//'`
CLASS=`echo $6|sed 's/,$//'`
echo -e "$CLASS $NAME $N $E $S $W"
done
done
$ ./allborders.sh
"URxvt" "urxvt" 1 1 1 1
"XTerm" "aterm" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"Firefox" "Navigator" 18 1 3 1
"Gmpc" "gmpc" 18 1 3 1
"XTerm" "aterm" 0 0 0 0
"XTerm" "one" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"XTerm" "one" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"FbPager" "fbpager" 0 0 0 0
Related Topics
Make for Compiling - All *.C Files in Folders & Subfolders in Project
Qemu Simple Backend Tracing Dosen'T Print Anything
How to Determine a Tar Archive's Format
How Does The Os Know Disk Address of an Absent Page
How to View Function Names and Parameters Contained in an Elf File
How to Find The Byte Position of Specific Line in a File
Sprof "Pltrel Not Found Error"
Git - How to Remove Branch from Checkout Autocomplete
How to Convert a Text/Plain to Text/X.Shellscript
Ssh Agent Forwarding Inside Cron Jobs
End Perl Script Without Waiting for System Call to Return
Cannot Push to My Github Private Repository
Producer Consumer Implementation in a Block Device Driver
Function Return Values Within Bash If Statements
Why Do Es and Ds Zero Out Eventually on 64 Bit Kernel When Set to Tls Selectors
Why Does High-Memory Not Exist for 64-Bit Cpu
How to Link a Linux's Thread Tid and a Pthread_T "Thread Id"