void handleKeyPressEvent(XKeyEvent e, XWindow window, XWindow root, XWindow subwindow) { XKeySym ks = window.KeycodeToKeysym(e.keycode); if (ks== XKeySym.NoSymbol) return; switch(ks) { case XKeySym.XK_Delete: Console.WriteLine("Window manager is restarting..."); restart(); break; case XKeySym.XK_End: Console.WriteLine("Window manager is quitting."); quitNicely(); break; } }
public XWindow(XDisplay dpy, XWindow parent, Rectangle geom, int border_width, int border_color, int background_color) { display = dpy; Handle = XCreateSimpleWindow (display.Handle, parent.Handle, geom.X, geom.Y, geom.Width, geom.Height, border_width, border_color, background_color); }
public int Reparent(XWindow p, Point pos) { return XReparentWindow (display.Handle, Handle, p.Handle, pos.X, pos.Y); }
public bool ReadFileToPixmap(XWindow d, string filename) { IntPtr pixmap_return; int shapemask_return; XpmAttributes attr = new XpmAttributes (); attr.valuemask = XPixmapValueMask.XpmSize; if (XpmReadFileToPixmap (display.Handle, d.Handle, filename, out pixmap_return, out shapemask_return, ref attr) == 0) { Handle = pixmap_return; mask = shapemask_return; width = attr.width; height = attr.height; success = true; return true; } return false; }
public XPointerQueryInfo Query(XWindow w) { XPointerQueryInfo pi = new XPointerQueryInfo (); IntPtr root_return, child_return; int root_x_return, root_y_return, win_x_return, win_y_return, mask_return; XQueryPointer (display.Handle, w.Handle, out root_return, out child_return, out root_x_return, out root_y_return, out win_x_return, out win_y_return, out mask_return); pi.root = root_return; pi.child = child_return; pi.root_x = root_x_return; pi.root_y = root_y_return; pi.win_x = win_x_return; pi.win_y = win_y_return; pi.mask = mask_return; return pi; }
public void DefineCursor(XWindow w) { XDefineCursor (display.Handle, w.Handle, Handle); base.Dispose (); }
public XGC(XDisplay dpy, XWindow d, XGCValuesMask valuemask, XGCValues values) { InitGC (dpy, d.Handle, valuemask, values); }
void sendWMDelete(XWindow window) { }
int sendXMessage(XWindow w, XAtom a, long mask, long x) { return 0; }
void handleShapeEvent(XShapeEvent e, XWindow window) { }
void handleUnmapNotifyEvent(XUnmapEvent e, XWindow window) { }
void handlePropertyNotifyEvent(XPropertyEvent e, XWindow window) { }
void handleMotionNotifyEvent(XMotionEvent e, XWindow window, XWindow root, XWindow subwindow) { }
void handleMapRequestEvent(XMapRequestEvent e, XWindow parent, XWindow window) { }
public void HandleMotionNotify(XMotionEvent e, XWindow window, XWindow root, XWindow subwindow) { int xdiff = e.x_root - start.x_root; int ydiff = e.y_root - start.y_root; if ((e.window == resize_top_left_win.ID) || (e.window == resize_bottom_left_win.ID) || (e.window == resize_top_right_win.ID) || (e.window == resize_bottom_right_win.ID)) { if (e.window == resize_top_left_win.ID) ResizeTopLeft (xdiff, ydiff); else if (e.window == resize_bottom_left_win.ID) ResizeBottomLeft (xdiff, ydiff); else if (e.window == resize_top_right_win.ID) ResizeTopRight (xdiff, ydiff); else if (e.window == resize_bottom_right_win.ID) ResizeBottomRight (xdiff, ydiff); if (resize_win_width < min_size || resize_win_height < min_size) return; resize_main_win.MoveResize (new Rectangle (resize_win_x, resize_win_y, resize_win_width, resize_win_height)); DrawClock (); PlaceHandles (); } else if (e.window == resize_main_win.ID) { int x = old_resize_x + (e.x_root - start.x_root); int y = old_resize_y + (e.y_root - start.y_root); resize_main_win.Move (new Point (x, y)); resize_win_x = x; resize_win_y = y; } }
void setWMState(XWindow window, XWindowState state) { }
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 (); }
void ungrabKeys(XWindow w) { foreach (XKeySym key in alt_keys) w.UngrabKey (key, (XModMask.Mod1Mask | XModMask.ControlMask)); }
// public int SendEvent (XWindow w, bool propagate, XEventMask event_mask) // { // return XSendEvent (display.Handle, w.Handle, propagate, event_mask, Handle); // } public int SendClientMessage(XWindow w, XAtom a, bool propagate, XEventMask event_mask) { //XEvent e; //e.type = XEventType.ClientMessage; //e.xclient.window = w; //e.xclient.message_type = a; //e.xclient.format = 32; //e.xclient.data.l[0] = x; //e.xclient.data.l[1] = CurrentTime; //FIXME: SendClientMessage //XClientMessageEvent cm = new XClientMessageEvent (); //cm.window = w.Handle; //cm.message_type = a; //cm.format = 32; //cm.data = new XClientMessageEvent.data (); //return XSendEvent (dpy, w, False, mask, &e); return 0; }
static LinuxController() { dsp = new XDisplay(null); root_window = new XWindow(dsp); }
public int CopyArea(XWindow src, XWindow dest, int src_x, int src_y, int width, int height, int dest_x, int dest_y) { return XCopyArea (display.Handle, src.Handle, dest.Handle, Handle, src_x, src_y, width, height, dest_x, dest_y); }
public void HandleButtonPress(XButtonEvent e, XWindow window, XWindow root, XWindow subwindow) { pointer.Grab (e.window, XEventMask.PointerMotionMask | XEventMask.ButtonReleaseMask); attr = resize_main_win.GetAttributes (); start = e; old_resize_x = resize_win_x; old_resize_y = resize_win_y; }
public bool ReadPixmapFromData(XWindow d, string[] data) { IntPtr pixmap_return; int shapemask_return; XpmAttributes attr = new XpmAttributes (); attr.valuemask = XPixmapValueMask.XpmSize; if (XpmCreatePixmapFromData (display.Handle, d.Handle, data, out pixmap_return, out shapemask_return, ref attr) == 0) { Handle = pixmap_return; mask = shapemask_return; width = attr.width; height = attr.height; //Console.WriteLine ("PIXMAP: W={0} | H={1}", width, height); success = true; return true; } return false; }
public void HandleButtonRelease(XButtonEvent e, XWindow window, XWindow root, XWindow subwindow) { pointer.Ungrab (); }
public int Warp(XWindow src_w, XWindow dest_w, int src_x, int src_y, int src_width, int src_height, int dest_x, int dest_y) { return XWarpPointer (display.Handle, src_w.Handle, dest_w.Handle, src_x, src_y, src_width, src_height, dest_x, dest_y); }
public void HandleExpose(XExposeEvent e, XWindow window) { if (e.window == main_win.ID) { DrawClock (); main_win.DrawString (gc, new Point (10, 20), "Resize / Move test / Clock / Color test... Press 'Q' to quit..."); } }
public List<XWindow> QueryTree() { IntPtr root_return; IntPtr parent_return; IntPtr children_return; int nchildren_return; XQueryTree (display.Handle, Handle, out root_return, out parent_return, out children_return, out nchildren_return); Console.WriteLine ("Total Windows = {0}", nchildren_return); IntPtr[] awins = new IntPtr[nchildren_return]; Marshal.Copy (children_return, awins, 0, awins.Length); List<XWindow> wins = new List<XWindow> (); foreach (IntPtr wid in awins) { XWindow win = new XWindow (display, wid); wins.Add (win); } return wins; }
public void HandleKeyPress(XKeyEvent e, XWindow window, XWindow root, XWindow subwindow) { if (Convert.ToBoolean (main_win.LookupKeysym (ref e) == XKeySym.XK_q)) { Console.WriteLine ("Cleaning up and exiting..."); //pix.Free (); gc.Dispose (); bg_color.Dispose (); handle_color.Dispose (); resize_top_left_win.Dispose (); resize_top_right_win.Dispose (); resize_bottom_left_win.Dispose (); resize_bottom_right_win.Dispose (); resize_main_win.Dispose (); main_win.Dispose (); ev.Dispose (); s.Dispose (); dpy.Dispose (); Environment.Exit (0); } }
public int SetTransientForHint(XWindow prop_window) { return XSetTransientForHint (display.Handle, Handle, prop_window.Handle); }
void handleFocusOutEvent(XFocusChangeEvent e, XWindow window) { }