Exemple #1
0
        public WindowResizeTest()
        {
            t = new Timer ();

              dpy = new XDisplay ();
              s = new XScreen (dpy);
              ev = new XEvent (dpy);
              pointer = new XPointer (dpy);
              gc = new XGC (dpy);

              //XShape shape = new XShape(dpy);
              //shape.Query();
              //Console.WriteLine("Shape Event Type Number = {0}", shape.Type.ToString());

              //atom = new XAtom (dpy, "_MAJYK_HINT", false);

              // Used to test the XPM function that reads a pixmap from a char**
            //      pix_data = new string[] {
            //            "16 16 16 1",
            //            "   c None",
            //            ". c #323232",
            //            "+  c #535353",
            //            "@  c #4A8A8E",
            //            "#  c #DEE2E2",
            //            "$  c #7E827A",
            //            "%  c #8A9292",
            //            "&  c #D6D6D6",
            //            "*  c #36767E",
            //            "=  c #9E9E9E",
            //            "-  c #FAFAFA",
            //            ";  c #B2B2B2",
            //            ">  c #DEEEEA",
            //            ",  c #464646",
            //            "'  c #5EA2A2",
            //            ")  c #52969A",
            //            "                ",
            //            "                ",
            //            " --#>>>>>>#-#-; ",
            //            " -&%')))))=&=&+ ",
            //            " >;$@*****=;%;+ ",
            //            " &$$$$$$$$$$$$, ",
            //            " &;;;;;;;;;;;;+ ",
            //            " &;;;;;;;;;;;;+ ",
            //            " #;;;;;;;;;;;;+ ",
            //            " &;;;;;;;;;;;;+ ",
            //            " #;;;;;;;;;;;;+ ",
            //            " #;;;;;;;;;;;;+ ",
            //            " &;;;;;;;;;;;;+ ",
            //            " $............. ",
            //            "                ",
            //            "                "
            //      };

              bg_color = new XColor (dpy, "#AAAAAA");
              handle_color = new XColor (dpy, "#FF0000");

              //bg_color = new XColor(dpy, Color.FromArgb(200, 200, 200));
              //handle_color = new XColor(dpy, Color.FromArgb(0, 255, 0));

              main_win = new XWindow (dpy, new Rectangle (5, 5, 640, 480), 0, s.BlackPixel (), s.WhitePixel ());

              main_win.Name = "Window Resize Test";
              main_win.SelectInput (XEventMask.KeyPressMask | XEventMask.ExposureMask);

              resize_main_win = new XWindow (dpy, main_win, new Rectangle (resize_win_x, resize_win_y, resize_win_width, resize_win_height), 1, s.BlackPixel (), bg_color.Pixel);
              resize_top_left_win = new XWindow (dpy, resize_main_win, new Rectangle (0, 0, resize_handle_width, resize_handle_height), 1, s.BlackPixel (), handle_color.Pixel);
              resize_top_right_win = new XWindow (dpy, resize_main_win, new Rectangle (0, 0, resize_handle_width, resize_handle_height), 1, s.BlackPixel (), handle_color.Pixel);
              resize_bottom_left_win = new XWindow (dpy, resize_main_win, new Rectangle (0, 0, resize_handle_width, resize_handle_height), 1, s.BlackPixel (), handle_color.Pixel);
              resize_bottom_right_win = new XWindow (dpy, resize_main_win, new Rectangle (0, 0, resize_handle_width, resize_handle_height), 1, s.BlackPixel (), handle_color.Pixel);

              //string foo="MAJYK!";
              //resize_main_win.ChangeProperty(atom, atom, 8, PropMode.PropModeReplace, Marshal.StringToHGlobalAnsi(foo), foo.Length);

              //int return_type=0;
              //int actual_format=0;
              //int nitems=0;
              //int bytes_return=0;
              //IntPtr data = IntPtr.Zero;

              //resize_main_win.GetProperty(atom, 0, 2, false, atom, out return_type, out actual_format, out nitems, out bytes_return, out data);

              //string z = Marshal.PtrToStringAnsi(data);
              //Console.WriteLine("nitems = {0}, z = {1}", nitems, z);

              //pix = new XPixmap (dpy);

              //if (pix.ReadPixmapFromData (resize_main_win, pix_data)) {
              //  resize_main_win.SetBackgroundPixmap (pix);

              //  Console.WriteLine ("pixmap w = {0} | h = {1}", pix.Width.ToString (), pix.Height.ToString ());
              //}

              resize_main_win.SetBackgroundColor (Color.Gray);

              // Test TransientFor
              //resize_main_win.SetTransientForHint(main_win);
              //Window foo = resize_main_win.GetTransientForHint();
              //Console.WriteLine("resize_main_win = {0} | foo.transient_for = {1} | main_win = {2}", resize_main_win.ID.ToString(), foo.ID.ToString(), main_win.ID.ToString());

              XEventMask mask = XEventMask.ButtonPressMask | XEventMask.ButtonReleaseMask;

              resize_main_win.SelectInput (mask);
              resize_top_left_win.SelectInput (mask);
              resize_top_right_win.SelectInput (mask);
              resize_bottom_left_win.SelectInput (mask);
              resize_bottom_right_win.SelectInput (mask);

              PlaceHandles ();

              resize_main_win.MapSubwindows ();
              main_win.MapSubwindows ();
              main_win.Map ();

              ev.KeyPressHandlerEvent += new KeyPressHandler (HandleKeyPress);
              ev.MotionNotifyHandlerEvent += new MotionNotifyHandler (HandleMotionNotify);
              ev.ButtonPressHandlerEvent += new ButtonPressHandler (HandleButtonPress);
              ev.ButtonReleaseHandlerEvent += new ButtonReleaseHandler (HandleButtonRelease);
              ev.ExposeHandlerEvent += new ExposeHandler (HandleExpose);

              t.Interval = 1000;
              t.Enabled = true;
              t.Elapsed += new ElapsedEventHandler (UpdateClock);
              t.Start ();

              ev.Loop ();
        }
Exemple #2
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);
        }