You are not logged in.

#1 2011-09-20 02:40:30

SuperRaWR
Member
From: Sylvan Lake, AB
Registered: 2011-09-18
Posts: 9
Website

[Solved] Java Window Focus Problem (Minecraft)

Hello everyone!  I have a fairly sincere problem with Minecraft, and I'm totally unsure if it's Java, or Gnome.  Basically, Minecraft has a feature that when the window loses focus, it pauses the game (when in single player) and brings up a menu (single player or multiplayer) where you have to click a "Back to game" button.  I can play in the game, open this menu manually by hitting Escape and close it as normal.  As soon as my window loses focus, and I switch back to it, I can't seem to close this menu.  It's as if it's not being registered as the window in focus.

I'm wondering if anyone else has encountered this sort of problem before?

I'm using Gnome 3, with Gnome Shell disabled.  I've tried with both Metacity and Compiz for Window Managers.
Also, I'm using the official Oracle JRE.

Last edited by SuperRaWR (2011-09-22 18:10:25)

Offline

#2 2011-09-20 08:25:06

mah0
Member
Registered: 2011-04-21
Posts: 47

Re: [Solved] Java Window Focus Problem (Minecraft)

Have you tried updating lwjgl?
You can do it manualy or simply use this script:

#!/bin/sh
PATH=/bin:/usr/bin

# Automatically upgrade Minecraft's version of LWJGL under Linux.
# 
# If you have wget, you can run this script directly without any further
# trouble: 
# ./upgrade-lwjgl.sh
#
# Otherwise, you'll need to provide a copy of LWJGL, like so:
# ./upgrade-lwjgl.sh lwjgl-2.7.1
# where lwjgl-2.7.1 is a directory. You can also give a ZIP file if you wish.
# 
# You can find LWJGL at http://lwjgl.org/download.php
# Pick up the latest stable version.
#
# This script tries to be as careful as possible. The script uses a temporary
# directory for replacing files, so it will only affect your Minecraft install
# if everything has gone correctly.
#
# If you need to revert this process, just delete the ~/.minecraft/bin
# directory, and rename ~/.minecraft/bin.~1~ to ~/.minecraft/bin.
#
# Good luck!
# Aaron Faanes <dafrito@gmail.com>

die() {
	echo $*
	exit 1
}

tmp=/tmp/lwjgl-upgrade.$$
mkdir -p $tmp
trap 'rm -rf $tmp' EXIT

MINECRAFT_DIR=$HOME/.minecraft
[ -d $MINECRAFT_DIR/bin ] || die "Minecraft bin directory was not found. Run it first: $MINECRAFT_DIR"

is_lwjgl_dir() {
	local testdir=${*:-"$LWJGL_DIR"}
	[ -d "$testdir/native/linux" ] && [ -d "$testdir/jar" ]
}

if [ $# -gt 0 ]; then
	LWJGL_DIR="$*"
	if [ -f "$LWJGL_DIR" ]; then
		# It's a file, so try to extract it
		lwjgl_file=$*
		LWJGL_DIR=$tmp/lwjgl
		mkdir -p $LWJGL_DIR || die "Failed to create extracting directory"
		case "$LWJGL_DIR" in
			*.zip) unzip $lwjgl_file -d $LWJGL_DIR || die "Failed to unzip $lwjgl_file" ;;
			*.tar) tar xv -C $LWJGL_DIR -f $lwjgl_file || die "Failed to untar $lwjgl_file" ;;
			*.tar.gz) tar zxv -C $LWJGL_DIR -f $lwjgl_file || die "Failed to untar $lwjgl_file" ;;
			*) die "Unsupported filetype; you must extract it manually: $lwjgl_file"
		esac
	elif ! is_lwjgl_dir; then
		die "Unrecognized argument: $*"
	fi
fi

search_directories() {
	local root=$*
	for repodir in $root $root/lwjgl $root/lwjgl-2.*; do
		if is_lwjgl_dir $repodir; then
			LWJGL_DIR=$repodir
			break
		fi
	done
}

if ! is_lwjgl_dir; then
	search_directories .
fi

if ! is_lwjgl_dir; then
	LWJGL_DIR=$tmp/lwjgl
	url="http://sourceforge.net/projects/java-game-lib/files/Official%20Releases/LWJGL%202.7.1/lwjgl-2.7.1.zip/download"
	wget -O $tmp/lwjgl.zip $url &&
	unzip $tmp/lwjgl.zip -d $LWJGL_DIR &&
	search_directories $LWJGL_DIR
fi

if ! is_lwjgl_dir; then
	echo "Failed to find a valid LWJGL directory" 1>&2
	echo "Download from http://lwjgl.org/download.php and specify on the command line" 1>&2
	echo "Example: ./upgrade-lwjgl.sh lwjgl-2.7.1.zip" 1>&2
	die
fi

stage=$tmp/bin
cp -r $MINECRAFT_DIR/bin $stage || die "Failed to create staging directory: $stage"

do_replace() {
	srcdir=$1
	[ -d $srcdir ] || die "Source directory was not found: $srcdir"
	shift
	destdir=$1
	[ -d $destdir ] || die "Destination directory was not found: $destdir"
	shift
	for file; do
		src=$srcdir/$file
		[ -f $src ] || die "Source file was not found: $src"
		dest=$destdir/$file
		cp -v $src $dest || die "Failed to replace $dest"
	done
}

do_replace $LWJGL_DIR/jar $stage \
	lwjgl.jar \
	lwjgl_util.jar \
	jinput.jar

do_replace $LWJGL_DIR/native/linux $stage/natives \
	libjinput-linux.so \
	liblwjgl.so \
	libopenal.so \
	libjinput-linux64.so \
	liblwjgl64.so \
	libopenal64.so

mv -v --backup=t $stage $MINECRAFT_DIR || die "Failed to move stage to $MINECRAFT_DIR"
echo "Upgrading LWJGL was successful. Backup(s) exist at:" $MINECRAFT_DIR/bin.*

Last edited by mah0 (2011-09-20 08:25:30)

Offline

#3 2011-09-22 18:10:13

SuperRaWR
Member
From: Sylvan Lake, AB
Registered: 2011-09-18
Posts: 9
Website

Re: [Solved] Java Window Focus Problem (Minecraft)

I have updated my LWJGL before posting this.

It appears as though by using the OpenJDK instead of the official JRE, the problem is fixed!  I don't seem to have any problems with OpenJDK either.

pacman -S openjdk

Offline

Board footer

Powered by FluxBB