Fix #21470: changing brush settings redraws the 3d view unecessarily,
[blender-staging.git] / source / blender / editors / space_view3d / space_view3d.c
index c175f835d676852874a957d77bdb6f1c0307b49c..92e3b35f6145a17e8d9bc9b723e5c05480662132 100644 (file)
@@ -1,5 +1,5 @@
 /**
 /**
- * $Id:
+ * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software Foundation,
  *
  * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * The Original Code is Copyright (C) 2008 Blender Foundation.
  * All rights reserved.
  *
  * The Original Code is Copyright (C) 2008 Blender Foundation.
  * All rights reserved.
 #include <string.h>
 #include <stdio.h>
 
 #include <string.h>
 #include <stdio.h>
 
-#include "DNA_action_types.h"
-#include "DNA_armature_types.h"
 #include "DNA_object_types.h"
 #include "DNA_object_types.h"
-#include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_view3d_types.h"
 
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
 
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
-#include "BLI_arithb.h"
+#include "BLI_math.h"
 #include "BLI_rand.h"
 
 #include "BKE_action.h"
 #include "BLI_rand.h"
 
 #include "BKE_action.h"
 #include "BKE_global.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 #include "BKE_global.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
+#include "BKE_image.h"
 
 
-#include "ED_armature.h"
-#include "ED_space_api.h"
 #include "ED_screen.h"
 #include "ED_object.h"
 
 #include "BIF_gl.h"
 
 #include "ED_screen.h"
 #include "ED_object.h"
 
 #include "BIF_gl.h"
 
+
 #include "WM_api.h"
 #include "WM_types.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
 
-#include "UI_interface.h"
-#include "UI_resources.h"
-#include "UI_view2d.h"
 
 #include "RNA_access.h"
 
 
 #include "RNA_access.h"
 
+#include "UI_resources.h"
+
 #include "view3d_intern.h"     // own include
 
 /* ******************** manage regions ********************* */
 #include "view3d_intern.h"     // own include
 
 /* ******************** manage regions ********************* */
@@ -123,7 +117,7 @@ ARegion *view3d_has_tools_region(ScrArea *sa)
                
                BLI_insertlinkafter(&sa->regionbase, arhead, artool);
                artool->regiontype= RGN_TYPE_TOOLS;
                
                BLI_insertlinkafter(&sa->regionbase, arhead, artool);
                artool->regiontype= RGN_TYPE_TOOLS;
-               artool->alignment= RGN_OVERLAP_LEFT;
+               artool->alignment= RGN_ALIGN_LEFT; //RGN_OVERLAP_LEFT;
                artool->flag = RGN_FLAG_HIDDEN;
        }
 
                artool->flag = RGN_FLAG_HIDDEN;
        }
 
@@ -148,7 +142,7 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C)
        
        if(rv3d==NULL) {
                ScrArea *sa =CTX_wm_area(C);
        
        if(rv3d==NULL) {
                ScrArea *sa =CTX_wm_area(C);
-               if(sa->spacetype==SPACE_VIEW3D) {
+               if(sa && sa->spacetype==SPACE_VIEW3D) {
                        ARegion *ar;
                        for(ar= sa->regionbase.first; ar; ar= ar->next)
                                if(ar->regiontype==RGN_TYPE_WINDOW)
                        ARegion *ar;
                        for(ar= sa->regionbase.first; ar; ar= ar->next)
                                if(ar->regiontype==RGN_TYPE_WINDOW)
@@ -158,6 +152,31 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C)
        return rv3d;
 }
 
        return rv3d;
 }
 
+/* Most of the time this isn't needed since you could assume the view matrix was
+ * set while drawing, however when functions like mesh_foreachScreenVert are
+ * called by selection tools, we can't be sure this object was the last.
+ *
+ * for example, transparent objects are drawn after editmode and will cause
+ * the rv3d mat's to change and break selection.
+ *
+ * 'ED_view3d_init_mats_rv3d' should be called before
+ * view3d_project_short_clip and view3d_project_short_noclip in cases where
+ * these functions are not used during draw_object
+ */
+void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d)
+{
+       /* local viewmat and persmat, to calculate projections */
+       mul_m4_m4m4(rv3d->viewmatob, ob->obmat, rv3d->viewmat);
+       mul_m4_m4m4(rv3d->persmatob, ob->obmat, rv3d->persmat);
+
+       /* we have to multiply instead of loading viewmatob to make
+          it work with duplis using displists, otherwise it will
+          override the dupli-matrix */
+       glMultMatrixf(ob->obmat);
+
+       /* initializes object space clipping, speeds up clip tests */
+       ED_view3d_local_clipping(rv3d, ob->obmat);
+}
 
 /* ******************** default callbacks for view3d space ***************** */
 
 
 /* ******************** default callbacks for view3d space ***************** */
 
