]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/clientwin.c
[svn-upgrade] Integrating new upstream version, ion3 (20070720)
[ion3.git] / ioncore / clientwin.c
index 4a5b4dacfd40ae08492058395d0d826df1b6c6dc..01a15d34b4018e0444498fa7780a2f2529562afc 100644 (file)
@@ -3,10 +3,7 @@
  *
  * Copyright (c) Tuomo Valkonen 1999-2007. 
  *
- * Ion is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
+ * See the included file LICENSE for details.
  */
 
 #include <string.h>
@@ -124,6 +121,7 @@ static WSizePolicy get_sizepolicy_winprop(WClientWin *cwin,
 static void clientwin_get_winprops(WClientWin *cwin)
 {
     ExtlTab tab, tab2;
+    char *s;
     int i1, i2;
     
     tab=ioncore_get_winprop(cwin);
@@ -157,13 +155,13 @@ static void clientwin_get_winprops(WClientWin *cwin)
     if(extl_table_is_bool_set(tab, "ignore_cfgrq"))
         cwin->flags|=CLIENTWIN_PROP_IGNORE_CFGRQ;
 
-#if 0    
-    cwin->szplcy=get_sizepolicy_winprop(cwin, "sizepolicy", 
-                                        SIZEPOLICY_DEFAULT);
-    cwin->transient_szplcy=get_sizepolicy_winprop(cwin, 
-                                                  "transient_sizepolicy",
-                                                  DFLT_SZPLCY);
-#endif
+    if(extl_table_gets_s(tab, "orientation", &s)){
+        if(strcmp(s, "vertical")==0)
+            cwin->flags|=CLIENTWIN_PROP_O_VERT;
+        else if(strcmp(s, "horizontal")==0)
+            cwin->flags|=CLIENTWIN_PROP_O_HORIZ;
+        free(s);
+    }
 }
 
 
@@ -323,8 +321,6 @@ static bool clientwin_init(WClientWin *cwin, WWindow *par, Window win,
     
     set_sane_gravity(cwin->win);
 
-    cwin->transient_for=None;
-    
     cwin->n_cmapwins=0;
     cwin->cmap=attr->colormap;
     cwin->cmaps=NULL;
@@ -481,11 +477,30 @@ again:
         
         xwindow_unmanaged_selectinput(win, 0);
         
-        win=hints->icon_window;
+        /* Copy WM_CLASS as _ION_DOCKAPP_HACK */
+        {
+            char **p=NULL;
+            int n=0;
+            
+            p=xwindow_get_text_property(win, XA_WM_CLASS, &n);
+            
+            if(p!=NULL){
+                xwindow_set_text_property(hints->icon_window, 
+                                          ioncore_g.atom_dockapp_hack,
+                                          (const char **)p, n);
+                XFreeStringList(p);
+            }else{
+                const char *pdummy[2]={"unknowndockapp", "UnknownDockapp"};
+                xwindow_set_text_property(hints->icon_window, 
+                                          ioncore_g.atom_dockapp_hack,
+                                          pdummy, 2);
+            }
+        }
         
         /* It is a dockapp, do everything again from the beginning, now
          * with the icon window.
          */
+        win=hints->icon_window;
         param.dockapp=TRUE;
         goto again;
     }
@@ -754,8 +769,8 @@ static bool send_clientmsg(Window win, Atom a, Time stmp)
 
 
 /*EXTL_DOC
- * Attempt to kill (with XKillWindow) the client that owns the X
- * window correspoding to \var{cwin}.
+ * Attempt to kill (with \code{XKillWindow}) the client that owns 
+ * the X window correspoding to \var{cwin}.
  */
 EXTL_EXPORT_MEMBER
 void clientwin_kill(WClientWin *cwin)
@@ -1025,6 +1040,16 @@ static void clientwin_size_hints(WClientWin *cwin, WSizeHints *hints_ret)
 }
 
 
