1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-02 22:25:48 +01:00

Updating to version 0.20.2

Many bug fixes.
This commit is contained in:
dan
1998-10-21 14:43:47 +00:00
parent 9d2e6ef9f1
commit 9af1c6c415
222 changed files with 9132 additions and 4322 deletions

View File

@@ -5,28 +5,32 @@ pkgdatadir = $(datadir)/@PACKAGE@
bin_PROGRAMS = wxcopy wxpaste wdwrite getstyle setstyle seticons geticonset wmsetbg
bin_SCRIPTS = wmaker.inst dockit
bin_SCRIPTS = wmaker.inst wm-oldmenu2new
EXTRA_DIST = wmaker.inst.in bughint dockit
EXTRA_DIST = wmaker.inst.in bughint wm-oldmenu2new
INCLUDES = @DFLAGS@ -I$(top_srcdir)/wrlib @XCFLAGS@ @LIBPL_INC_PATH@ @GFXFLAGS@
INCLUDES = @DFLAGS@ @XCFLAGS@ -I$(top_srcdir)/wrlib -I$(top_srcdir)/libPropList @GFXFLAGS@
wdwrite_LDADD = @LIBPL_LIBS@ @X_EXTRA_LIBS@
# X_EXTRA_LIBS is for libproplist in systems that need -lsocket
liblist= -L$(top_builddir)/libPropList -lPropList @X_EXTRA_LIBS@
wdwrite_LDADD = $(liblist)
wxcopy_LDADD = @XLFLAGS@ @XLIBS@
wxpaste_LDADD = @XLFLAGS@ @XLIBS@
getstyle_LDADD = @LIBPL_LIBS@ @X_EXTRA_LIBS@
getstyle_LDADD = $(liblist)
setstyle_LDADD = @LIBPL_LIBS@ @X_EXTRA_LIBS@
setstyle_LDADD = $(liblist)
seticons_LDADD= @LIBPL_LIBS@ @X_EXTRA_LIBS@
seticons_LDADD= $(liblist)
geticonset_LDADD= @LIBPL_LIBS@ @X_EXTRA_LIBS@
geticonset_LDADD= $(liblist)
wmsetbg_LDADD = @LIBPL_LIBS@ -L$(top_builddir)/wrlib -lwraster @XLFLAGS@\
@GFXLIBS@ @XLIBS@ -lm
wmsetbg_LDADD = -L$(top_builddir)/libPropList -lPropList \
-L$(top_builddir)/wrlib -lwraster @XLFLAGS@ @GFXLIBS@ @XLIBS@ -lm
getstyle_SOURCES = getstyle.c

View File

@@ -66,8 +66,6 @@ I18N = @I18N@
I18N_MB = @I18N_MB@
ICONEXT = @ICONEXT@
INTLIBS = @INTLIBS@
LIBPL_INC_PATH = @LIBPL_INC_PATH@
LIBPL_LIBS = @LIBPL_LIBS@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
MOFILES = @MOFILES@
@@ -95,28 +93,31 @@ pkgdatadir = $(datadir)/@PACKAGE@
bin_PROGRAMS = wxcopy wxpaste wdwrite getstyle setstyle seticons geticonset wmsetbg
bin_SCRIPTS = wmaker.inst dockit
bin_SCRIPTS = wmaker.inst wm-oldmenu2new
EXTRA_DIST = wmaker.inst.in bughint dockit
EXTRA_DIST = wmaker.inst.in bughint wm-oldmenu2new
INCLUDES = @DFLAGS@ -I$(top_srcdir)/wrlib @XCFLAGS@ @LIBPL_INC_PATH@ @GFXFLAGS@
INCLUDES = @DFLAGS@ @XCFLAGS@ -I$(top_srcdir)/wrlib -I$(top_srcdir)/libPropList @GFXFLAGS@
wdwrite_LDADD = @LIBPL_LIBS@ @X_EXTRA_LIBS@
# X_EXTRA_LIBS is for libproplist in systems that need -lsocket
liblist= -L$(top_builddir)/libPropList -lPropList @X_EXTRA_LIBS@
wdwrite_LDADD = $(liblist)
wxcopy_LDADD = @XLFLAGS@ @XLIBS@
wxpaste_LDADD = @XLFLAGS@ @XLIBS@
getstyle_LDADD = @LIBPL_LIBS@ @X_EXTRA_LIBS@
getstyle_LDADD = $(liblist)
setstyle_LDADD = @LIBPL_LIBS@ @X_EXTRA_LIBS@
setstyle_LDADD = $(liblist)
seticons_LDADD= @LIBPL_LIBS@ @X_EXTRA_LIBS@
seticons_LDADD= $(liblist)
geticonset_LDADD= @LIBPL_LIBS@ @X_EXTRA_LIBS@
geticonset_LDADD= $(liblist)
wmsetbg_LDADD = @LIBPL_LIBS@ -L$(top_builddir)/wrlib -lwraster @XLFLAGS@\
@GFXLIBS@ @XLIBS@ -lm
wmsetbg_LDADD = -L$(top_builddir)/libPropList -lPropList \
-L$(top_builddir)/wrlib -lwraster @XLFLAGS@ @GFXLIBS@ @XLIBS@ -lm
getstyle_SOURCES = getstyle.c