@@ -200,12 +219,28 @@ static SpaceLink *view3d_new(const bContext *C)
        ar->regiontype= RGN_TYPE_HEADER;
        ar->alignment= RGN_ALIGN_BOTTOM;
        
        ar->regiontype= RGN_TYPE_HEADER;
        ar->alignment= RGN_ALIGN_BOTTOM;
        
+       /* tool shelf */
+       ar= MEM_callocN(sizeof(ARegion), "toolshelf for view3d");
+       
+       BLI_addtail(&v3d->regionbase, ar);
+       ar->regiontype= RGN_TYPE_TOOLS;
+       ar->alignment= RGN_ALIGN_LEFT;
+       ar->flag = RGN_FLAG_HIDDEN;
+       
+       /* tool properties */
+       ar= MEM_callocN(sizeof(ARegion), "tool properties for view3d");
+       
+       BLI_addtail(&v3d->regionbase, ar);
+       ar->regiontype= RGN_TYPE_TOOL_PROPS;
+       ar->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
+       ar->flag = RGN_FLAG_HIDDEN;
+       
        /* buttons/list view */
        ar= MEM_callocN(sizeof(ARegion), "buttons for view3d");
        
        BLI_addtail(&v3d->regionbase, ar);
        ar->regiontype= RGN_TYPE_UI;
        /* buttons/list view */
        ar= MEM_callocN(sizeof(ARegion), "buttons for view3d");
        
        BLI_addtail(&v3d->regionbase, ar);
        ar->regiontype= RGN_TYPE_UI;
-       ar->alignment= RGN_ALIGN_LEFT;
+       ar->alignment= RGN_ALIGN_RIGHT;
        ar->flag = RGN_FLAG_HIDDEN;
        
        /* main area */
        ar->flag = RGN_FLAG_HIDDEN;
        
        /* main area */
