antiright-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Antiright-devel] antiright/gtkshell Makefile module_includes.h o...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/gtkshell Makefile module_includes.h o...
Date: Mon, 13 Aug 2007 11:08:28 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/08/13 11:08:28

Modified files:
        gtkshell       : Makefile module_includes.h options.c 
Added files:
        gtkshell       : swallow.c swallow.h 

Log message:
        Add initial code for containment of external applications.  Once 
completed,
        this will help phase out vte in favor of rxvt.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/Makefile?cvsroot=antiright&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/module_includes.h?cvsroot=antiright&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/options.c?cvsroot=antiright&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/swallow.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/swallow.h?cvsroot=antiright&rev=1.1

Patches:
Index: Makefile
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/Makefile,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- Makefile    13 Aug 2007 07:12:30 -0000      1.43
+++ Makefile    13 Aug 2007 11:08:28 -0000      1.44
@@ -38,7 +38,7 @@
        image_button.o terminal.o terminal_options.o menu.o updated.o\
        guidl_util.o about_dialog.o init.o guidl_dialog.o guidl_dictionary.o\
        guidl_options.o guidl_widgets.o update_manager.o pane.o\
-       command_shell.o app_mode.o clock.o tree.o form.o dialog.o
+       command_shell.o app_mode.o clock.o tree.o form.o dialog.o swallow.o
 
 program=main.o 
 

Index: module_includes.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/module_includes.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- module_includes.h   13 Aug 2007 07:12:31 -0000      1.9
+++ module_includes.h   13 Aug 2007 11:08:28 -0000      1.10
@@ -60,5 +60,6 @@
 #include "tree.h"
 #include "form.h"
 #include "dialog.h"
+#include "swallow.h"
 
 #endif /* not GSH_MODULE_INCLUDES_H */

Index: options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/options.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- options.c   25 Jul 2007 04:42:39 -0000      1.30
+++ options.c   13 Aug 2007 11:08:28 -0000      1.31
@@ -111,6 +111,10 @@
                break;
        case 't': /* test area.  */
                {
+                       GtkWidget * parent;
+                       parent=gtk_event_box_new();
+                       gsh_swallow_app(parent, "internal");
+                       $(gsh, manage, parent);
                }
                break;
        default:

