From 165f1045ab78edb86348b76022b0106251a5d10c Mon Sep 17 00:00:00 2001 From: Olivier Fourdan <fourdan.olivier@wanadoo.fr> Date: Tue, 20 Apr 2004 22:25:10 +0000 Subject: [PATCH] Add window size/position during resize (based on a patch submitted by Joshua Blanton <jblanton@irg.cs.ohiou.edu>) (Old svn revision: 11713) --- po/xfwm4.pot | 2 +- src/Makefile.am | 2 + src/Makefile.in | 33 +++++++++++++- src/client.c | 19 +++++++- src/poswin.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++ src/poswin.h | 47 ++++++++++++++++++++ 6 files changed, 210 insertions(+), 5 deletions(-) create mode 100644 src/poswin.c create mode 100644 src/poswin.h diff --git a/po/xfwm4.pot b/po/xfwm4.pot index 0d328eac4..eddfc03c1 100644 --- a/po/xfwm4.pot +++ b/po/xfwm4.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2004-04-15 22:54+0200\n" +"POT-Creation-Date: 2004-04-19 00:14+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/src/Makefile.am b/src/Makefile.am index bc09ca479..6c90d67e0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,6 +23,8 @@ xfwm4_SOURCES = \ mywindow.h \ parserc.c \ parserc.h \ + poswin.c \ + poswin.h \ session.c \ session.h \ settings.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 100f08af7..6e3756be4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -58,8 +58,9 @@ am_xfwm4_OBJECTS = xfwm4-client.$(OBJEXT) xfwm4-events.$(OBJEXT) \ xfwm4-keyboard.$(OBJEXT) xfwm4-main.$(OBJEXT) \ xfwm4-menu.$(OBJEXT) xfwm4-misc.$(OBJEXT) \ xfwm4-mypixmap.$(OBJEXT) xfwm4-mywindow.$(OBJEXT) \ - xfwm4-parserc.$(OBJEXT) xfwm4-session.$(OBJEXT) \ - xfwm4-settings.$(OBJEXT) xfwm4-startup_notification.$(OBJEXT) \ + xfwm4-parserc.$(OBJEXT) xfwm4-poswin.$(OBJEXT) \ + xfwm4-session.$(OBJEXT) xfwm4-settings.$(OBJEXT) \ + xfwm4-startup_notification.$(OBJEXT) \ xfwm4-spinning_cursor.$(OBJEXT) xfwm4-tabwin.$(OBJEXT) \ xfwm4-workspaces.$(OBJEXT) xfwm4_OBJECTS = $(am_xfwm4_OBJECTS) @@ -78,6 +79,7 @@ am__depfiles_maybe = depfiles @AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-mypixmap.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-mywindow.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-parserc.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-poswin.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-session.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-settings.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/xfwm4-spinning_cursor.Po \ @@ -266,6 +268,8 @@ xfwm4_SOURCES = \ mywindow.h \ parserc.c \ parserc.h \ + poswin.c \ + poswin.h \ session.c \ session.h \ settings.c \ @@ -385,6 +389,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-mypixmap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-mywindow.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-parserc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-poswin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-session.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-settings.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfwm4-spinning_cursor.Po@am__quote@ @@ -680,6 +685,30 @@ xfwm4-parserc.lo: parserc.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -c -o xfwm4-parserc.lo `test -f 'parserc.c' || echo '$(srcdir)/'`parserc.c +xfwm4-poswin.o: poswin.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -MT xfwm4-poswin.o -MD -MP -MF "$(DEPDIR)/xfwm4-poswin.Tpo" -c -o xfwm4-poswin.o `test -f 'poswin.c' || echo '$(srcdir)/'`poswin.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfwm4-poswin.Tpo" "$(DEPDIR)/xfwm4-poswin.Po"; else rm -f "$(DEPDIR)/xfwm4-poswin.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='poswin.c' object='xfwm4-poswin.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfwm4-poswin.Po' tmpdepfile='$(DEPDIR)/xfwm4-poswin.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -c -o xfwm4-poswin.o `test -f 'poswin.c' || echo '$(srcdir)/'`poswin.c + +xfwm4-poswin.obj: poswin.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -MT xfwm4-poswin.obj -MD -MP -MF "$(DEPDIR)/xfwm4-poswin.Tpo" -c -o xfwm4-poswin.obj `if test -f 'poswin.c'; then $(CYGPATH_W) 'poswin.c'; else $(CYGPATH_W) '$(srcdir)/poswin.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfwm4-poswin.Tpo" "$(DEPDIR)/xfwm4-poswin.Po"; else rm -f "$(DEPDIR)/xfwm4-poswin.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='poswin.c' object='xfwm4-poswin.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfwm4-poswin.Po' tmpdepfile='$(DEPDIR)/xfwm4-poswin.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -c -o xfwm4-poswin.obj `if test -f 'poswin.c'; then $(CYGPATH_W) 'poswin.c'; else $(CYGPATH_W) '$(srcdir)/poswin.c'; fi` + +xfwm4-poswin.lo: poswin.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -MT xfwm4-poswin.lo -MD -MP -MF "$(DEPDIR)/xfwm4-poswin.Tpo" -c -o xfwm4-poswin.lo `test -f 'poswin.c' || echo '$(srcdir)/'`poswin.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfwm4-poswin.Tpo" "$(DEPDIR)/xfwm4-poswin.Plo"; else rm -f "$(DEPDIR)/xfwm4-poswin.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='poswin.c' object='xfwm4-poswin.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/xfwm4-poswin.Plo' tmpdepfile='$(DEPDIR)/xfwm4-poswin.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -c -o xfwm4-poswin.lo `test -f 'poswin.c' || echo '$(srcdir)/'`poswin.c + xfwm4-session.o: session.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfwm4_CFLAGS) $(CFLAGS) -MT xfwm4-session.o -MD -MP -MF "$(DEPDIR)/xfwm4-session.Tpo" -c -o xfwm4-session.o `test -f 'session.c' || echo '$(srcdir)/'`session.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/xfwm4-session.Tpo" "$(DEPDIR)/xfwm4-session.Po"; else rm -f "$(DEPDIR)/xfwm4-session.Tpo"; exit 1; fi diff --git a/src/client.c b/src/client.c index e97dd5094..e355ed019 100644 --- a/src/client.c +++ b/src/client.c @@ -48,6 +48,7 @@ #include "mywindow.h" #include "settings.h" #include "tabwin.h" +#include "poswin.h" #include "session.h" #include "startup_notification.h" @@ -107,6 +108,7 @@ struct _MoveResizeData int ox, oy; int oldw, oldh; int corner; + Poswin *poswin; Window tmp_event_window; Client *c; }; @@ -5489,6 +5491,10 @@ clientResize_event_filter (XEvent * xevent, gpointer data) int disp_x, disp_y, disp_max_x, disp_max_y; int frame_x, frame_y, frame_height, frame_width; int frame_top, frame_left, frame_right, frame_bottom; + static GtkWidget *window = NULL; + static GtkWidget *label = NULL; + static GtkWidget *frame = NULL; + char location[32]; /* 32 is enough for (NNNNNxNNNNN) @ (-NNNNN,-NNNNN) */ TRACE ("entering clientResize_event_filter"); @@ -5522,6 +5528,7 @@ clientResize_event_filter (XEvent * xevent, gpointer data) disp_max_y = MyDisplayMaxY (dpy, screen, cx, cy); last_timestamp = stashEventTime (last_timestamp, xevent); + if (xevent->type == KeyPress) { if (passdata->use_keys) @@ -5726,6 +5733,7 @@ clientResize_event_filter (XEvent * xevent, gpointer data) c->width = prev_width; } } + poswinSetPosition (passdata->poswin, frame_x, frame_y, c->width, c->height, c->size->width_inc, c->size->height_inc); if (params.box_resize) { clientDrawOutline (c); @@ -5738,6 +5746,7 @@ clientResize_event_filter (XEvent * xevent, gpointer data) wc.height = c->height; clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, NO_CFG_FLAG); } + } else if (xevent->type == ButtonRelease) { @@ -5837,11 +5846,15 @@ clientResize (Client * c, int corner, XEvent * e) removeTmpEventWin (passdata.tmp_event_window); return; } - if (passdata.use_keys) { XPutBackEvent (dpy, e); } + + passdata.poswin = poswinCreate(); + poswinSetPosition (passdata.poswin, frameX (c), frameY (c), c->width, c->height, c->size->width_inc, c->size->height_inc); + poswinShow (passdata.poswin); + FLAG_SET (c->flags, CLIENT_FLAG_MOVING_RESIZING); TRACE ("entering resize loop"); pushEventFilter (clientResize_event_filter, &passdata); @@ -5849,7 +5862,9 @@ clientResize (Client * c, int corner, XEvent * e) popEventFilter (); TRACE ("leaving resize loop"); FLAG_UNSET (c->flags, CLIENT_FLAG_MOVING_RESIZING); - + + poswinDestroy (passdata.poswin); + if (passdata.grab && params.box_resize) { clientDrawOutline (c); diff --git a/src/poswin.c b/src/poswin.c new file mode 100644 index 000000000..fa9b05b52 --- /dev/null +++ b/src/poswin.c @@ -0,0 +1,112 @@ +/* + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; You may only use version 2 of the License, + you have no option to use any other version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + xfwm4 - (c) 2004 Olivier Fourdan + based on a patch from Joshua Blanton <jblanton@irg.cs.ohiou.edu> + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib.h> +#include <gdk/gdk.h> +#include <gdk/gdkx.h> +#include <gtk/gtk.h> +#include <libxfce4util/debug.h> +#include <libxfce4util/i18n.h> +#include <libxfcegui4/libxfcegui4.h> +#include "poswin.h" + +Poswin * +poswinCreate (void) +{ + Poswin *poswin; + GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *header; + + poswin = g_new (Poswin, 1); + + poswin->window = gtk_window_new (GTK_WINDOW_POPUP); + gtk_container_set_border_width (GTK_CONTAINER (poswin->window), 0); + gtk_window_set_resizable (GTK_WINDOW (poswin->window), TRUE); + + frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); + gtk_container_set_border_width (GTK_CONTAINER (frame), 0); + gtk_container_add (GTK_CONTAINER (poswin->window), frame); + gtk_widget_show (frame); + + poswin->label = gtk_label_new (""); + gtk_misc_set_alignment (GTK_MISC (poswin->label), 0.5, 0.5); + gtk_misc_set_padding (GTK_MISC (poswin->label), 3, 3); + gtk_widget_show (poswin->label); + gtk_container_add(GTK_CONTAINER(frame), poswin->label); + gtk_widget_show_all (frame); + + return poswin; +} + +void +poswinSetPosition (Poswin * poswin, gint x, gint y, guint width, guint height, gint wsizeinc, gint hsizeinc) +{ + /* 32 is enough for (NNNNNxNNNNN) @ (-NNNNN,-NNNNN) */ + gchar label[32]; + gint px, py, pw, ph; + + g_return_if_fail (poswin != NULL); + g_return_if_fail (hsizeinc != 0); + g_return_if_fail (wsizeinc != 0); + + g_snprintf (label, 32, "(%ux%u) @ (%i,%i)", width / wsizeinc, height / hsizeinc, x, y); + gtk_label_set_text (GTK_LABEL (poswin->label), label); + gtk_widget_queue_draw (poswin->window); + gtk_window_get_size (GTK_WINDOW (poswin->window), &pw, &ph); + px = x + (width - pw) / 2; + py = y + (height - ph) / 2; + if (GTK_WIDGET_REALIZED (poswin->window)) + { + gdk_window_move_resize (poswin->window->window, px, py, pw, ph); + } + else + { + gtk_window_move (GTK_WINDOW (poswin->window), px, py); + } +} + +void +poswinDestroy (Poswin * poswin) +{ + g_return_if_fail (poswin != NULL); + + gtk_widget_destroy (poswin->window); +} + +void +poswinShow (Poswin * poswin) +{ + g_return_if_fail (poswin != NULL); + + gtk_widget_show_now (poswin->window); +} + +void +poswinHide(Poswin * poswin) +{ + g_return_if_fail (poswin != NULL); + + gtk_widget_hide (poswin->window); +} diff --git a/src/poswin.h b/src/poswin.h new file mode 100644 index 000000000..14268d7f8 --- /dev/null +++ b/src/poswin.h @@ -0,0 +1,47 @@ +/* + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; You may only use version 2 of the License, + you have no option to use any other version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + xfwm4 - (c) 2004 Olivier Fourdan + based on a patch from Joshua Blanton <jblanton@irg.cs.ohiou.edu> + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifndef INC_POSWIN_H +#define INC_POSWIN_H + +#include <glib.h> +#include <gdk/gdk.h> +#include <gdk/gdkx.h> +#include <gtk/gtk.h> + +typedef struct _Poswin Poswin; +struct _Poswin +{ + GtkWidget *window; + GtkWidget *label; +}; + +Poswin *poswinCreate (void); +void poswinSetPosition (Poswin * poswin, gint x, gint y, + guint width, guint height, + gint wsizeinc, gint hsizeinc); +void poswinDestroy (Poswin * poswin); +void poswinShow (Poswin * poswin); +void poswinHide(Poswin * poswin); + +#endif /* INC_POSWIN_H */ -- GitLab