Beispiel #1
0
        public static DocSet GetDocSetInstance(int min, int max, int count, FOCUS hint)
        {
            // Default to Medians
            if (min == -1 || max == -1 || count == -1)
            {
                min   = DEFAULT_MIN;
                max   = DEFAULT_MAX;
                count = DEFAULT_COUNT;
            }
            else
            {
                Bucket(min, Act.Min);
                Bucket(max, Act.Max);
                Bucket(count, Act.Count);
            }

            INVOKE++;
            if (INVOKE == long.MaxValue)
            {
                INVOKE = 10000L;
            }

            switch (hint)
            {
            // Always Favor IntArray or OpenBitSet
            case FOCUS.PERFORMANCE:
                if ((((max - min) >> LONG_SHIFT) + 1) * 2 * INT_SIZE > count * INT_SIZE)
                {
                    return(new IntArrayDocIdSet(count));
                }
                else
                {
                    //return new IntArrayDocIdSet(count);
                    return(new OBSDocIdSet(max - min + 1));
                }

            // Always Favor BitSet or Compression
            case FOCUS.SPACE:
                if ((max - min) / count < BITSET_COMP_SWAP_RATIO)
                {
                    return(new OBSDocIdSet(max - min + 1));
                }
                else
                {
                    return(new P4DDocIdSet());
                }

            // All cases in consideration
            case FOCUS.OPTIMAL:
                if ((max - min) / count > BITSET_COMP_SWAP_RATIO)
                {
                    if (count < AbstractDocSet.DEFAULT_BATCH_SIZE)
                    {
                        return(new IntArrayDocIdSet(count));
                    }
                    else
                    {
                        return(new P4DDocIdSet());
                    }
                }
                else if ((((max - min) >> LONG_SHIFT) + 1) * 2 * INT_SIZE > count * INT_SIZE)
                {
                    return(new IntArrayDocIdSet(count));
                }
                else
                {
                    return(new OBSDocIdSet(max - min + 1));
                }
            }

            return(new IntArrayDocIdSet(count));
        }
        public static DocSet GetDocSetInstance(int min, int max, int count, FOCUS hint)
        {
            // Default to Medians
            if (min == -1 || max == -1 || count == -1)
            {
                min = DEFAULT_MIN;
                max = DEFAULT_MAX;
                count = DEFAULT_COUNT;
            }
            else
            {
                Bucket(min, Act.Min);
                Bucket(max, Act.Max);
                Bucket(count, Act.Count);
            }

            INVOKE++;
            if (INVOKE == long.MaxValue)
                INVOKE = 10000L;

            switch (hint)
            {
                // Always Favor IntArray or OpenBitSet
                case FOCUS.PERFORMANCE:
                    if ((((max - min) >> LONG_SHIFT) + 1) * 2 * INT_SIZE > count * INT_SIZE)
                    {
                        return new IntArrayDocIdSet(count);
                    }
                    else
                    {
                        //return new IntArrayDocIdSet(count);
                        return new OBSDocIdSet(max - min + 1);
                    }

                // Always Favor BitSet or Compression   
                case FOCUS.SPACE:
                    if ((max - min) / count < BITSET_COMP_SWAP_RATIO)
                    {
                        return new OBSDocIdSet(max - min + 1);
                    }
                    else
                    {
                        return new P4DDocIdSet();
                    }

                // All cases in consideration  
                case FOCUS.OPTIMAL:
                    if ((max - min) / count > BITSET_COMP_SWAP_RATIO)
                    {
                        if (count < AbstractDocSet.DEFAULT_BATCH_SIZE)
                        {
                            return new IntArrayDocIdSet(count);
                        }
                        else
                        {
                            return new P4DDocIdSet();
                        }
                    }
                    else if ((((max - min) >> LONG_SHIFT) + 1) * 2 * INT_SIZE > count * INT_SIZE)
                    {
                        return new IntArrayDocIdSet(count);
                    }
                    else
                    {
                        return new OBSDocIdSet(max - min + 1);
                    }
            }

            return new IntArrayDocIdSet(count);
        }
