diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-09-08 12:36:10 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-09-08 12:36:10 +0000 |
commit | abbe4a3de13983cbcab7c62f08457fccd6aa9bee (patch) | |
tree | 904217b046d2a81dc02a77c7af6f9debad3bcb32 | |
parent | 56aa33e8cf2d62b12f4c56537d13905e6cafca72 (diff) | |
download | drakx-abbe4a3de13983cbcab7c62f08457fccd6aa9bee.tar drakx-abbe4a3de13983cbcab7c62f08457fccd6aa9bee.tar.gz drakx-abbe4a3de13983cbcab7c62f08457fccd6aa9bee.tar.bz2 drakx-abbe4a3de13983cbcab7c62f08457fccd6aa9bee.tar.xz drakx-abbe4a3de13983cbcab7c62f08457fccd6aa9bee.zip |
fixing keyboard focus during install:
- removed aewm-drakx which doesn't work nicely
- fix @interactive::objects handling
(don't push non pop_it windows, ensure destroyed windows are removed)
- ensure XSetInputFocus is called on $::WizardWindow
-rw-r--r-- | perl-install/Makefile.config | 2 | ||||
-rw-r--r-- | perl-install/install_steps_gtk.pm | 4 | ||||
-rw-r--r-- | perl-install/ugtk2.pm | 25 | ||||
-rw-r--r-- | tools/Makefile | 2 | ||||
-rw-r--r-- | tools/aewm-drakx/Makefile | 17 | ||||
-rw-r--r-- | tools/aewm-drakx/README | 53 | ||||
-rw-r--r-- | tools/aewm-drakx/aewm-drakx.c | 50 | ||||
-rw-r--r-- | tools/aewm-drakx/aewm.h | 34 | ||||
-rw-r--r-- | tools/aewm-drakx/client.c | 122 | ||||
-rw-r--r-- | tools/aewm-drakx/events.c | 106 | ||||
-rw-r--r-- | tools/aewm-drakx/misc.c | 29 |
11 files changed, 24 insertions, 420 deletions
diff --git a/perl-install/Makefile.config b/perl-install/Makefile.config index 2dd49d9db..082e21b79 100644 --- a/perl-install/Makefile.config +++ b/perl-install/Makefile.config @@ -24,7 +24,7 @@ STAGE2 = $(ROOTDEST)/Mandrake/base/mdkinst_stage2 BASE = $(ROOTDEST)/Mandrake/base DESTREP4PMS = $(DEST)$(REP4PMS) PERL = perl -LOCALFILES = $(patsubst %, ../tools/%,ddcprobe/ddcxinfos aewm-drakx/aewm-drakx serial_probe/serial_probe xhost+) +LOCALFILES = $(patsubst %, ../tools/%,ddcprobe/ddcxinfos serial_probe/serial_probe xhost+) DIRS = c Newt resize_fat #po CFLAGS = -Wall override CFLAGS += -pipe diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm index 9c5b01ac6..d38476972 100644 --- a/perl-install/install_steps_gtk.pm +++ b/perl-install/install_steps_gtk.pm @@ -65,9 +65,7 @@ sub new($$) { sleep 1; log::l("Server died"), return 0 if !$ok; if (c::Xtest($wanted_DISPLAY)) { - if (-x '/usr/bin/aewm-drakx') { - fork() || exec("aewm-drakx") || c::_exit(0); - } + $ugtk2::force_focus = 1; return 1; } } diff --git a/perl-install/ugtk2.pm b/perl-install/ugtk2.pm index 4f434ce52..24d0f2210 100644 --- a/perl-install/ugtk2.pm +++ b/perl-install/ugtk2.pm @@ -806,9 +806,6 @@ sub new { my $o = bless { %opts }, $type; $o->_create_window($title); while (my $e = shift @tempory::objects) { $e->destroy } - push @interactive::objects, $o if !$opts{no_interactive_objects}; - $o->{rwindow}->set_modal(1) if ($grab || $o->{grab} || $o->{modal}) && !$::isInstall; - $o->{rwindow}->set_transient_for($o->{transient}) if $o->{transient}; $o->{pop_it} ||= $pop_it || $::WizardTable && do { my @l = $::WizardTable->get_children; @@ -816,6 +813,12 @@ sub new { any { $_->visible } @l; }; + if ($o->{pop_it}) { + push @interactive::objects, $o if !$opts{no_interactive_objects}; + $o->{rwindow}->set_modal(1) if ($grab || $o->{grab} || $o->{modal}) && !$::isInstall; + $o->{rwindow}->set_transient_for($o->{transient}) if $o->{transient}; + } + if ($::isWizard && !$o->{pop_it}) { $o->{isWizard} = 1; $o->{window} = Gtk2::VBox->new(0,0); @@ -824,6 +827,8 @@ sub new { if (!defined($::WizardWindow)) { $::WizardWindow = Gtk2::Window->new('toplevel'); $::WizardWindow->signal_connect(delete_event => sub { die 'wizcancel' }); + $::WizardWindow->signal_connect(expose_event => \&_XSetInputFocus) if $force_focus || $o->{force_focus}; + $::WizardTable = Gtk2::Table->new(2, 2, 0); $::WizardWindow->add(gtkadd(gtkset_shadow_type(Gtk2::Frame->new, 'out'), $::WizardTable)); @@ -916,6 +921,7 @@ sub show($) { sub destroy($) { my ($o) = @_; $o->{rwindow}->destroy if !$o->{destroyed}; + @interactive::objects = grep { $o != $_ } @interactive::objects; gtkset_mousecursor_wait(); flush(); } @@ -945,7 +951,7 @@ sub _create_window($$) { $w->set_name("Title"); $w->set_title($title); - $w->signal_connect(expose_event => sub { eval { $interactive::objects[-1]{rwindow} == $w and $w->window->XSetInputFocus } }) if $force_focus || $o->{force_focus}; + $w->signal_connect(expose_event => \&_XSetInputFocus) if $force_focus || $o->{force_focus}; $w->signal_connect(delete_event => sub { if ($::isWizard) { $w->destroy; die 'wizcancel' } else { Gtk2->main_quit } }); $w->set_uposition(@{$force_position || $o->{force_position}}) if $force_position || $o->{force_position}; @@ -975,6 +981,17 @@ sub _create_window($$) { $o->{rwindow} = $w; } +sub _XSetInputFocus { + my ($w) = @_; + log::l("_XSetInputFocus"); + if (!@interactive::objects || $interactive::objects[-1]{rwindow} == $w) { + $w->window->XSetInputFocus; + } else { + log::l("not XSetInputFocus since already done and not on top"); + } + 0; +} + # -=-=---=-=---=-=---=-=---=-=---=-=---=-=---=-=---=-=---=-=---=-=---=-=--- # ask diff --git a/tools/Makefile b/tools/Makefile index 244b23bd9..38507bab1 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,7 +1,7 @@ ROOTDEST = /export DEST = $(ROOTDEST)/Mandrake/mdkinst RPMS = $(wildcard $(ROOTDEST)/Mandrake/RPMS/*.rpm) -DIRS = ddcprobe serial_probe aewm-drakx +DIRS = ddcprobe serial_probe BASE = $(ROOTDEST)/Mandrake/base CFLAGS = -Wall diff --git a/tools/aewm-drakx/Makefile b/tools/aewm-drakx/Makefile deleted file mode 100644 index ec5bbf977..000000000 --- a/tools/aewm-drakx/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -ARCH := $(shell arch | egrep "(x86_64|sparc64|s390x)") -ifneq ("x$(ARCH)", "x") -LIB_NAME = lib64 -else -LIB_NAME = lib -endif - -CFLAGS = -Wall -Os -LDFLAGS = -L/usr/X11R6/$(LIB_NAME) -lX11 -CFILES = $(wildcard *.c) -OFILES = $(CFILES:%.c=%.o) -GOAL = aewm-drakx - -$(GOAL): $(OFILES) - -clean: - rm -f $(GOAL) $(OFILES) TAGS *~ diff --git a/tools/aewm-drakx/README b/tools/aewm-drakx/README deleted file mode 100644 index 160ffb4d2..000000000 --- a/tools/aewm-drakx/README +++ /dev/null @@ -1,53 +0,0 @@ -aewm-drakx - A DrakX-aware X11 Window Manager -====================================================================== -aewm-drakx is a stripped down version of aewm with keyboard focus added. -The main and only purpose of aewm-drakx is to provide keyboard focus. - -Thanks to aewm author for his job. The already small aewm, gives a tiny WM -(source < 4Kl, binary < 8KB) when stripped down of nearly everything. - -Pixel. - - -aewm -====================================================================== -http://www.red-bean.com/~decklin/aewm/. - -Author -====================================================================== - -aewm is maintained by Decklin Foster <decklin@red-bean.com>. If you -have bug reports, comments, flames, want permission to change the -license, or are just bored, send me email. Your messages are -appreciated (but do read the thing above about virtual desktops ;-). - -License -====================================================================== - -Copyright (c) 1998-2001 Decklin Foster. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS", WITHOUT ANY EXPRESS -OR IMPLIED WARRANTIES OF ANY KIND. IN NO EVENT SHALL THE AUTHOR BE -HELD LIABLE FOR ANY DAMAGES CONNECTED WITH THE USE OF THIS PROGRAM. - -You are granted permission to copy, publish, distribute, and/or sell -copies of this program and any modified versions or derived works, -provided that this copyright and notice are not removed or altered. - -Portions of the code were based on 9wm, which contains this license: - -> 9wm is free software, and is Copyright (c) 1994 by David Hogan. -> Permission is granted to all sentient beings to use this software, -> to make copies of it, and to distribute those copies, provided -> that: -> -> (1) the copyright and licence notices are left intact -> (2) the recipients are aware that it is free software -> (3) any unapproved changes in functionality are either -> (i) only distributed as patches -> or (ii) distributed as a new program which is not called 9wm -> and whose documentation gives credit where it is due -> (4) the author is not held responsible for any defects -> or shortcomings in the software, or damages caused by it. -> -> There is no warranty for this software. Have a nice day. diff --git a/tools/aewm-drakx/aewm-drakx.c b/tools/aewm-drakx/aewm-drakx.c deleted file mode 100644 index 4df2544af..000000000 --- a/tools/aewm-drakx/aewm-drakx.c +++ /dev/null @@ -1,50 +0,0 @@ -/* aewm - a minimalistic X11 window manager. ------- vim:sw=4:et - * Copyright (c) 1998-2001 Decklin Foster <decklin@red-bean.com> - * Free software! Please see README for details and license. */ - -#include "aewm.h" - - -Display *dpy; -Window root; - -static void scan_wins(void) -{ - unsigned int nwins, i; - Window dummyw1, dummyw2, *wins; - XWindowAttributes attr; - - XQueryTree(dpy, root, &dummyw1, &dummyw2, &wins, &nwins); - for (i = 0; i < nwins; i++) { - XGetWindowAttributes(dpy, wins[i], &attr); - if (!attr.override_redirect && attr.map_state == IsViewable) - make_new_client(wins[i]); - } - XFree(wins); -} - -static void setup_display(void) -{ - XSetWindowAttributes sattr; - - dpy = XOpenDisplay(NULL); - - if (!dpy) { - err("can't open display! check your DISPLAY variable."); - exit(1); - } - - XSetErrorHandler(handle_xerror); - root = RootWindow(dpy, DefaultScreen(dpy)); - - sattr.event_mask = SubstructureRedirectMask|SubstructureNotifyMask; - XChangeWindowAttributes(dpy, root, CWEventMask, &sattr); -} - - -int main() -{ - setup_display(); - scan_wins(); - do_event_loop(); -} diff --git a/tools/aewm-drakx/aewm.h b/tools/aewm-drakx/aewm.h deleted file mode 100644 index 1f2f11f1f..000000000 --- a/tools/aewm-drakx/aewm.h +++ /dev/null @@ -1,34 +0,0 @@ -/* aewm - a minimalistic X11 window manager. ------- vim:sw=4:et - * Copyright (c) 1998-2001 Decklin Foster <decklin@red-bean.com> - * Free software! Please see README for details and license. */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <X11/Xutil.h> - -typedef struct _Client Client; - -struct _Client { - Client *next; - Window window; -}; - -extern Display *dpy; - -/* events.c */ -extern void do_event_loop(void); - -/* client.c */ -extern Client *find_client(Window); -extern void set_focus_on(Window w); -extern void set_wm_state(Client *, int); -extern void remove_client(Client *); -extern void make_new_client(Window); - -/* misc.c */ -void err(const char *, ...); -int handle_xerror(Display *, XErrorEvent *); - - -#define wm_state XInternAtom(dpy, "WM_STATE", False) diff --git a/tools/aewm-drakx/client.c b/tools/aewm-drakx/client.c deleted file mode 100644 index 8db6b2151..000000000 --- a/tools/aewm-drakx/client.c +++ /dev/null @@ -1,122 +0,0 @@ -/* aewm - a minimalistic X11 window manager. ------- vim:sw=4:et - * Copyright (c) 1998-2001 Decklin Foster <decklin@red-bean.com> - * Free software! Please see README for details and license. */ - -#include "aewm.h" -#include <X11/Xmd.h> - - -Client *head_client = NULL; - -Client *find_client(Window w) -{ - Client *c; - - for (c = head_client; c; c = c->next) - if (c->window == w) return c; - - return NULL; -} - -void set_focus_on(Window w) -{ - char *name; - XFetchName(dpy, w, &name); - if (name && strcmp(name, "skip")) { - XSetInputFocus(dpy, w, RevertToPointerRoot, CurrentTime); -#ifdef DEBUG - printf("aewm-drakx: adding %lx %s\n", w, name); -#endif - } -} - -/* Attempt to follow the ICCCM by explicity specifying 32 bits for - * this property. Does this goof up on 64 bit systems? */ -void set_wm_state(Client *c, int state) -{ - CARD32 data[2]; - - data[0] = state; - data[1] = None; /* Icon? We don't need no steenking icon. */ - - XChangeProperty(dpy, c->window, wm_state, wm_state, - 32, PropModeReplace, (unsigned char *)data, 2); -} - -/* If we can't find a WM_STATE we're going to have to assume - * Withdrawn. This is not exactly optimal, since we can't really - * distinguish between the case where no WM has run yet and when the - * state was explicitly removed (Clients are allowed to either set the - * atom to Withdrawn or just remove it... yuck.) */ -long get_wm_state(Client *c) -{ - Atom real_type; int real_format; - unsigned long items_read, items_left; - long *data, state = WithdrawnState; - - if (XGetWindowProperty(dpy, c->window, wm_state, 0L, 2L, False, - wm_state, &real_type, &real_format, &items_read, &items_left, - (unsigned char **) &data) == Success && items_read) { - state = *data; - XFree(data); - } - return state; -} - -void remove_client(Client *c) -{ - int ignore_xerror(Display *dpy, XErrorEvent *e) { return 0; } - - Client *p; - - XGrabServer(dpy); - XSetErrorHandler(ignore_xerror); - - set_wm_state(c, WithdrawnState); - - if (head_client == c) head_client = c->next; - else for (p = head_client; p && p->next; p = p->next) - if (p->next == c) p->next = c->next; - - free(c); - - if (head_client) set_focus_on(head_client->window); - - XSync(dpy, False); - XSetErrorHandler(handle_xerror); - XUngrabServer(dpy); -} - -void make_new_client(Window w) -{ - Client *c; - XWindowAttributes attr; - - c = malloc(sizeof *c); - c->next = head_client; - c->window = w; - head_client = c; - - XGrabServer(dpy); - XGetWindowAttributes(dpy, w, &attr); - - - if (attr.map_state != IsViewable) { - XWMHints *hints; - set_wm_state(c, NormalState); - if ((hints = XGetWMHints(dpy, w))) { - if (hints->flags & StateHint) set_wm_state(c, hints->initial_state); - XFree(hints); - } - } - if (attr.map_state == IsViewable) { - XMapWindow(dpy, c->window); - set_wm_state(c, NormalState); - } else if (get_wm_state(c) == NormalState) { - XMapWindow(dpy, c->window); - } - set_focus_on(w); - - XSync(dpy, False); - XUngrabServer(dpy); -} diff --git a/tools/aewm-drakx/events.c b/tools/aewm-drakx/events.c deleted file mode 100644 index f9a387e1e..000000000 --- a/tools/aewm-drakx/events.c +++ /dev/null @@ -1,106 +0,0 @@ -/* aewm - a minimalistic X11 window manager. ------- vim:sw=4:et - * Copyright (c) 1998-2001 Decklin Foster <decklin@red-bean.com> - * Free software! Please see README for details and license. */ - -#include "aewm.h" - - -static void handle_configure_request(XConfigureRequestEvent *e) -{ - XWindowChanges wc; - - wc.x = e->x; - wc.y = e->y; - wc.width = e->width; - wc.height = e->height; - wc.sibling = e->above; - wc.stack_mode = e->detail; - XConfigureWindow(dpy, e->window, e->value_mask, &wc); -} - -static void handle_map_request(XMapRequestEvent *e) -{ - Client *c = find_client(e->window); - - if (c) { - XMapWindow(dpy, c->window); - set_wm_state(c, NormalState); - set_focus_on(c->window); - } else { - make_new_client(e->window); - } -} - -static void handle_destroy_event(XDestroyWindowEvent *e) -{ - Client *c = find_client(e->window); - - if (c) remove_client(c); -} - - -#ifdef DEBUG -#define SHOW_EV(name, memb) \ - case name: s = #name; w = e.memb.window; break; -#define SHOW(name) \ - case name: return #name; - -void show_event(XEvent e) -{ - char *s = 0, buf[20]; - char *dd = 0; - Window w = 0; - Client *c; - - switch (e.type) { - SHOW_EV(ButtonPress, xbutton) - SHOW_EV(ButtonRelease, xbutton) - SHOW_EV(ClientMessage, xclient) - SHOW_EV(ColormapNotify, xcolormap) - SHOW_EV(ConfigureNotify, xconfigure) - SHOW_EV(ConfigureRequest, xconfigurerequest) - SHOW_EV(CreateNotify, xcreatewindow) - SHOW_EV(DestroyNotify, xdestroywindow) - SHOW_EV(EnterNotify, xcrossing) - SHOW_EV(Expose, xexpose) - SHOW_EV(MapNotify, xmap) - SHOW_EV(MapRequest, xmaprequest) - SHOW_EV(MappingNotify, xmapping) - SHOW_EV(MotionNotify, xmotion) - SHOW_EV(PropertyNotify, xproperty) - SHOW_EV(ReparentNotify, xreparent) - SHOW_EV(ResizeRequest, xresizerequest) - SHOW_EV(UnmapNotify, xunmap) - default: - break; - } - - c = find_client(w); - - if (c) XFetchName(dpy, c->window, &dd); - - snprintf(buf, sizeof buf, dd ? dd : ""); - err("%#-10lx: %-20s: %s", w, buf, s); -} -#endif - - -void do_event_loop(void) -{ - XEvent ev; - - for (;;) { - XNextEvent(dpy, &ev); -#ifdef DEBUG - show_event(ev); -#endif - switch (ev.type) { - case ConfigureRequest: - handle_configure_request(&ev.xconfigurerequest); break; - case MapRequest: - handle_map_request(&ev.xmaprequest); break; - case DestroyNotify: - handle_destroy_event(&ev.xdestroywindow); break; - } - } -} diff --git a/tools/aewm-drakx/misc.c b/tools/aewm-drakx/misc.c deleted file mode 100644 index fa0523534..000000000 --- a/tools/aewm-drakx/misc.c +++ /dev/null @@ -1,29 +0,0 @@ -/* aewm - a minimalistic X11 window manager. ------- vim:sw=4:et - * Copyright (c) 1998-2001 Decklin Foster <decklin@red-bean.com> - * Free software! Please see README for details and license. */ - -#include "aewm.h" -#include <stdarg.h> - - -void err(const char *fmt, ...) -{ - va_list argp; - - fprintf(stderr, "aewm: "); - va_start(argp, fmt); - vfprintf(stderr, fmt, argp); - va_end(argp); - fprintf(stderr, "\n"); -} - -int handle_xerror(Display *dpy, XErrorEvent *e) -{ - Client *c = find_client(e->resourceid); - - char msg[255]; - XGetErrorText(dpy, e->error_code, msg, sizeof msg); - err("X error (%#lx): %s", e->resourceid, msg); - - return 0; -} |