Index: swallow.c
===================================================================
RCS file: swallow.c
diff -N swallow.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ swallow.c   13 Aug 2007 11:08:28 -0000      1.1
@@ -0,0 +1,195 @@
+/*
+  AntiRight
+
+  Swallowing code written by Peter Amstutz <address@hidden>, 2003 GPL,
+       as part of gnome-swallow.
+  (c) 2007 Jeffrey Bedard 
+  address@hidden
+
+  This file is part of AntiRight.
+
+  AntiRight 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; either version 2 of the License, or
+  (at your option) any later version.
+
+  AntiRight 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 AntiRight; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+*/
+
+#include "gtkshell.h"
+#include <gdk/gdkx.h>
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+static gboolean 
+swallow(char* wantedWindow, Display* display, Screen* screen, Window hunger, 
+       unsigned int* width, unsigned int* height)
+{
+    int ready = FALSE, i,k,l;
+    unsigned int number_of_kids, number_of_subkids, number_of_subsubkids;
+    Window root, parent, *children=NULL,*subchildren=NULL,*subsubchildren=NULL;
+    Window victim;
+    char *windowname;
+    XWMHints *leader_change;
+    int x, y;
+    unsigned int junk;
+    double start, now;
+    struct timeval tv;
+    char ret;
+
+    if(! display) return FALSE;
+
+    XSync (display, FALSE);
+
+    gettimeofday(&tv, NULL);
+    now = start = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0);
+
+    while (ready == FALSE && now < (start + 10.0))
+    {
+        if (children != (Window *) NULL) XFree (children);
+
+        XQueryTree (display, RootWindowOfScreen (screen), &root,
+                    &parent, &children, &number_of_kids);
+        for (i = 0; i < number_of_kids; i++)
+        {
+            if (0 != XFetchName (display, children[i], &windowname))
+            {
+                if (!strcmp (windowname, wantedWindow))
+                {
+                    ready = TRUE;
+                    victim = children[i];
+                    fprintf(stderr,"Found It\n");
+                }
+                else
+                    fprintf(stderr,"Found %s\n",windowname);
+                XFree (windowname);
+            }
+            /*for each of these toplevel windows check their children*/
+            /*if it wasnt found*/
+            if (ready == FALSE)
+            {
+                if (subchildren != (Window *) NULL)
+                    XFree (subchildren);
+                XQueryTree (display, children[i], &root,
+                            &parent, &subchildren, &number_of_subkids);
+                for (k = 0; k < number_of_subkids; k++)
+                {
+                    if (0 != XFetchName (display, subchildren[k], &windowname))
+                    {
+                        if (!strcmp (windowname, wantedWindow))
+                        {
+                            ready = TRUE;
+                            victim = subchildren[k];
+                            fprintf(stderr,"Found %s!!!\n",windowname);
+                        }
+                        else
+                            fprintf(stderr,"Found %s\n",windowname);
+                        XFree (windowname);
+                    }
+                    /**/
+                    /*for each of these sublevel windows check their children*/
+                    /*if it wasnt found*/
+                    if (ready == FALSE)
+                    {
+                        if (subsubchildren != (Window *) NULL)
+                            XFree (subsubchildren);
+                        XQueryTree (display, subchildren[k], &root,
+                                    &parent, &subsubchildren, 
&number_of_subsubkids);
+                        for (l = 0; l < number_of_subsubkids; l++)
+                        {
+                            if (0 != XFetchName (display, subsubchildren[l], 
&windowname))
+                            {
+                                if (!strcmp (windowname, wantedWindow))
+                                {
+                                    ready = TRUE;
+                                    victim = subsubchildren[l];
+                                    fprintf(stderr,"Found %s!!!\n",windowname);
+                                }
+                                else
+                                    fprintf(stderr,"Found %s\n",windowname);
+                                XFree (windowname);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        fprintf(stderr,"Loop");
+        gtk_main_iteration_do(FALSE);
+
+        gettimeofday(&tv, NULL);
+        now = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0);
+    }
+
+    if(ready) {
+        XSync (display, FALSE);
+        XUnmapWindow (display, victim);
+        XIconifyWindow (display, victim, XScreenNumberOfScreen (screen));
+        XWithdrawWindow (display, victim, XScreenNumberOfScreen (screen));
+        XMoveWindow (display, victim, -9999, -9999);
+
+        leader_change = XGetWMHints(display, victim);
+        if(leader_change) {
+            leader_change->flags = (leader_change->flags | WindowGroupHint);
+            leader_change->window_group = RootWindowOfScreen(screen);
+        }
+        XSetWindowBorderWidth (display, victim, 0);
+
+        XSync (display, FALSE);
+
+        sleep(1);
+
+        XReparentWindow (display, victim, hunger, -9999, -9999);
+
+        XGetGeometry (display, victim, &root, &x, &y, width, height, &junk, 
&junk);
+        XMoveWindow (display, victim, 0, 0);
+        if(leader_change) XSetWMHints(display, victim, leader_change);
+        XMapWindow (display, victim);
+        XSync (display, FALSE);
+
+        ret = TRUE;
+    } else {
+        ret = FALSE;
+    }
+
+    if (children != (Window *) NULL)
+        XFree (children);
+    if (subchildren != (Window *) NULL)
+        XFree (subchildren);
+    if (subsubchildren != (Window *) NULL)
+        XFree (subsubchildren);
+
+    return ret;
+}
+
+void
+gsh_swallow_app(GtkWidget * target, gchar * source_name)
+{
+       GdkWindow * window = target->window;
+
+       swallow(source_name, 
+               GDK_WINDOW_XDISPLAY(window),
+               GDK_SCREEN_XSCREEN(gtk_widget_get_screen(target)),
+               GDK_WINDOW_XWINDOW(window), 
+               (unsigned int *)&(target->requisition.width), 
+               (unsigned int *)&(target->requisition.height));
+       gtk_widget_set_size_request(target,
+               target->requisition.width,
+               target->requisition.height);
+}
+
+/* example
+    if(swallow(ap->applet_name,
+            GDK_DISPLAY_XDISPLAY(gdkdisplay),
+            GDK_SCREEN_XSCREEN(gdkscreen),
+            GDK_WINDOW_XWINDOW (GTK_WIDGET (ap->parentWidget)->window),
+               &ap->width, &ap->height))
+*/

Index: swallow.h
===================================================================
RCS file: swallow.h
diff -N swallow.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ swallow.h   13 Aug 2007 11:08:28 -0000      1.1
@@ -0,0 +1,30 @@
+/*
+  AntiRight
+  (c) 2002-2007 Jeffrey Bedard
+  address@hidden
+
+  This file is part of AntiRight.
+
+  AntiRight 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; either version 2 of the License, or
+  (at your option) any later version.
+
+  AntiRight 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 AntiRight; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+*/
+
+#ifndef GSH_SWALLOW_H
+#define GSH_SWALLOW_H
+
+void
+gsh_swallow_app(GtkWidget * target, gchar * source_name);
+
+#endif /* GSH_SWALLOW_H */
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]