@@ -228,12 +263,13 @@ static SpaceLink *view3d_new(const bContext *C)
 static void view3d_free(SpaceLink *sl)
 {
        View3D *vd= (View3D *) sl;
 static void view3d_free(SpaceLink *sl)
 {
        View3D *vd= (View3D *) sl;
-       
-       if(vd->bgpic) {
-               if(vd->bgpic->ima) vd->bgpic->ima->id.us--;
-               MEM_freeN(vd->bgpic);
+
+       BGpic *bgpic;
+       for(bgpic= vd->bgpicbase.first; bgpic; bgpic= bgpic->next) {
+               if(bgpic->ima) bgpic->ima->id.us--;
        }
        }
-       
+       BLI_freelistN(&vd->bgpicbase);
+
        if(vd->localvd) MEM_freeN(vd->localvd);
        
        if(vd->properties_storage) MEM_freeN(vd->properties_storage);
        if(vd->localvd) MEM_freeN(vd->localvd);
        
        if(vd->properties_storage) MEM_freeN(vd->properties_storage);
@@ -251,6 +287,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
 {
        View3D *v3do= (View3D *)sl;
        View3D *v3dn= MEM_dupallocN(sl);
 {
        View3D *v3do= (View3D *)sl;
        View3D *v3dn= MEM_dupallocN(sl);
+       BGpic *bgpic;
        
        /* clear or remove stuff from old */
        
        
        /* clear or remove stuff from old */
        
@@ -265,10 +302,11 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
        
        /* copy or clear inside new stuff */
 
        
        /* copy or clear inside new stuff */
 
-       if(v3dn->bgpic) {
-               v3dn->bgpic= MEM_dupallocN(v3dn->bgpic);
-               if(v3dn->bgpic->ima) v3dn->bgpic->ima->id.us++;
-       }
+       BLI_duplicatelist(&v3dn->bgpicbase, &v3do->bgpicbase);
+       for(bgpic= v3dn->bgpicbase.first; bgpic; bgpic= bgpic->next)
+               if(bgpic->ima)
+                       bgpic->ima->id.us++;
+
        v3dn->properties_storage= NULL;
        
        return (SpaceLink *)v3dn;
        v3dn->properties_storage= NULL;
        
        return (SpaceLink *)v3dn;
@@ -277,68 +315,161 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
 /* add handlers, stuff you only do once or on area/region changes */
 static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
+       ListBase *lb;
        wmKeyMap *keymap;
 
        /* object ops. */
        wmKeyMap *keymap;
 
        /* object ops. */
-       keymap= WM_keymap_find(wm, "Object Non-modal", 0, 0);
-       WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        /* pose is not modal, operator poll checks for this */
        
        /* pose is not modal, operator poll checks for this */
-       keymap= WM_keymap_find(wm, "Pose", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Pose", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
-       keymap= WM_keymap_find(wm, "Object Mode", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Object Mode", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
-       keymap= WM_keymap_find(wm, "Image Paint", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Image Paint", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
-       keymap= WM_keymap_find(wm, "Vertex Paint", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Vertex Paint", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
-       keymap= WM_keymap_find(wm, "Weight Paint", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Weight Paint", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+       
+       keymap= WM_keymap_find(wm->defaultconf, "Face Mask", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
-       keymap= WM_keymap_find(wm, "Sculpt", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Sculpt", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
-       keymap= WM_keymap_find(wm, "EditMesh", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Mesh", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
-       keymap= WM_keymap_find(wm, "Curve", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Curve", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
-       keymap= WM_keymap_find(wm, "Armature", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Armature", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
-       keymap= WM_keymap_find(wm, "Pose", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Pose", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
-       keymap= WM_keymap_find(wm, "Metaball", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Metaball", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
-       keymap= WM_keymap_find(wm, "Lattice", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Lattice", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        /* armature sketching needs to take over mouse */
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        /* armature sketching needs to take over mouse */
-       keymap= WM_keymap_find(wm, "Armature_Sketch", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Armature Sketch", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
-       keymap= WM_keymap_find(wm, "Particle", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Particle", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        /* editfont keymap swallows all... */
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        /* editfont keymap swallows all... */
-       keymap= WM_keymap_find(wm, "Font", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Font", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+
+       keymap= WM_keymap_find(wm->defaultconf, "Object Non-modal", 0, 0);
+       WM_event_add_keymap_handler(&ar->handlers, keymap);
+
+       keymap= WM_keymap_find(wm->defaultconf, "Frames", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        /* own keymap, last so modes can override it */
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        /* own keymap, last so modes can override it */
-       keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
-       keymap= WM_keymap_find(wm, "View3D", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "3D View", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
+       
+       /* add drop boxes */
+       lb= WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW);
+       
+       WM_event_add_dropbox_handler(&ar->handlers, lb);
+       
+}
+
+static int view3d_ob_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
+{
+       if(drag->type==WM_DRAG_ID) {
+               ID *id= (ID *)drag->poin;
+               if( GS(id->name)==ID_OB )
+                       return 1;
+       }
+       return 0;
 }
 
 }
 
+static int view3d_mat_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
+{
+       if(drag->type==WM_DRAG_ID) {
+               ID *id= (ID *)drag->poin;
+               if( GS(id->name)==ID_MA )
+                       return 1;
+       }
+       return 0;
+}
+
+static int view3d_ima_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
+{
+       if( ED_view3d_give_base_under_cursor(C, event->mval) ) {
+               if(drag->type==WM_DRAG_ID) {
+                       ID *id= (ID *)drag->poin;
+                       if( GS(id->name)==ID_IM )
+                               return 1;
+               }
+               else if(drag->type==WM_DRAG_PATH){
+                       if(ELEM(drag->icon, 0, ICON_FILE_IMAGE))        /* rule might not work? */
+                               return 1;
+               }
+       }
+       return 0;
+}
+
+static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+       ID *id= (ID *)drag->poin;
+       PointerRNA ptr;
+
+       /* need to put name in sub-operator in macro */
+       ptr= RNA_pointer_get(drop->ptr, "OBJECT_OT_add_named");
+       if(ptr.data)
+               RNA_string_set(&ptr, "name", id->name+2);
+       else
+               RNA_string_set(drop->ptr, "name", id->name+2);
+}
+
+static void view3d_id_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+       ID *id= (ID *)drag->poin;
+       
+       RNA_string_set(drop->ptr, "name", id->name+2);
+}
+
+static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+       ID *id= (ID *)drag->poin;
+       
+       if(id)
+               RNA_string_set(drop->ptr, "name", id->name+2);
+       if(drag->path[0]) 
+               RNA_string_set(drop->ptr, "filepath", drag->path);
+}
+
+
+/* region dropbox definition */
+static void view3d_dropboxes(void)
+{
+       ListBase *lb= WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW);
+       
+       WM_dropbox_add(lb, "OBJECT_OT_add_named_cursor", view3d_ob_drop_poll, view3d_ob_drop_copy);
+       WM_dropbox_add(lb, "OBJECT_OT_drop_named_material", view3d_mat_drop_poll, view3d_id_drop_copy);
+       WM_dropbox_add(lb, "MESH_OT_drop_named_image", view3d_ima_drop_poll, view3d_id_path_drop_copy);
+}
+
+
+
 /* type callback, not region itself */
 static void view3d_main_area_free(ARegion *ar)
 {
 /* type callback, not region itself */
 static void view3d_main_area_free(ARegion *ar)
 {
@@ -392,27 +523,35 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
        switch(wmn->category) {
                case NC_ANIMATION:
                        switch(wmn->data) {
        switch(wmn->category) {
                case NC_ANIMATION:
                        switch(wmn->data) {
-                               case ND_KEYFRAME_EDIT:
                                case ND_KEYFRAME_PROP:
                                case ND_KEYFRAME_PROP:
-                               case ND_NLA_EDIT:
                                case ND_NLA_ACTCHANGE:
                                case ND_NLA_ACTCHANGE:
-                               case ND_ANIMCHAN_SELECT:
                                        ED_region_tag_redraw(ar);
                                        break;
                                        ED_region_tag_redraw(ar);
                                        break;
+                               case ND_NLA:
+                               case ND_KEYFRAME:
+                                       if (wmn->action == NA_EDITED)
+                                               ED_region_tag_redraw(ar);
+                                       break;
+                               case ND_ANIMCHAN:
+                                       if (wmn->action == NA_SELECTED)
+                                               ED_region_tag_redraw(ar);
+                                       break;
                        }
                        break;
                case NC_SCENE:
                        switch(wmn->data) {
                        }
                        break;
                case NC_SCENE:
                        switch(wmn->data) {
-                               case ND_TRANSFORM:
                                case ND_FRAME:
                                case ND_FRAME:
+                               case ND_TRANSFORM:
                                case ND_OB_ACTIVE:
                                case ND_OB_SELECT:
                                case ND_OB_ACTIVE:
                                case ND_OB_SELECT:
-                                       ED_region_tag_redraw(ar);
-                                       break;
+                               case ND_LAYER:
+                               case ND_RENDER_OPTIONS:
                                case ND_MODE:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
                                case ND_MODE:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
+                       if (wmn->action == NA_EDITED)
+                               ED_region_tag_redraw(ar);
                        break;
                case NC_OBJECT:
                        switch(wmn->data) {
                        break;
                case NC_OBJECT:
                        switch(wmn->data) {
@@ -424,8 +563,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                                case ND_MODIFIER:
                                case ND_CONSTRAINT:
                                case ND_KEYS:
                                case ND_MODIFIER:
                                case ND_CONSTRAINT:
                                case ND_KEYS:
-                               case ND_PARTICLE_SELECT:
-                               case ND_PARTICLE_DATA:
+                               case ND_PARTICLE:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
@@ -437,11 +575,20 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
+                       switch(wmn->action) {
+                               case NA_EDITED:
+                                       ED_region_tag_redraw(ar);
+                                       break;
+                       }
                        break;
                case NC_GROUP:
                        /* all group ops for now */
                        ED_region_tag_redraw(ar);
                        break;
                        break;
                case NC_GROUP:
                        /* all group ops for now */
                        ED_region_tag_redraw(ar);
                        break;
+               case NC_BRUSH:
+                       if(wmn->action == NA_EDITED)
+                               ED_region_tag_redraw_overlay(ar);
+                       break;                  
                case NC_MATERIAL:
                        switch(wmn->data) {
                                case ND_SHADING_DRAW:
                case NC_MATERIAL:
                        switch(wmn->data) {
                                case ND_SHADING_DRAW:
@@ -468,8 +615,27 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                         * more context than just the region */
                        ED_region_tag_redraw(ar);
                        break;
                         * more context than just the region */
                        ED_region_tag_redraw(ar);
                        break;
+               case NC_TEXTURE:        
+                       /* same as above */
+                       ED_region_tag_redraw(ar);
+                       break;
                case NC_SPACE:
                case NC_SPACE:
-                       if(wmn->data == ND_SPACE_VIEW3D)
+                       if(wmn->data == ND_SPACE_VIEW3D) {
+                               if (wmn->subtype == NS_VIEW3D_GPU) {
+                                       RegionView3D *rv3d= ar->regiondata;
+                                       rv3d->rflag |= RV3D_GPULIGHT_UPDATE;
+                               }
+                               ED_region_tag_redraw(ar);
+                       }
+                       break;
+               case NC_ID:
+                       if(wmn->action == NA_RENAME)
+                               ED_region_tag_redraw(ar);
+                       break;
+               case NC_SCREEN:
+                       if(wmn->data == ND_GPENCIL)     
+                               ED_region_tag_redraw(ar);
+                       else if(wmn->data==ND_ANIMPLAY)
                                ED_region_tag_redraw(ar);
                        break;
        }
                                ED_region_tag_redraw(ar);
                        break;
        }
@@ -491,7 +657,7 @@ static void view3d_main_area_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
 /* add handlers, stuff you only do once or on area/region changes */
 static void view3d_header_area_init(wmWindowManager *wm, ARegion *ar)
 {
 /* add handlers, stuff you only do once or on area/region changes */
 static void view3d_header_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       wmKeyMap *keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
        
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
@@ -513,6 +679,8 @@ static void view3d_header_area_listener(ARegion *ar, wmNotifier *wmn)
                                case ND_OB_ACTIVE:
                                case ND_OB_SELECT:
                                case ND_MODE:
                                case ND_OB_ACTIVE:
                                case ND_OB_SELECT:
                                case ND_MODE:
+                               case ND_LAYER:
+                               case ND_TOOLSETTINGS:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
@@ -531,7 +699,7 @@ static void view3d_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 
        ED_region_panels_init(wm, ar);
        
 
        ED_region_panels_init(wm, ar);
        
-       keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -546,12 +714,15 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
        switch(wmn->category) {
                case NC_ANIMATION:
                        switch(wmn->data) {
        switch(wmn->category) {
                case NC_ANIMATION:
                        switch(wmn->data) {
-                               case ND_KEYFRAME_EDIT:
                                case ND_KEYFRAME_PROP:
                                case ND_KEYFRAME_PROP:
-                               case ND_NLA_EDIT:
                                case ND_NLA_ACTCHANGE:
                                        ED_region_tag_redraw(ar);
                                        break;
                                case ND_NLA_ACTCHANGE:
                                        ED_region_tag_redraw(ar);
                                        break;
+                               case ND_NLA:
+                               case ND_KEYFRAME:
+                                       if (wmn->action == NA_EDITED)
+                                               ED_region_tag_redraw(ar);
+                                       break;  
                        }
                        break;
                case NC_SCENE:
                        }
                        break;
                case NC_SCENE:
@@ -560,6 +731,12 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
                                case ND_OB_ACTIVE:
                                case ND_OB_SELECT:
                                case ND_MODE:
                                case ND_OB_ACTIVE:
                                case ND_OB_SELECT:
                                case ND_MODE:
+                               case ND_LAYER:
+                                       ED_region_tag_redraw(ar);
+                                       break;
+                       }
+                       switch(wmn->action) {
+                               case NA_EDITED:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
@@ -584,6 +761,10 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
                                        break;
                        }
                        break;
                                        break;
                        }
                        break;
+               case NC_TEXTURE:
+                       /* for brush textures */
+                       ED_region_tag_redraw(ar);
+                       break;
                case NC_BRUSH:
                        if(wmn->action==NA_EDITED)
                                ED_region_tag_redraw(ar);
                case NC_BRUSH:
                        if(wmn->action==NA_EDITED)
                                ED_region_tag_redraw(ar);
@@ -592,6 +773,14 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
                        if(wmn->data == ND_SPACE_VIEW3D)
                                ED_region_tag_redraw(ar);
                        break;
                        if(wmn->data == ND_SPACE_VIEW3D)
                                ED_region_tag_redraw(ar);
                        break;
+               case NC_ID:
+                       if(wmn->action == NA_RENAME)
+                               ED_region_tag_redraw(ar);
+                       break;
+               case NC_SCREEN: 
+                       if(wmn->data == ND_GPENCIL)
+                               ED_region_tag_redraw(ar);
+                       break;
        }
 }
 
        }
 }
 
@@ -602,7 +791,7 @@ static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar)
        
        ED_region_panels_init(wm, ar);
 
        
        ED_region_panels_init(wm, ar);
 
-       keymap= WM_keymap_find(wm, "View3D Generic", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -611,6 +800,25 @@ static void view3d_tools_area_draw(const bContext *C, ARegion *ar)
        ED_region_panels(C, ar, 1, CTX_data_mode_string(C), -1);
 }
 
        ED_region_panels(C, ar, 1, CTX_data_mode_string(C), -1);
 }
 
+static void view3d_props_area_listener(ARegion *ar, wmNotifier *wmn)
+{
+       /* context changes */
+       switch(wmn->category) {
+               case NC_WM:
+                       if(wmn->data == ND_HISTORY)
+                               ED_region_tag_redraw(ar);
+                       break;
+               case NC_SCENE:
+                       if(wmn->data == ND_MODE)
+                               ED_region_tag_redraw(ar);
+                       break;
+               case NC_SPACE:
+                       if(wmn->data == ND_SPACE_VIEW3D)
+                               ED_region_tag_redraw(ar);
+                       break;
+       }
+}
+
 static int view3d_context(const bContext *C, const char *member, bContextDataResult *result)
 {
        View3D *v3d= CTX_wm_view3d(C);
 static int view3d_context(const bContext *C, const char *member, bContextDataResult *result)
 {
        View3D *v3d= CTX_wm_view3d(C);
@@ -620,11 +828,9 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
 
        if(CTX_data_dir(member)) {
                static const char *dir[] = {
 
        if(CTX_data_dir(member)) {
                static const char *dir[] = {
-                       "selected_objects", "selected_bases" "selected_editable_objects",
-                       "selected_editable_bases" "visible_objects", "visible_bases", "selectable_objects", "selectable_bases",
-                       "active_base", "active_object", "visible_bones", "editable_bones",
-                       "selected_bones", "selected_editable_bones" "visible_pchans",
-                       "selected_pchans", "active_bone", "active_pchan", NULL};
+                       "selected_objects", "selected_bases", "selected_editable_objects",
+                       "selected_editable_bases", "visible_objects", "visible_bases", "selectable_objects", "selectable_bases",
+                       "active_base", "active_object", NULL};
 
                CTX_data_dir_set(result, dir);
        }
 
                CTX_data_dir_set(result, dir);
        }
@@ -637,11 +843,11 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                                        if(selected_objects)
                                                CTX_data_id_list_add(result, &base->object->id);
                                        else
                                        if(selected_objects)
                                                CTX_data_id_list_add(result, &base->object->id);
                                        else
-                                               CTX_data_list_add(result, &scene->id, &RNA_UnknownType, base);
+                                               CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
                                }
                        }
                }
                                }
                        }
                }
-
+               CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
                return 1;
        }
        else if(CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) {
                return 1;
        }
        else if(CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) {
@@ -654,12 +860,12 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                                                if(selected_editable_objects)
                                                        CTX_data_id_list_add(result, &base->object->id);
                                                else
                                                if(selected_editable_objects)
                                                        CTX_data_id_list_add(result, &base->object->id);
                                                else
-                                                       CTX_data_list_add(result, &scene->id, &RNA_UnknownType, base);
+                                                       CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
                                        }
                                }
                        }
                }
                                        }
                                }
                        }
                }
-               
+               CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
                return 1;
        }
        else if(CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) {
                return 1;
        }
        else if(CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) {
@@ -671,11 +877,11 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                                        if(visible_objects)
                                                CTX_data_id_list_add(result, &base->object->id);
                                        else
                                        if(visible_objects)
                                                CTX_data_id_list_add(result, &base->object->id);
                                        else
-                                               CTX_data_list_add(result, &scene->id, &RNA_UnknownType, base);
+                                               CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
                                }
                        }
                }
                                }
                        }
                }