View File

@@ -1,3 +1,6 @@
wm-oldmenu2new - converts between the plain text file menu format to the
property list menu format.
bughint- gathers some information for bug reporting
dockit- a Tcl/Tk for docking applications that normally can't be docked.

View File

@@ -1,298 +0,0 @@
#!/bin/sh
# Only run the following line once \
exec wish -f $0 $@
##########################################
#Copyright 1998 Kenneth W. Persinger Jr. #
# Written for WindowMaker #
##########################################
# You can add the full path for Xprop here.
set xprop xprop
###############################
# DO NOT EDIT BELOW THIS LINE #
###############################
global xprop;
global instance;set instance ""
global class;set class ""
global command; set command ""
global Version;set Version "V1.3"
global Version
global instance
global class
global command
wm withdraw .
wm group . .
toplevel .dockit -class Dockit
wm group .dockit .dockit
wm command .dockit "$argv0 $argv"
wm iconname .dockit "Dockit ${Version}"
wm protocol .dockit WM_DELETE_WINDOW {exit}
wm focusmodel .dockit passive
wm title .dockit "Dockit ${Version}"
wm geometry .dockit 309x157+440+412
wm maxsize .dockit 1265 994
wm minsize .dockit 1 1
wm overrideredirect .dockit 0
wm resizable .dockit 0 0
wm deiconify .dockit
label .dockit.msgbar \
-anchor nw -borderwidth 1 -justify left -relief raised \
-text ""
label .dockit.instlbl \
-borderwidth 1 -relief raised -text Instance
label .dockit.cllbl \
-borderwidth 1 -relief raised -text Class
label .dockit.comlbl \
-borderwidth 1 -relief raised -text Command
entry .dockit.instent -textvariable instance
entry .dockit.clent -textvariable class
entry .dockit.coment -textvariable command
button .dockit.create \
-padx 9 -pady 3 -text {Create Icon} -command {docreate}
button .dockit.exit \
-padx 9 -pady 3 -text Quit -command exit
button .dockit.grab \
-padx 9 -pady 3 -text Grab -command {dograb}
button .dockit.help \
-padx 9 -pady 3 -text Help -command {dohelp}
###################
# SETTING GEOMETRY
###################
place .dockit.msgbar \
-x 5 -y 120 -width 296 -height 33 -anchor nw -bordermode ignore
place .dockit.instlbl \
-x 5 -y 5 -width 76 -height 23 -anchor nw -bordermode ignore
place .dockit.cllbl \
-x 5 -y 30 -width 76 -height 23 -anchor nw -bordermode ignore
place .dockit.comlbl \
-x 5 -y 55 -width 76 -height 23 -anchor nw -bordermode ignore
place .dockit.instent \
-x 85 -y 5 -width 216 -height 22 -anchor nw -bordermode ignore
place .dockit.clent \
-x 85 -y 30 -width 216 -height 22 -anchor nw -bordermode ignore
place .dockit.coment \
-x 85 -y 55 -width 216 -height 22 -anchor nw -bordermode ignore
place .dockit.create \
-x 5 -y 80 -width 77 -height 36 -anchor nw -bordermode ignore
place .dockit.exit \
-x 230 -y 80 -width 72 -height 36 -anchor nw -bordermode ignore
place .dockit.grab \
-x 80 -y 80 -width 77 -height 36 -anchor nw -bordermode ignore
place .dockit.help \
-x 155 -y 80 -width 77 -height 36 -anchor nw -bordermode ignore
############
# Bindings #
############
bind all <Leave> {message ""}
bind .dockit.instlbl <Enter> {message "Instance name goes here.
(the 1st string of WM_CLASS)"}
bind .dockit.instent <Enter> {message "Instance name goes here.
(the 1st string of WM_CLASS)"}
bind .dockit.cllbl <Enter> {message "Class name goes here.
(the 2nd string of WM_CLASS)"}
bind .dockit.clent <Enter> {message "Class name goes here.
(the 2nd string of WM_CLASS)"}
bind .dockit.comlbl <Enter> {message "The command to execute goes here.
(all of WM_COMMAND)"}
bind .dockit.coment <Enter> {message "The command to execute goes here.
(all of WM_COMMAND)"}
bind .dockit.create <Enter> {message "Create you custom AppIcon."}
bind .dockit.exit <Enter> {message "Exit Dockit!"}
bind .dockit.help <Enter> {message "Help with creating AppIcons,
and for these commands."}
bind .dockit.grab <Enter> {message "Grab AppInfo from a running App."}
###################
# Actual Code #
###################
proc message {message} {
.dockit.msgbar configure -text $message
}
proc docreate {} {
global Version
global instance
global class
global command
if {$command == ""} {
tk_dialog .error "DockIt ${Version}: ERROR" \
"You must supply a command line. Otherwise your icon would do nothing!" \
"" "" "Doh!"
} else {
set insttmp $instance
set classtmp $class
set commandtmp $command
if {$insttmp == ""} { set insttmp "dockit" }
if {$classtmp == ""} { set classtmp "DockedApp" }
toplevel .$insttmp -class $classtmp
wm command .$insttmp "$commandtmp"
wm group .$insttmp .$insttmp
label .$insttmp.l1 -text "
Great! Your new App-Icon should be finished now.
once you have dragged it to the Dock, Click Finish.
If your Icon doesn't Dock, or does not appear,
Try again. If problems persist, see Dockit's Help."
button .$insttmp.b1 -text "Finish" -command "destroy .$insttmp"
pack .$insttmp.l1
pack .$insttmp.b1
wm title .$insttmp "Dockit ${Version}: Confirmation"
}
}
proc dohelp {} {
global Version
set HLPTXT { Dockit V1.2
General Info:
Dockit is a tool designed to provide the ability to Dock
poorly coded programs within WindowMaker.
This is not a 100% accurate solution. It was not designed to be.
It will however, generate a dockable icon 99% of the time.
for that other 1%, you will need to edit by hand.
Troubleshooting:
Error: 'window name starts with an upper-case letter':
This is a limitation of Tcl/Tk.
window/pathnames cannot start with an uppercase letter.
This behavior is most noticable in Netscape's Navigator.
It's instance is 'Navigator'
A work-around to this limitation, is to double-define your App
settings. (ex:'navigator', and 'Navigator')
Error: couldn't execute "xprop": no such file or directory
This means that /usr/X11R6/bin (or its equivilent)
is not defined in your path.
You must add this to your path.
AppIcon does not appear as it should:
This could happen for a number of reasons.
A: You have NoAppIcon defined for that particular App.
B: One word: El Ni~no
App Closes, but Dots do not appear/ Cannot remove Icon from the Dock:
This is the result of a VERY poorly coded App.
As far as WIndowMaker can tell, the program is still running.
The only real fix for this, is CTRL + ALT + BACKSPACE
}
toplevel .userhelp -class Dockit
wm group .userhelp .dockit
wm iconname .userhelp "Dockit HELP"
wm focusmodel .userhelp passive
wm geometry .userhelp 456x635
wm maxsize .userhelp 1265 1265
wm minsize .userhelp 1 1
wm overrideredirect .userhelp 0
wm resizable .userhelp 1 1
wm deiconify .userhelp
wm title .userhelp "Dockit ${Version}: HELP"
label .userhelp.text \
-anchor nw -justify left -borderwidth 1 \
-text $HLPTXT
place .userhelp.text \
-x 0 -y 0 -anchor nw -bordermode ignore
}
proc dograb {} {
global xprop
global class
global instance
global command
catch "open ~/GNUstep/.AppInfo/xprop1 w+" m1
exec ${xprop} >@ $m1
seek $m1 0
set tmpmsg [read $m1]
set tmpmsg [split $tmpmsg \n]
close $m1
#Make sure we are the leader
foreach junk $tmpmsg {
if {[string match "WM_TRANSIENT_FOR(WINDOW): window id \# *" $junk]} {
dograb+ [lindex $junk 4] NNNN
return 1
} elseif {[string match "*window id # of group leader: *" $junk]} {
dograb+ [lindex $junk 6] NNNN
return 1
}
}
set tclass [lindex $tmpmsg [lsearch -glob $tmpmsg *WM_CLASS*]]
set tclass [split $tclass ,]
set class [string trim [lindex $tclass 1] \ \"]
set instance [string tolower \
[string trim [lindex [lindex $tclass 0] 2] \ \"]]
set tcom [lindex $tmpmsg [lsearch -glob $tmpmsg *WM_COMMAND*]]
set tcom [split [lindex $tcom 2] \,]
set tcom [split [join $tcom] \"]
set command [join [join $tcom]]
}
proc dograb+ {winid sourcewin} {
global xprop
global class
global instance
global command
catch "open ~/GNUstep/.AppInfo/xprop1 w+" m1
exec ${xprop} -id $winid >@ $m1
seek $m1 0
set tmpmsg [read $m1]
set tmpmsg [split $tmpmsg \n]
# Make sure we arent hitting a Loop, where we show ourself as
# The group leader.
if { ![string match $sourcewin $winid]} {
# recurse to the toplevel leader.
foreach junk $tmpmsg {
if {[string match "WM_TRANSIENT_FOR(WINDOW): window id # *" $junk]} {
dograb+ [lindex $junk 4] $winid
return 1
} elseif {[string match "*window id # of group leader: *" $junk]} {
dograb+ [lindex $junk 6] $winid
return 1
}
}
}
set tclass [lindex $tmpmsg [lsearch -glob $tmpmsg *WM_CLASS*]]
set tclass [split $tclass ,]
set class [string trim [lindex $tclass 1] \ \"]
set instance [string tolower \
[string trim [lindex [lindex $tclass 0] 2] \ \"]]
set tcom [lindex $tmpmsg [lsearch -glob $tmpmsg *WM_COMMAND*]]
set tcom [split [lindex $tcom 2] \,]
set tcom [split [join $tcom] \"]
set command [join [join $tcom]]
close $m1
}

203
util/wm-oldmenu2new Executable file
View File

@@ -0,0 +1,203 @@
#!/bin/sh
#
# wm-oldmenu2new: script to convert from old-style WindowMaker
# menu file to the new PropertyList style of the WMRootMenu.
#
# Note: ex in all the Linux systems I've used is badly
# broken, except for nex. perl can be relied on however.
# Re-written to use perl.
#
# Local dependencies:
# None.
#
# Authors: Luke Kendall, Toby J Sargeant
#
# Copyright waived; no warranty provided.
#
GLW=GNUstep/Library/WindowMaker
GD=GNUstep/Defaults
WLW=$HOME/$GLW
WD=$HOME/$GD
MYNAME=`basename $0`
USAGE="usage: $MYNAME [menu-file-specifier]
E.g. $MYNAME menu.pt
or $MYNAME pt
the default menu if no arguments are given is the English one, 'menu'."
#
# Process arguments - work out which language menu we're converting.
# I am *assuming* that foreign language locales have the .lang suffix
# attached to the WMRootMenu name. I hope that's right!
#
OLD_MENU=menu
NEW_MENU=WMRootMenu
if [ $# = 1 ]
then
if [ -s "$WLW/menu.$1" ]
then
OLD_MENU="menu.$1"
NEW_MENU="WMRootMenu.$1"
elif [ -s "$WLW/$1" ]
then
OLD_MENU="$1"
x=`expr "$1" : "menu\.\(.*\)"`
[ "x$x" != "x" ] && NEW_MENU="WMRootMenu.$x"
else
echo "$MYNAME: $WLW/$1 does not exist" >&2
exit 1
fi
elif [ $# != 0 ]
then
echo "$USAGE" >&2
exit 1
fi
#
# For working out what cc is installed
#
which1()
{
oldpath=$PATH
PATH=/bin:/usr/bin:/usr/local/bin
IFS=":"
for j in $oldpath
do
test -x $j/$1 && test ! -d $j/$1 && echo $j/$1 && return 0
done
IFS=" "
return 1
}
#
# Expand macros if necessary.
# Create a temp copy of the menu file to edit to turn into the new.
#
T=/tmp/wmmenu$$
echo "Converting $GLW/$OLD_MENU --> $GD/$NEW_MENU"
cd $WLW || exit 1
if [ ! -s "$OLD_MENU" ]
then
echo "$MYNAME: $WLW/$OLD_MENU does not exist" >&2
exit 1
fi
#
# Always pre-process, to join lines split with \, and to strip comments.
# Not to mention the main purpose, include & process wmmacros if used.
#
set -e
CC=`which1 cc`
[ "x$CC" = "x" ] && CC=`which1 gcc`
[ "x$CC" = "x" ] && "$MYNAME: no cc, gcc found - can't preprocess" >&2 && exit 1
cp $OLD_MENU $T-c
#
# Given the set -e, the exit 1 shouldn't be needed. But it is, on my NeXT!
#
$CC -E -I. $T-c > $T+c || exit 1
sed '/^#/d;/^[ ]*$/d' $T+c > $T
rm $T-c $T+c
set +e
#
# This is the interesting bit. Edit the old style menu and
# convert into new style property-list menu.
#
perl - $T <<-'EOF' > $T-p
$v=chr(22);
for (<>) {
push @foo,$_;
}
for (@foo) {
s/\s*$//;
s/^(\s*)"*(Workspaces*)"*\s\s*(WORKSPACE_MENU)/\1(\2, \3),/;
s/^(\s*)("[^"]*")\s+MENU/\1($v\n\1\2,/;
push @foo2,split "\n";
}
@foo=();
for (@foo2) {
s/^(\s*)"([^"]*)"\s\s*END/\1),/;
s/^(\s*)"([^"]*)"\s\s*EXEC\s\s*(.*)$/\1($v\n\1"\2",$v\n\1EXEC,$v\n\1"\3"$v\n\1),/;
push @foo,split "\n";
}
@foo2=();
for (@foo) {
s/^(\s*)"([^"]*)"\s\s*OPEN_MENU\s\s*(.*)$/\1($v\n\1"\2",$v\n\1OPEN_MENU,$v\n\1"\3"$v\n\1),/;
push @foo2,split "\n";
}
@foo=();
for (@foo2) {
s/^(\s*)([^ ]*)\s\s*MENU/\1($v\n\1"\2",/;
push @foo,split "\n";
}
@foo2=();
for (@foo) {
s/^(\s*)([^ ]*)\s\s*END/\1),/;
s/^(\s*)([^ ]*)\s\s*EXEC\s\s*(.*)$/\1($v\n\1"\2",$v\n\1EXEC,$v\n\1"\3"$v\n\1),/;
push @foo2,split "\n";
}
@foo=();
for (@foo2) {
s/^(\s*)([^ ]*)\s\s*OPEN_MENU\s\s*(.*)$/\1($v\n\1"\2",$v\n\1OPEN_MENU,$v\n\1"\3"$v\n\1),/;
push @foo,split "\n";
}
@foo2=();
for (@foo) {
s/ WITH / QQQjjQQQ /;
s/^(\s*)"([^"]*)"\s\s*([A-Z_][A-Z_]*)$/\1("\2", \3),/;
s/^(\s*)"([^"]*)"\s+([A-Z_][A-Z_]*)\s\s*(.*)$/\1("\2", \3, \4),/;
s/"(.*".*)"/JJJqqJJJ\1JJJqqJJJ/;
/JJJqqJJJ/ && s/"/\\"/g;
s/JJJqqJJJ/"/g;
s/ QQQjjQQQ / WITH /;
print "$_\n";
}
EOF
mv $T-p $T
#
# Now strip off spurious commas from lines like:
# ),
# )
# since comma is a property separator, not terminator. Sigh.
# Also correct for another problem - Linux ex's require the CTRL-V
# above; a real vi/ex doesn't; so we have to strip out any spurious
# CTRL-V characters if we're using a real ex:
#
sed 's///g' $T | awk '
{
if (last_line != null)
{
if ((last_line ~ /,$/) && ($0 ~ /^[ ]*\)/))
print substr(last_line, 0, length(last_line)-1)
else
print last_line
}
last_line = $0
}
END {
if (last_line != null)
{
if (last_line ~ /,$/)
print substr(last_line, 0, length(last_line)-1)
else
print last_line
}
}
' > $WD/$NEW_MENU.new || exit 1
rm $T
#
# Now install it.
#
cd $WD
if [ -s $NEW_MENU ]
then
echo "Preserving $NEW_MENU as $NEW_MENU.sav in $WD"
mv $NEW_MENU $NEW_MENU.sav
fi
mv $NEW_MENU.new $NEW_MENU && echo "Created new $WD/$NEW_MENU"

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# Install WindowMaker for the current user
# Install Window Maker for the current user
#
# directory where system wide configuration is stored
@@ -16,9 +16,22 @@ BINDIR="#bindir#"
make_script() {
ISCRIPT=$1
echo '#!/bin/sh' >> $ISCRIPT
echo '# WindowMaker Default .xinitrc' >> $ISCRIPT
echo "exec $BINDIR/wmaker" >> $ISCRIPT
cat << EOF >> $ISCRIPT
#!/bin/sh
# Window Maker default X session startup script
PATH="\$PATH:$BINDIR"
# If you login from xdm, uncomment this to make error messages appear
# in the console window.
#
# tail -f $HOME/.xsession-errors > /dev/console
exec wmaker
EOF
chmod +rx $ISCRIPT
}
@@ -51,7 +64,7 @@ echo "Installing WindowMaker $VERSION for current user..."
if [ ! -d $GLOBALDIR ]; then
echo "Could not find global configurations files"
echo "Make sure you've installed WindowMaker correctly"
echo "Make sure you've installed Window Maker correctly"
exit 1
fi
@@ -175,6 +188,14 @@ else
fi
if [ ! -d "$GSDIR/Library/WindowMaker/SoundSets" ]; then
echo "Creating sound set library $GSDIR/Library/WindowMaker/SoundSets"
mkdir $GSDIR/Library/WindowMaker/SoundSets
else
echo "Default SoundSets directory already exists. Skipping..."
fi
echo "Copying default menu configuration files..."
FILES=`(cd $GLOBALDIR;ls -1 menu* plmenu wmmacros)`
all=""
@@ -206,11 +227,28 @@ chmod +rx $GSDIR/Library/WindowMaker/autostart
DATE=`date +%m%d%H%M`
show_end_message() {
echo
echo "Installation Finished"
echo
echo "There are menus in 2 different file formats. The plain text format and"
echo "the property list format. The plain text format is more flexible, but"
echo "the menu in the property list format can be edited graphically. The"
echo "menu that will be used by default is the plain text. Read"
echo "$GSDIR/Library/WindowMaker/README for information on how to change it."
}
trap "show_end_message;exit" 2
echo
echo "Now the .xinitrc, .Xclients or .xsession script must be updated so that"
echo "it calls wmaker when you start an X session."
echo "Type the name of the file that must be changed (normally .xinitrc)."
echo "If the file already exists, it will be backed up with a .old.$DATE extension"
echo "If you want to edit it by hand, hit <Control>-C now."
read file
if test "x$file" = "x"; then
@@ -224,12 +262,5 @@ fi
make_script $USERDIR/$file
echo "Installation Finished"
echo
echo "There are menus in 2 different file formats. The plain text format and"
echo "the property list format. The plain text format is more flexible, but"
echo "the menu in the property list format can be edited graphically. The"
echo "menu that will be used by default is the plain text. Read"
echo "$GSDIR/Library/WindowMaker/README for information on how to change it."
show_end_message

View File

@@ -21,7 +21,6 @@
* USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -49,7 +48,7 @@
char *ProgName;
#ifdef at_one_step_from_the_trash
/* Alfredo please take a look at this function. I don't like the way
* it sends the XKillClient. Should it interfere this way with the rest?
* This was added by the patch to allow the transparent background for Eterm.
@@ -76,25 +75,34 @@ setPixmapProperty(Pixmap pixmap, Display *dpy, Window root)
XGetWindowProperty(dpy, root, prop, 0L, 1L, True, AnyPropertyType,
&type, &format, &length, &after, &data);
/* I think this is OK -Alfredo */
if ((type == XA_PIXMAP) && (format == 32) && (length == 1)) {
XKillClient(dpy, *((Pixmap *)data));
}
XDeleteProperty(dpy, root, prop);
/* I don't understand this one. The atom is *always* created in
the previous XInternAtom() -Alfredo */
prop = XInternAtom(dpy, "_XROOTPMAP_ID", True);
if (prop == None)
return;
/* Now add the new one. We use PropModeAppend because PropModeReplace
doesn't seem to work if there isn't already a property there. */
/* Must be something wrong with this code.
* Anyways, better do a XGrabServer() between the XDeleteProperty() and
* this XChangeProperty() if things will be this way. -Alfredo */
XChangeProperty(dpy, root, prop, XA_PIXMAP, 32, PropModeAppend,
(unsigned char *) &pixmap, 1);
XFlush(dpy);
/* Potential resource leak. Must check the rest of the
* program for other resources that rely on XCloseDisplay() to
* free them. -Alfredo */
XSetCloseDownMode(dpy, RetainPermanent);
XFlush(dpy);
}
#endif
void*
wmalloc(size_t size)
@@ -235,6 +243,11 @@ getPixmapPath(char *domain)
}
int
main(int argc, char **argv)
{
@@ -361,7 +374,7 @@ main(int argc, char **argv)
execlp(program, program, domain, "WorkspaceBack", value, NULL);
printf("%s: warning could not run \"%s\"\n", ProgName, program);
/* Do not exit. At least try to put the image in the background */
/* Won't this waste CPU for nothing? We're going to be called again,
/* Won't this waste CPU for nothing? We're going to be called again,
* anyways. -Alfredo */
/* If it fails to update the WindowMaker domain with "wdwrite" we
* won't be called again, because Window Maker will not notice any
@@ -400,7 +413,7 @@ main(int argc, char **argv)
rcontext = RCreateContext(dpy, screen_number, &rattr);
if (!rcontext) {
printf("could not initialize graphics library context: %s\n",
RErrorString);
RMessageForError(RErrorCode));
exit(1);
}
@@ -418,7 +431,7 @@ main(int argc, char **argv)
#endif
if (!image) {
printf("could not load image %s:%s\n", image_name, RErrorString);
printf("could not load image %s:%s\n", image_name, RMessageForError(RErrorCode));
exit(1);
}
@@ -433,7 +446,7 @@ main(int argc, char **argv)
exit(1);
}
RDestroyImage(image);
image = tmp;
image = tmp;
} else if (style==WTP_CENTER && (image->width!=scr_width
|| image->height!=scr_height)) {
RColor color;
@@ -445,13 +458,13 @@ main(int argc, char **argv)
tmp = RMakeCenteredImage(image, scr_width, scr_height, &color);
if (!tmp) {
printf("could not create centered image: %s\n", image_name);
exit(1);
exit(1);
}
RDestroyImage(image);
image = tmp;
}
#ifdef DEBUG
gettimeofday(&timev, NULL);
gettimeofday(&timev, NULL);
t2 = (double)timev.tv_sec + (((double)timev.tv_usec)/1000000);
total = t2 - t1;
printf("scale image in %f sec\n", total);
@@ -470,7 +483,9 @@ main(int argc, char **argv)
#endif
RDestroyImage(image);
if (secretBuffer==None) {
#ifdef at_one_step_from_the_trash
setPixmapProperty(pixmap, dpy, root_win);
#endif
XSetWindowBackgroundPixmap(dpy, root_win, pixmap);
XClearWindow(dpy, root_win);
} else {

View File

@@ -20,7 +20,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#define LINESIZE (4*1024)
@@ -29,7 +31,16 @@
void
help(char *progn)
{
printf("usage: %s [-cutbuffer number] [filename]\n", progn);
fprintf
(
stderr,
"usage: %s [options] [filename]\n"
" -display display\n"
" -cutbuffer number\n"
" -nolimit\n"
" -clearselection\n",
progn
);
}
static int
@@ -48,8 +59,12 @@ main(int argc, char **argv)
char *filename=NULL;
FILE *file=stdin;
char *buf=NULL;
char *display_name="";
int l=0;
int buf_len = 0;
int limit_check = 1;
int clear_selection = 0;
for (i=1; i<argc; i++) {
if (argv[i][0]=='-') {
if (argv[i][1]=='h') {
@@ -59,19 +74,30 @@ main(int argc, char **argv)
if (i<argc-1) {
i++;
if (sscanf(argv[i],"%i", &buffer)!=1) {
printf("%s: could not convert \"%s\" to int\n",
fprintf(stderr, "%s: could not convert \"%s\" to int\n",
argv[0], argv[i]);
exit(1);
}
if (buffer<0 || buffer > 7) {
printf("%s: invalid buffer number %i\n", argv[0],
buffer);
fprintf(stderr, "%s: invalid buffer number %i\n",
argv[0], buffer);
exit(1);
}
} else {
help(argv[0]);
exit(1);
}
} else if (strcmp(argv[i], "-display")==0) {
if (i < argc-1) {
display_name = argv[++i];
} else {
help(argv[0]);
exit(1);
}
} else if (strcmp(argv[i],"-clearselection")==0) {
clear_selection = 1;
} else if (strcmp(argv[i],"-nolimit")==0) {
limit_check = 0;
} else {
help(argv[0]);
exit(1);
@@ -90,10 +116,11 @@ main(int argc, char **argv)
}
}
dpy = XOpenDisplay("");
dpy = XOpenDisplay(display_name);
XSetErrorHandler(errorHandler);
if (!dpy) {
printf("%s: could not open display\n", argv[0]);
fprintf(stderr, "%s: could not open display \"%s\"\n", argv[0],
XDisplayName(display_name));
exit(1);
}
if (buffer<0) {
@@ -105,34 +132,61 @@ main(int argc, char **argv)
char tmp[LINESIZE+2];
int nl=0;
if (!fgets(tmp, LINESIZE, file)) {
/*
* Use read() instead of fgets() to preserve NULs, since
* especially since there's no reason to read one line at a time.
*/
if ((nl = fread(tmp, 1, LINESIZE, file)) <= 0) {
break;
}
nl = strlen(tmp);
if (!buf)
nbuf = malloc(l+nl+1);
else
nbuf = realloc(buf, l+nl+1);
if (buf_len == 0) {
nbuf = malloc(buf_len = l+nl+1);
}
else {
if (buf_len < l+nl+1) {
/*
* To avoid terrible performance on big input buffers,
* grow by doubling, not by the minimum needed for the
* current line.
*/
buf_len = 2 * buf_len + nl + 1;
nbuf = realloc(buf, buf_len);
}
else {
nbuf = buf;
}
}
if (!nbuf) {
printf("%s: out of memory\n", argv[0]);
fprintf(stderr, "%s: out of memory\n", argv[0]);
exit(1);
}
buf=nbuf;
if (l==0) {
strcpy(buf,tmp);
} else {
strcat(buf, tmp);
}
/*
* Don't strcat, since it would make the algorithm n-squared.
* Don't use strcpy, since it stops on a NUL.
*/
memcpy(buf+l, tmp, nl);
l+=nl;
if (l>=MAXDATA) {
printf("%s: too much data in input\n", argv[0]);
if (limit_check && l>=MAXDATA) {
fprintf
(
stderr,
"%s: too much data in input - more than %d bytes\n"
" use the -nolimit argument to remove the limit check.\n",
argv[0], MAXDATA
);
exit(1);
}
}
if (buf)
XStoreBuffer(dpy, buf, l, buffer);
if (clear_selection) {
XSetSelectionOwner(dpy, XA_PRIMARY, None, CurrentTime);
}
if (buf) {
XStoreBuffer(dpy, buf, l, buffer);
}
XFlush(dpy);
XCloseDisplay(dpy);
exit(1);
exit(buf == NULL || errno != 0);
}

View File

@@ -17,20 +17,140 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "../src/config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#define LINESIZE (4*1024)
#define MAXDATA (4*1024*1024)
void
help(char *progn)
{
printf("usage: %s [-cutbuffer number]\n", progn);
fprintf(stderr,
"usage: %s [options]\n"
" -display display-name\n"
" -cutbuffer number\n"
" -selection [selection-name]\n"
, progn);
}
Time
getTimestamp(Display *dpy, Window win)
{
XEvent ev;
/* So we do this trickery to get a time stamp:
*
* 1. Grab the server because we are paranoid and don't want to
* get in a race with another instance of wxpaste being ran at the
* same time.
*
* 2. Set a dummy property in our window.
*
* 3. Get the PropertyNotify event and get it's timestamp.
*
* 4. Ungrab the server.
*/
XSelectInput(dpy, win, PropertyChangeMask);
/* Generate a PropertyNotify event */
XStoreName(dpy, win, "shit");
/* wait for the event */
while (1) {
XNextEvent(dpy, &ev);
if (ev.type == PropertyNotify)
break;
}
return ev.xproperty.time;
}
char*
fetchSelection(Display *dpy, char *selection, char *progName)
{
Atom selatom = XInternAtom(dpy, selection, False);
Atom clipatom = XInternAtom(dpy, "CLIPBOARD", False);
Time now;
XEvent ev;
Window win;
int ok = 0;
struct timeval timeout;
fd_set fdset;
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1, 1,
0, 0, 0);
/*
* The ICCCM says that we can't pass CurrentTime as the timestamp
* for XConvertSelection(), but we don't have anything to use as
* a timestamp...
*/
now = getTimestamp(dpy, win);
XConvertSelection(dpy, selatom, XA_STRING, clipatom, win, now);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
/* wait for the convertion */
while (0) {
int res;
if (XPending(dpy)==0) {
FD_ZERO(&fdset);
FD_SET(ConnectionNumber(dpy), &fdset);
res = select(ConnectionNumber(dpy)+1, &fdset, NULL, NULL,
&timeout);
if (res <= 0) {
ok = 0;
break;
}
}
if (res > 0 || XPending(dpy) > 0) {
XNextEvent(dpy, &ev);
if (ev.type == SelectionNotify && ev.xany.window == win) {
ok = 1;
break;
}
}
}
/* if success, return the data */
if (ok) {
Atom rtype;
int bits;
unsigned long len, bytes;
unsigned char *data;
if (XGetWindowProperty(dpy, win, clipatom, 0, MAXDATA/4, False,
XA_STRING, &rtype, &bits, &len, &bytes, &data)!=0)
return NULL;
if ((rtype!=XA_STRING) || (bits!=8)) {
return NULL;
} else {
return (char*)data;
}
}
return NULL;
}
int
main(int argc, char **argv)
{
@@ -38,23 +158,39 @@ main(int argc, char **argv)
int i, l;
int buffer=0;
char *buf;
int status;
char *display_name="";
char *selection_name=NULL;
for (i=1; i<argc; i++) {
if (argv[i][0]=='-') {
if (argv[i][1]=='h') {
help(argv[0]);
exit(0);
} else if (strcmp(argv[i],"-selection")==0) {
if (i<argc-1) {
selection_name = argv[++i];
} else {
selection_name = "PRIMARY";
}
} else if (strcmp(argv[i],"-display")==0) {
if (i<argc-1) {
display_name = argv[++i];
} else {
help(argv[0]);
exit(0);
}
} else if (strcmp(argv[i],"-cutbuffer")==0) {
if (i<argc-1) {
i++;
if (sscanf(argv[i],"%i", &buffer)!=1) {
printf("%s: could not convert \"%s\" to int\n",
fprintf(stderr, "%s: could not convert \"%s\" to int\n",
argv[0], argv[i]);
exit(1);
}
if (buffer<0 || buffer > 7) {
printf("%s: invalid buffer number %i\n", argv[0],
buffer);
fprintf(stderr, "%s: invalid buffer number %i\n",
argv[0], buffer);
exit(1);
}
} else {
@@ -67,15 +203,32 @@ main(int argc, char **argv)
exit(1);
}
}
dpy = XOpenDisplay("");
dpy = XOpenDisplay(display_name);
if (!dpy) {
printf("%s: could not open display\n", argv[0]);
fprintf(stderr, "%s: could not open display \"%s\"\n", argv[0],
XDisplayName(display_name));
exit(1);
}
buf=XFetchBuffer(dpy, &l, buffer);
if (buf)
printf("%s", buf);
if (selection_name) {
buf = fetchSelection(dpy, selection_name, argv[0]);
} else {
buf = NULL;
}
if (buf == NULL) {
buf = XFetchBuffer(dpy, &l, buffer);
}
if (buf == NULL) {
status = 1;
} else {
if (write(STDIN_FILENO, buf, l) == -1)
status = errno;
else
status = 0;
}
XCloseDisplay(dpy);
exit(1);
exit(status);
}