Beispiel #3
0
        public Mini(string[] args)
        {
            if (args.Length > 0)
            {
                if (args[0].Equals("--version"))
                {
                    Console.WriteLine(VERSION_STRING);
                    Environment.Exit(0);
                }
            }

            XGCValues            gv;
            XSetWindowAttributes sattr;

            focused_client = null;
            focus_model    = DEFAULT_FOCUS_MODEL;

            //  for (int i = 0; i < argc; i++)
            //    command_line = command_line + argv[i] + " ";

            try {
                dpy = new XDisplay(":0");

                try {
                    font = new XFont(dpy, DEFAULT_FONT);
                } catch {
                    font = new XFont(dpy, "Fixed");
                }
            } catch (Exception e) {
                Console.WriteLine("{0} check your DISPLAY variable.", e.Message);
                Environment.Exit(-1);
            }

            XEvent ev = new XEvent(dpy);

            ev.ErrorHandlerEvent += new ErrorHandler(ErrorHandler);

            // SET UP ATOMS
            atom_wm_state        = new XAtom(dpy, "WM_STATE", false);
            atom_wm_change_state = new XAtom(dpy, "WM_CHANGE_STATE", false);
            atom_wm_protos       = new XAtom(dpy, "WM_PROTOCOLS", false);
            atom_wm_delete       = new XAtom(dpy, "WM_DELETE_WINDOW", false);
            atom_wm_takefocus    = new XAtom(dpy, "WM_TAKE_FOCUS", false);

            XSetWindowAttributes pattr = new XSetWindowAttributes();

            pattr.override_redirect = true;
            _button_proxy_win       = new XWindow(dpy, new Rectangle(-80, -80, 24, 24));
            _button_proxy_win.ChangeAttributes(XWindowAttributeFlags.CWOverrideRedirect, pattr);

            // SETUP COLORS USED FOR WINDOW TITLE BARS and WINDOW BORDERS
            fg               = new XColor(dpy, DEFAULT_FOREGROUND_COLOR);
            bg               = new XColor(dpy, DEFAULT_BACKGROUND_COLOR);
            bd               = new XColor(dpy, DEFAULT_BORDER_COLOR);
            fc               = new XColor(dpy, DEFAULT_FOCUS_COLOR);
            focused_border   = new XColor(dpy, FOCUSED_BORDER_COLOR);
            unfocused_border = new XColor(dpy, UNFOCUSED_BORDER_COLOR);

            //shape = XShapeQueryExtension(dpy, &shape_event, &dummy);

            move_curs  = new XCursor(dpy, XCursors.XC_fleur);
            arrow_curs = new XCursor(dpy, XCursors.XC_left_ptr);

            root.DefineCursor(arrow_curs);

            gv.function   = XGCFunctionMask.GXcopy;
            gv.foreground = fg.Pixel;
            gv.font       = font.FID;
            string_gc     = new XGC(dpy, root, XGCValuesMask.GCFunction | XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

            gv.foreground = unfocused_border.Pixel;
            unfocused_gc  = new XGC(dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

            gv.foreground    = fg.Pixel;
            focused_title_gc = new XGC(dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

            gv.foreground = bd.Pixel;
            gv.line_width = DEFAULT_BORDER_WIDTH;
            border_gc     = new XGC(dpy, root, XGCValuesMask.GCFunction | XGCValuesMask.GCForeground | XGCValuesMask.GCLineWidth, gv);

            gv.foreground     = fg.Pixel;
            gv.function       = XGCFunctionMask.GXinvert;
            gv.subwindow_mode = XSubwindowMode.IncludeInferiors;
            invert_gc         = new XGC(dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFunction | XGCValuesMask.GCSubwindowMode | XGCValuesMask.GCLineWidth | XGCValuesMask.GCFont, gv);

            sattr.event_mask = XEventMask.SubstructureRedirectMask | XEventMask.SubstructureNotifyMask | XEventMask.ButtonPressMask | XEventMask.ButtonReleaseMask | XEventMask.FocusChangeMask | XEventMask.EnterWindowMask | XEventMask.LeaveWindowMask | XEventMask.PropertyChangeMask | XEventMask.ButtonMotionMask;

            root.ChangeAttributes(XWindowAttributeFlags.CWEventMask, sattr);

            queryWindowTree();

            ev.KeyPressHandlerEvent         += new KeyPressHandler(handleKeyPressEvent);
            ev.ButtonPressHandlerEvent      += new ButtonPressHandler(handleButtonPressEvent);
            ev.ButtonReleaseHandlerEvent    += new ButtonReleaseHandler(handleButtonReleaseEvent);
            ev.ConfigureRequestHandlerEvent += new ConfigureRequestHandler(handleConfigureRequestEvent);
            ev.MotionNotifyHandlerEvent     += new MotionNotifyHandler(handleMotionNotifyEvent);
            ev.MapRequestHandlerEvent       += new MapRequestHandler(handleMapRequestEvent);
            ev.UnmapNotifyHandlerEvent      += new UnmapNotifyHandler(handleUnmapNotifyEvent);
            ev.DestroyNotifyHandlerEvent    += new DestroyNotifyHandler(handleDestroyNotifyEvent);
            ev.EnterNotifyHandlerEvent      += new EnterNotifyHandler(handleEnterNotifyEvent);
            ev.FocusInHandlerEvent          += new FocusInHandler(handleFocusInEvent);
            ev.FocusOutHandlerEvent         += new FocusOutHandler(handleFocusOutEvent);
            ev.PropertyNotifyHandlerEvent   += new PropertyNotifyHandler(handlePropertyNotifyEvent);
            ev.ExposeHandlerEvent           += new ExposeHandler(handleExposeEvent);
            ev.ShapeHandlerEvent            += new ShapeHandler(handleShapeEvent);
        }
Beispiel #4
0
        public Mini(string[] args)
        {
            if (args.Length > 0) {
            if (args[0].Equals ("--version")) {
              Console.WriteLine (VERSION_STRING);
              Environment.Exit (0);
            }
              }

              XGCValues gv;
              XSetWindowAttributes sattr;
              focused_client = null;
              focus_model = DEFAULT_FOCUS_MODEL;

              //  for (int i = 0; i < argc; i++)
              //    command_line = command_line + argv[i] + " ";

              try {
            dpy = new XDisplay (":0");

            try {
              font = new XFont (dpy, DEFAULT_FONT);
            } catch {
              font = new XFont (dpy, "Fixed");
            }
              } catch (Exception e) {
            Console.WriteLine ("{0} check your DISPLAY variable.", e.Message);
            Environment.Exit (-1);
              }

              XEvent ev = new XEvent (dpy);
              ev.ErrorHandlerEvent += new ErrorHandler (ErrorHandler);

              // SET UP ATOMS
              atom_wm_state = new XAtom (dpy, "WM_STATE", false);
              atom_wm_change_state = new XAtom (dpy, "WM_CHANGE_STATE", false);
              atom_wm_protos = new XAtom (dpy, "WM_PROTOCOLS", false);
              atom_wm_delete = new XAtom (dpy, "WM_DELETE_WINDOW", false);
              atom_wm_takefocus = new XAtom (dpy, "WM_TAKE_FOCUS", false);

              XSetWindowAttributes pattr = new XSetWindowAttributes ();
              pattr.override_redirect = true;
              _button_proxy_win = new XWindow (dpy, new Rectangle (-80, -80, 24, 24));
              _button_proxy_win.ChangeAttributes (XWindowAttributeFlags.CWOverrideRedirect, pattr);

              // SETUP COLORS USED FOR WINDOW TITLE BARS and WINDOW BORDERS
              fg = new XColor (dpy, DEFAULT_FOREGROUND_COLOR);
              bg = new XColor (dpy, DEFAULT_BACKGROUND_COLOR);
              bd = new XColor (dpy, DEFAULT_BORDER_COLOR);
              fc = new XColor (dpy, DEFAULT_FOCUS_COLOR);
              focused_border = new XColor (dpy, FOCUSED_BORDER_COLOR);
              unfocused_border = new XColor (dpy, UNFOCUSED_BORDER_COLOR);

              //shape = XShapeQueryExtension(dpy, &shape_event, &dummy);

              move_curs = new XCursor (dpy, XCursors.XC_fleur);
              arrow_curs = new XCursor (dpy, XCursors.XC_left_ptr);

              root.DefineCursor (arrow_curs);

              gv.function = XGCFunctionMask.GXcopy;
              gv.foreground = fg.Pixel;
              gv.font = font.FID;
              string_gc = new XGC (dpy, root, XGCValuesMask.GCFunction | XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

              gv.foreground = unfocused_border.Pixel;
              unfocused_gc = new XGC (dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

              gv.foreground = fg.Pixel;
              focused_title_gc = new XGC (dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

              gv.foreground = bd.Pixel;
              gv.line_width = DEFAULT_BORDER_WIDTH;
              border_gc = new XGC (dpy, root, XGCValuesMask.GCFunction | XGCValuesMask.GCForeground | XGCValuesMask.GCLineWidth, gv);

              gv.foreground = fg.Pixel;
              gv.function = XGCFunctionMask.GXinvert;
              gv.subwindow_mode = XSubwindowMode.IncludeInferiors;
              invert_gc = new XGC (dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFunction | XGCValuesMask.GCSubwindowMode | XGCValuesMask.GCLineWidth | XGCValuesMask.GCFont, gv);

              sattr.event_mask = XEventMask.SubstructureRedirectMask | XEventMask.SubstructureNotifyMask | XEventMask.ButtonPressMask | XEventMask.ButtonReleaseMask | XEventMask.FocusChangeMask | XEventMask.EnterWindowMask | XEventMask.LeaveWindowMask | XEventMask.PropertyChangeMask | XEventMask.ButtonMotionMask;

              root.ChangeAttributes (XWindowAttributeFlags.CWEventMask, sattr);

              queryWindowTree ();

              ev.KeyPressHandlerEvent += new KeyPressHandler (handleKeyPressEvent);
              ev.ButtonPressHandlerEvent += new ButtonPressHandler (handleButtonPressEvent);
              ev.ButtonReleaseHandlerEvent += new ButtonReleaseHandler (handleButtonReleaseEvent);
              ev.ConfigureRequestHandlerEvent += new ConfigureRequestHandler (handleConfigureRequestEvent);
              ev.MotionNotifyHandlerEvent += new MotionNotifyHandler (handleMotionNotifyEvent);
              ev.MapRequestHandlerEvent += new MapRequestHandler (handleMapRequestEvent);
              ev.UnmapNotifyHandlerEvent += new UnmapNotifyHandler (handleUnmapNotifyEvent);
              ev.DestroyNotifyHandlerEvent += new DestroyNotifyHandler (handleDestroyNotifyEvent);
              ev.EnterNotifyHandlerEvent += new EnterNotifyHandler (handleEnterNotifyEvent);
              ev.FocusInHandlerEvent += new FocusInHandler (handleFocusInEvent);
              ev.FocusOutHandlerEvent += new FocusOutHandler (handleFocusOutEvent);
              ev.PropertyNotifyHandlerEvent += new PropertyNotifyHandler (handlePropertyNotifyEvent);
              ev.ExposeHandlerEvent += new ExposeHandler (handleExposeEvent);
              ev.ShapeHandlerEvent += new ShapeHandler (handleShapeEvent);
        }