-               
+               CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
                return 1;
        }
        else if(CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) {
                return 1;
        }
        else if(CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) {
@@ -687,17 +893,17 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                                        if(selectable_objects)
                                                CTX_data_id_list_add(result, &base->object->id);
                                        else
                                        if(selectable_objects)
                                                CTX_data_id_list_add(result, &base->object->id);
                                        else
-                                               CTX_data_list_add(result, &scene->id, &RNA_UnknownType, base);
+                                               CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
                                }
                        }
                }
                                }
                        }
                }
-               
+               CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
                return 1;
        }
        else if(CTX_data_equals(member, "active_base")) {
                if(scene->basact && (scene->basact->lay & lay))
                        if((scene->basact->object->restrictflag & OB_RESTRICT_VIEW)==0)
                return 1;
        }
        else if(CTX_data_equals(member, "active_base")) {
                if(scene->basact && (scene->basact->lay & lay))
                        if((scene->basact->object->restrictflag & OB_RESTRICT_VIEW)==0)
-                               CTX_data_pointer_set(result, &scene->id, &RNA_UnknownType, scene->basact);
+                               CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, scene->basact);
                
                return 1;
        }
                
                return 1;
        }
@@ -708,156 +914,30 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                
                return 1;
        }
                
                return 1;
        }