+static int clientwin_orientation(WClientWin *cwin)
+{
+    return (cwin->flags&CLIENTWIN_PROP_O_VERT
+            ? REGION_ORIENTATION_VERTICAL
+            : (cwin->flags&CLIENTWIN_PROP_O_HORIZ
+               ? REGION_ORIENTATION_HORIZONTAL
+               : REGION_ORIENTATION_NONE));
+}
+
+
 /*}}}*/
 
 
@@ -1041,12 +1066,27 @@ EXTL_SAFE
 EXTL_EXPORT_MEMBER
 ExtlTab clientwin_get_ident(WClientWin *cwin)
 {
-    char **p=NULL, *wrole=NULL;
+    char **p=NULL, **p2=NULL, *wrole=NULL;
     int n=0, n2=0, n3=0, tmp=0;
+    Window tforwin=None;
     ExtlTab tab;
+    bool dockapp_hack=FALSE;
     
     p=xwindow_get_text_property(cwin->win, XA_WM_CLASS, &n);
-    wrole=xwindow_get_string_property(cwin->win, ioncore_g.atom_wm_window_role, &n2);
+    
+    p2=xwindow_get_text_property(cwin->win, ioncore_g.atom_dockapp_hack, &n2);
+    
+    dockapp_hack=(n2>0);
+    
+    if(p==NULL){
+        /* Some dockapps do actually have WM_CLASS, so use it. */
+        p=p2;
+        n=n2;
+        p2=NULL;
+    }
+    
+    wrole=xwindow_get_string_property(cwin->win, ioncore_g.atom_wm_window_role, 
+                                      &n3);
     
     tab=extl_create_table();
     if(n>=2 && p[1]!=NULL)
@@ -1056,8 +1096,18 @@ ExtlTab clientwin_get_ident(WClientWin *cwin)
     if(wrole!=NULL)
         extl_table_sets_s(tab, "role", wrole);
     
+    if(XGetTransientForHint(ioncore_g.dpy, cwin->win, &tforwin) 
+       && tforwin!=None){
+        extl_table_sets_b(tab, "is_transient", TRUE);
+    }
+    
+    if(dockapp_hack)
+        extl_table_sets_b(tab, "is_dockapp", TRUE);
+    
     if(p!=NULL)
         XFreeStringList(p);
+    if(p2!=NULL)
+        XFreeStringList(p2);
     if(wrole!=NULL)
         free(wrole);
     
@@ -1085,9 +1135,9 @@ static bool check_fs_cfgrq(WClientWin *cwin, XConfigureRequestEvent *ev)
             
             if(!region_fullscreen_scr(grp, scr, sw))
                 cwin->flags&=~CLIENTWIN_FS_RQ;
+                
+            return TRUE;
         }
-        
-        return TRUE;
     }
 
     return FALSE;
@@ -1260,8 +1310,8 @@ WRegion *clientwin_load(WWindow *par, const WFitParams *fp, ExtlTab tab)
     WClientWin *cwin=NULL;
     XWindowAttributes attr;
     WRectangle rg;
-    bool got_chkc;
-
+    bool got_chkc=FALSE;
+    
     if(!extl_table_gets_d(tab, "windowid", &wind) ||
        !extl_table_gets_i(tab, "checkcode", &chkc)){
         return NULL;
@@ -1294,14 +1344,7 @@ WRegion *clientwin_load(WWindow *par, const WFitParams *fp, ExtlTab tab)
         warn(TR("Saved client window does not want to be managed."));
         return NULL;
     }
-
-    /*
-    attr.x=fp->g.x;
-    attr.y=fp->g.y;
-    attr.width=fp->g.w;
-    attr.height=fp->g.h;
-     */
-
+    
     cwin=create_clientwin(par, win, &attr);
     
     if(cwin==NULL)
@@ -1358,6 +1401,9 @@ static DynFunTab clientwin_dynfuntab[]={
     
     {region_size_hints, 
      clientwin_size_hints},
+     
+    {(DynFun*)region_orientation, 
+     (DynFun*)clientwin_orientation},
     
     {(DynFun*)region_rqclose, 
      (DynFun*)clientwin_rqclose},