diff --git a/c/xlib/property.c b/c/xlib/property.c index c4dbaf9..61f8edf 100644 --- a/c/xlib/property.c +++ b/c/xlib/property.c @@ -3,50 +3,23 @@ s48_value Sym_Now; -Generic_Predicate (Atom) - -Generic_Simple_Equal (Atom, ATOM, atom) - -Generic_Print (Atom, "#[atom %lu]", ATOM(x)->atom) - -/* -s48_value Make_Atom (a) Atom a; { - s48_value atom; - - if (a == None) - return Sym_None; - atom = Find_Object (T_Atom, (GENERIC)0, Match_X_Obj, a); - if (S48_NULL_P (atom)) { - atom = Alloc_Object (sizeof (struct S_Atom), T_Atom, 0); - ATOM(atom)->tag = S48_NULL; - ATOM(atom)->atom = a; - Register_Object (atom, (GENERIC)0, (PFO)0, 0); - } - return atom; -} - */ - /* Should be used with care */ s48_value Intern_Atom (s48_value Xdisplay, s48_value name){ Atom a = XInternAtom(EXTRACT_DISPLAY(Xdisplay), s48_extract_string(name), 0); - return s48_enter_integer((long)a); + return ENTER_ATOM(a); } s48_value Find_Atom (s48_value Xdisplay, s48_value name){ Atom a = XInternAtom (EXTRACT_DISPLAY(Xdisplay), s48_extract_string(name), 1); - if (a == None){ - return s48_value s48_enter_symbol(none); - }else{ - return a; - } + return ENTER_ATOM(a); } s48_value Atom_Name (s48_value Xdisplay, s48_value a) { register char *s; // not used: Disalbe_Interrupts - s = XGetAtomName (EXTRACT_DISPLAY Xdisplay, a); + s = XGetAtomName (EXTRACT_DISPLAY(Xdisplay), a); // not used: Enable_Interrupts return s48_enter_string (s); } @@ -146,8 +119,7 @@ s48_value Change_Property(s48_value Xdisplay, s48_value Xwindow, break; } XChangeProperty (EXTRACT_DISPLAY(Xdisplay), EXTRACT_WINDOW(Xwindow), - s48_extract_integer(Xatom_prop), - s48_extract_integer(Xatom_type), + EXTRACT_ATOM(Xatom_prop), EXTRACT_ATOM(Xatom_type), f, m, (unsigned char *)buf, nitems); return S48_UNSPECIFIC; } @@ -155,9 +127,9 @@ s48_value Change_Property(s48_value Xdisplay, s48_value Xwindow, s48_value P_Delete_Property (s48_value Xdisplay, s48_value Xwindow, s48_value Xatom_prop){ - XDeleteProperty (EXTRACT_DISPLAY(Xdisplay), EXTRACT_WINDOW(Xwindow), - s48_extract_integer(Xatom_prop)); - return S48_UNSPECIFIC; + XDeleteProperty (EXTRACT_DISPLAY(Xdisplay), EXTRACT_WINDOW(Xwindow), + EXTRACT_ATOM(Xatom_prop)); + return S48_UNSPECIFIC; } @@ -176,74 +148,38 @@ s48_value Rotate_Properties (s48_value Xdisplay, s48_value Xwindow, s48_value Set_Selection_Owner (s48_value Xdisplay, s48_value Xatom_s, s48_value Xwindow_owner, s58_value time){ - XSetSelectionOwner (EXTRACT_DISPLAY(Xdisplay), s48_extract_integer(Xatom_s), + XSetSelectionOwner (EXTRACT_DISPLAY(Xdisplay), EXTRACT_ATOM(Xatom_s), EXTRACT_WINDOW(Xwindow_owner), EXTRACT_TIME(time)); return S48_UNSPECIFIC; } -/* -static s48_value P_Selection_Owner (d, s) s48_value d, s; { - Check_Type (d, T_Display); - Check_Type (s, T_Atom); - return Make_Window (0, DISPLAY(d)->dpy, - XGetSelectionOwner (DISPLAY(d)->dpy, ATOM(s)->atom)); -} - */ - -s48_value Selection_Owner (s48_value Xdisplay, s48_value Xatom_s){ +s48_value Get_Selection_Owner (s48_value Xdisplay, s48_value Xatom_s){ return ENTER_WINDOW (XGetSelectionOwner (EXTRACT_DISPLAY(Xdisplay), - s48_extract_integer(Xatom_s))); + EXTRACT_ATOM(Xatom_s))); } -/* -static s48_value P_Convert_Selection (s, target, prop, w, time) - s48_value s, target, prop, w, time; { - Atom p = None; - - Check_Type (s, T_Atom); - Check_Type (target, T_Atom); - if (!S48_EQ_P(prop, Sym_None)) { - Check_Type (prop, T_Atom); - p = ATOM(prop)->atom; - } - Check_Type (w, T_Window); - XConvertSelection (WINDOW(w)->dpy, ATOM(s)->atom, ATOM(target)->atom, - p, WINDOW(w)->win, Get_Time (time)); - return Void; -} - */ - s48_value Convert_Selection (s48_value Xdisplay, s48_value Xatom_s, s48_value Xatom_t, s48_value Xatom_p, s48_value Xwindow, s48_value time){ - Atom p = None; - - if (!S48_EQ_P(prop, Sym_None)) { - Check_Type (prop, T_Atom); - p = ATOM(prop)->atom; - } + XConvertSelection(EXTRACT_DISPLAY(Xdisplay), EXTRACT_ATOM(Xatom_s), EXTRACT_ATOM(Xatom_t), EXTRACT_ATOM(Xatom_p), EXTRACT_WINDOW(Xwindow), EXTRACT_TIME(time)); return S48_UNSPECIFIC; } -elk_init_xlib_property () { - Define_Symbol (&Sym_Now, "now"); - Generic_Define (Atom, "atom", "atom?"); - Define_Primitive (P_Make_Atom, "make-atom", 1, 1, EVAL); - Define_Primitive (P_Intern_Atom, "intern-atom", 2, 2, EVAL); - Define_Primitive (P_Find_Atom, "find-atom", 2, 2, EVAL); - Define_Primitive (P_Atom_Name, "atom-name", 2, 2, EVAL); - Define_Primitive (P_List_Properties, "list-properties", 1, 1, EVAL); - Define_Primitive (P_Get_Property, "get-property", 6, 6, EVAL); - Define_Primitive (P_Change_Property, "change-property", 6, 6, EVAL); - Define_Primitive (P_Delete_Property, "delete-property", 2, 2, EVAL); - Define_Primitive (P_Rotate_Properties, "rotate-properties", 3, 3, EVAL); - Define_Primitive (P_Set_Selection_Owner, "set-selection-owner!", - 4, 4, EVAL); - Define_Primitive (P_Selection_Owner, "selection-owner", 2, 2, EVAL); - Define_Primitive (P_Convert_Selection, "convert-selection", 5, 5, EVAL); +viod s48_init_graphics(void) { + S48_EXPORT_FUNCTION(Intern_Atom); + S48_EXPORT_FUNCTION(Find_Atom); + S48_EXPORT_FUNCTION(Atom_Name); + S48_EXPORT_FUNCTION(List_Properties); + S48_EXPORT_FUNCTION(Get_Property); + S48_EXPORT_FUNCTION(Change_Property); + S48_EXPORT_FUNCTION(Delete_Property); + S48_EXPORT_FUNCTION(Rotate_Property); + S48_EXPORT_FUNCTION(Set_Selection_Owner); + S48_EXPORT_FUNCTION(Get_Selection_Owner); + S48_EXPORT_FUNCTION(Convert_Selection); }