-       else if(CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) {
-               Object *obedit= scene->obedit; // XXX get from context?
-               bArmature *arm= (obedit) ? obedit->data : NULL;
-               EditBone *ebone, *flipbone=NULL;
-               int editable_bones= CTX_data_equals(member, "editable_bones");
-               
-               if (arm && arm->edbo) {
-                       /* Attention: X-Axis Mirroring is also handled here... */
-                       for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
-                               /* first and foremost, bone must be visible and selected */
-                               if (EBONE_VISIBLE(arm, ebone)) {
-                                       /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
-                                        * so that most users of this data don't need to explicitly check for it themselves.
-                                        * 
-                                        * We need to make sure that these mirrored copies are not selected, otherwise some
-                                        * bones will be operated on twice.
-                                        */
-                                       if (arm->flag & ARM_MIRROR_EDIT)
-                                               flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
-                                       
-                                       /* if we're filtering for editable too, use the check for that instead, as it has selection check too */
-                                       if (editable_bones) {
-                                               /* only selected + editable */
-                                               if (EBONE_EDITABLE(ebone)) {
-                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
-                                               
-                                                       if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
-                                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
-                                               }
-                                       }
-                                       else {
-                                               /* only include bones if visible */
-                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
-                                               
-                                               if ((flipbone) && EBONE_VISIBLE(arm, flipbone)==0)
-                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
-                                       }
-                               }
-                       }       
-                       
-                       return 1;
-               }
-       }
-       else if(CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) {
-               Object *obedit= scene->obedit; // XXX get from context?
-               bArmature *arm= (obedit) ? obedit->data : NULL;
-               EditBone *ebone, *flipbone=NULL;
-               int selected_editable_bones= CTX_data_equals(member, "selected_editable_bones");
-               
-               if (arm && arm->edbo) {
-                       /* Attention: X-Axis Mirroring is also handled here... */
-                       for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
-                               /* first and foremost, bone must be visible and selected */
-                               if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) {
-                                       /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
-                                        * so that most users of this data don't need to explicitly check for it themselves.
-                                        * 
-                                        * We need to make sure that these mirrored copies are not selected, otherwise some
-                                        * bones will be operated on twice.
-                                        */
-                                       if (arm->flag & ARM_MIRROR_EDIT)
-                                               flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
-                                       
-                                       /* if we're filtering for editable too, use the check for that instead, as it has selection check too */
-                                       if (selected_editable_bones) {
-                                               /* only selected + editable */
-                                               if (EBONE_EDITABLE(ebone)) {
-                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
-                                               
-                                                       if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
-                                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
-                                               }
-                                       }
-                                       else {
-                                               /* only include bones if selected */
-                                               CTX_data_list_add(result, &arm->id, &RNA_UnknownType, ebone);
-                                               
-                                               if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
-                                                       CTX_data_list_add(result, &arm->id, &RNA_UnknownType, flipbone);
-                                       }
-                               }
-                       }       
-                       
-                       return 1;
-               }
-       }
-       else if(CTX_data_equals(member, "visible_pchans")) {
-               Object *obact= OBACT;
-               bArmature *arm= (obact) ? obact->data : NULL;
-               bPoseChannel *pchan;
-               
-               if (obact && arm) {
-                       for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
-                               /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
-                               if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
-                                       CTX_data_list_add(result, &obact->id, &RNA_PoseChannel, pchan);
-                               }
-                       }
-                       
-                       return 1;
-               }
-       }
-       else if(CTX_data_equals(member, "selected_pchans")) {
-               Object *obact= OBACT;
-               bArmature *arm= (obact) ? obact->data : NULL;
-               bPoseChannel *pchan;
-               
-               if (obact && arm) {
-                       for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) {
-                               /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
-                               if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
-                                       if (pchan->bone->flag & (BONE_SELECTED|BONE_ACTIVE)) 
-                                               CTX_data_list_add(result, &obact->id, &RNA_PoseChannel, pchan);
-                               }
-                       }
-                       
-                       return 1;
-               }
+       else {
+               return 0; /* not found */
        }
        }
-       else if(CTX_data_equals(member, "active_bone")) {
-               Object *obedit= scene->obedit; // XXX get from context?
-               bArmature *arm= (obedit) ? obedit->data : NULL;
-               EditBone *ebone;
-               
-               if (arm && arm->edbo) {
-                       for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
-                               if (EBONE_VISIBLE(arm, ebone)) {
-                                       if (ebone->flag & BONE_ACTIVE) {
-                                               CTX_data_pointer_set(result, &arm->id, &RNA_UnknownType, ebone);
-                                               
-                                               return 1;
-                                       }
-                               }
+
+       return -1; /* found but not available */
+}
+
+/*area (not region) level listener*/
+#if 0 // removed since BKE_image_user_calc_frame is now called in draw_bgpic because screen_ops doesnt call the notifier.
+void space_view3d_listener(struct ScrArea *area, struct wmNotifier *wmn)
+{
+       if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) {
+               View3D *v3d = area->spacedata.first;
+               BGpic *bgpic = v3d->bgpicbase.first;
+
+               for (; bgpic; bgpic = bgpic->next) {
+                       if (bgpic->ima) {
+                               Scene *scene = wmn->reference;
+                               BKE_image_user_calc_frame(&bgpic->iuser, scene->r.cfra, 0);
                        }
                }
                        }
                }
-               
-       }
-       else if(CTX_data_equals(member, "active_pchan")) {
-               Object *obact= OBACT;
-               bPoseChannel *pchan;
-               
-               pchan= get_active_posechannel(obact);
-               if (pchan) {
-                       CTX_data_pointer_set(result, &obact->id, &RNA_PoseChannel, pchan);
-                       return 1;
-               }
        }
        }
-
-       return 0;
 }
 }
+#endif
 
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_view3d(void)
 
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_view3d(void)
@@ -866,19 +946,22 @@ void ED_spacetype_view3d(void)
        ARegionType *art;
        
        st->spaceid= SPACE_VIEW3D;
        ARegionType *art;
        
        st->spaceid= SPACE_VIEW3D;
+       strncpy(st->name, "View3D", BKE_ST_MAXNAME);
        
        st->new= view3d_new;
        st->free= view3d_free;
        st->init= view3d_init;
        
        st->new= view3d_new;
        st->free= view3d_free;
        st->init= view3d_init;
+//     st->listener = space_view3d_listener;
        st->duplicate= view3d_duplicate;
        st->operatortypes= view3d_operatortypes;
        st->keymap= view3d_keymap;
        st->duplicate= view3d_duplicate;
        st->operatortypes= view3d_operatortypes;
        st->keymap= view3d_keymap;
+       st->dropboxes= view3d_dropboxes;
        st->context= view3d_context;
        
        /* regions: main window */
        art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
        art->regionid = RGN_TYPE_WINDOW;
        st->context= view3d_context;
        
        /* regions: main window */
        art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
        art->regionid = RGN_TYPE_WINDOW;
-       art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_GPENCIL;
+       art->keymapflag= ED_KEYMAP_GPENCIL;
        art->draw= view3d_main_area_draw;
        art->init= view3d_main_area_init;
        art->free= view3d_main_area_free;
        art->draw= view3d_main_area_draw;
        art->init= view3d_main_area_init;
        art->free= view3d_main_area_free;
@@ -890,7 +973,7 @@ void ED_spacetype_view3d(void)
        /* regions: listview/buttons */
        art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
        art->regionid = RGN_TYPE_UI;
        /* regions: listview/buttons */
        art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
        art->regionid = RGN_TYPE_UI;
-       art->minsizex= 180; // XXX
+       art->prefsizex= 180; // XXX
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
        art->listener= view3d_buttons_area_listener;
        art->init= view3d_buttons_area_init;
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
        art->listener= view3d_buttons_area_listener;
        art->init= view3d_buttons_area_init;
@@ -902,23 +985,23 @@ void ED_spacetype_view3d(void)
        /* regions: tool(bar) */
        art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
        art->regionid = RGN_TYPE_TOOLS;
        /* regions: tool(bar) */
        art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
        art->regionid = RGN_TYPE_TOOLS;
-       art->minsizex= 160; // XXX
-       art->minsizey= 50; // XXX
+       art->prefsizex= 160; // XXX
+       art->prefsizey= 50; // XXX
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
        art->listener= view3d_buttons_area_listener;
        art->init= view3d_tools_area_init;
        art->draw= view3d_tools_area_draw;
        BLI_addhead(&st->regiontypes, art);
        
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
        art->listener= view3d_buttons_area_listener;
        art->init= view3d_tools_area_init;
        art->draw= view3d_tools_area_draw;
        BLI_addhead(&st->regiontypes, art);
        
-       view3d_toolbar_register(art);
+       view3d_toolshelf_register(art);
 
        /* regions: tool properties */
        art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
        art->regionid = RGN_TYPE_TOOL_PROPS;
 
        /* regions: tool properties */
        art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
        art->regionid = RGN_TYPE_TOOL_PROPS;
-       art->minsizex= 0;
-       art->minsizey= 120;
+       art->prefsizex= 0;
+       art->prefsizey= 120;
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
-       art->listener= view3d_buttons_area_listener;
+       art->listener= view3d_props_area_listener;
        art->init= view3d_tools_area_init;
        art->draw= view3d_tools_area_draw;
        BLI_addhead(&st->regiontypes, art);
        art->init= view3d_tools_area_init;
        art->draw= view3d_tools_area_draw;
        BLI_addhead(&st->regiontypes, art);
@@ -929,8 +1012,8 @@ void ED_spacetype_view3d(void)
        /* regions: header */
        art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
        art->regionid = RGN_TYPE_HEADER;
        /* regions: header */
        art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
        art->regionid = RGN_TYPE_HEADER;
-       art->minsizey= HEADERY;
-       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
+       art->prefsizey= HEADERY;
+       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
        art->listener= view3d_header_area_listener;
        art->init= view3d_header_area_init;
        art->draw= view3d_header_area_draw;
        art->listener= view3d_header_area_listener;
        art->init= view3d_header_area_init;
        art->draw= view3d_header_area_draw;