static Atom *getTypeAtomList(WMScreen * scr, WMView * view, int *count) { WMArray *types; Atom *typeAtoms; int i; types = view->dragSourceProcs->dropDataTypes(view); if (types != NULL) { *count = WMGetArrayItemCount(types); if (*count > 0) { typeAtoms = wmalloc((*count) * sizeof(Atom)); for (i = 0; i < *count; i++) { typeAtoms[i] = XInternAtom(scr->display, WMGetFromArray(types, i), False); } /* WMFreeArray(types); */ return typeAtoms; } /* WMFreeArray(types); */ } *count = 1; typeAtoms = wmalloc(sizeof(Atom)); *typeAtoms = None; return typeAtoms; }
/* * Function: _wilddog_url_getKey * Description: Get the Key of the path. * Input: p_path: The path. * Output: N/A * Return: Pointer to the Key. */ Wilddog_Str_T * WD_SYSTEM _wilddog_url_getKey(Wilddog_Str_T * p_path) { int i, len, pos = 0; Wilddog_Str_T* p_str = NULL; if(NULL == p_path) return NULL; len = strlen((const char*)p_path); if(len == 1 && p_path[0] == '/') { p_str = (Wilddog_Str_T*)wmalloc(len + 1); if(NULL == p_str) return NULL; p_str[0] = '/'; return p_str; } for(i = len - 1; i >=0; i--) { if(p_path[len - 1] == '/') continue; if(p_path[i] == '/') { pos = i; break; } } p_str = (Wilddog_Str_T*)wmalloc(len - pos); if(NULL == p_str) return NULL; memcpy((char*)p_str, (char*)(p_path + pos + 1), len - pos); return p_str; }
/* ** Perform Re-Pair on one block */ static void executeRepair_OneBlock (PROG_INFO *prog_struct, BLOCK_INFO *block_struct) { R_UINT i; /* Perform scanPairs */ scanPairs (prog_struct, block_struct); /* Allocate queue and initialize to NULL */ /* Make the priority queue bigger by one since position 0 is ** unused. */ block_struct -> pqueue_size = block_struct -> max_count + 1; block_struct -> pqueue = wmalloc ((block_struct -> pqueue_size) * (sizeof (TPHRASE*))); for (i = 0; i < block_struct -> pqueue_size; i++) { block_struct -> pqueue[i] = NULL; } /* Populate queue with tentative phrases */ initQueue (prog_struct, block_struct); /* Recursively pair phrases */ rePairPhrases (prog_struct, block_struct); /* Sort primitives */ sortPrimitives (block_struct); block_struct -> sort_phrases = wmalloc (((block_struct -> num_prims) + (block_struct -> num_phrases)) * (sizeof (PHRASE))); /* Sort phrases */ sortPhrases (prog_struct, block_struct); return; }
static struct apiState *eventInit(int nevent) { struct kevent *events = NULL; int ep; struct apiState *state = NULL; ep = kqueue(); if (ep < 0) { return NULL; } state = wmalloc(sizeof(struct apiState)); if (!state) { close(ep); return NULL; } events = wmalloc(nevent*sizeof(struct kevent)); if (events == NULL) { close(ep); wfree(state); return NULL; } state->kqfd = ep; state->events = events; return state; }
/* upon fully deducing one particular menu entry, parsers call back to this * function to have said menu entry added to the wm menu. initializes wm menu * with a root element if needed. */ static void addWMMenuEntryCallback(WMMenuEntry *aEntry) { WMMenuEntry *wm; WMTreeNode *at; wm = (WMMenuEntry *)wmalloc(sizeof(WMMenuEntry)); /* this entry */ at = (WMTreeNode *)NULL; /* will be a child of this entry */ if (!menu) { WMMenuEntry *root; root = (WMMenuEntry *)wmalloc(sizeof(WMMenuEntry)); root->Name = "Applications"; root->CmdLine = NULL; root->SubMenu = NULL; root->Flags = 0; menu = WMCreateTreeNode(root); } if (aEntry->SubMenu) at = findPositionInMenu(aEntry->SubMenu); if (!at) at = menu; wm->Flags = aEntry->Flags; wm->Name = wstrdup(aEntry->Name); wm->CmdLine = wstrdup(aEntry->CmdLine); wm->SubMenu = NULL; WMAddItemToTree(at, wm); }
static WMPropList* getDefaultMenu(_Panel *panel) { WMPropList *menu; char *menuPath, *gspath; gspath = wusergnusteppath(); menuPath = wmalloc(strlen(gspath)+128); sprintf(menuPath, "%s/Library/WindowMaker/plmenu", gspath); menu = WMReadPropListFromFile(menuPath); if (!menu) { char *buffer, *msg; msg = _("Could not open default menu from '%s'"); buffer = wmalloc(strlen(msg) + strlen(menuPath) + 10); sprintf(buffer, msg, menuPath); WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Error"), buffer, _("OK"), NULL, NULL); wfree(buffer); } wfree(menuPath); return menu; }
WMFont* WMCreateFont(WMScreen *scrPtr, char *fontName) { WMFont *font; Display *display = scrPtr->display; char *fname, *ptr; /* This is for back-compat (to allow reading of old xlfd descriptions) */ if (fontName[0]=='-' && (ptr = strchr(fontName, ','))) { // warn for deprecation fname = wmalloc(ptr - fontName + 1); strncpy(fname, fontName, ptr - fontName); fname[ptr - fontName] = 0; } else { fname = wstrdup(fontName); } font = WMHashGet(scrPtr->fontCache, fname); if (font) { WMRetainFont(font); wfree(fname); return font; } font = wmalloc(sizeof(WMFont)); memset(font, 0, sizeof(WMFont)); font->screen = scrPtr; // remove printf("WMCreateFont: %s\n", fname); if (fname[0] == '-') { // Backward compat thing. Remove in a later version font->font = XftFontOpenXlfd(display, scrPtr->screen, fname); } else { font->font = XftFontOpenName(display, scrPtr->screen, fname); } if (!font->font) { wfree(font); wfree(fname); return NULL; } font->height = font->font->ascent+font->font->descent; font->y = font->font->ascent; font->refCount = 1; font->name = fname; assert(WMHashInsert(scrPtr->fontCache, font->name, font)==NULL); return font; }
WMTextField *WMCreateTextField(WMWidget * parent) { TextField *tPtr; tPtr = wmalloc(sizeof(TextField)); tPtr->widgetClass = WC_TextField; tPtr->view = W_CreateView(W_VIEW(parent)); if (!tPtr->view) { wfree(tPtr); return NULL; } tPtr->view->self = tPtr; tPtr->view->delegate = &_TextFieldViewDelegate; tPtr->view->attribFlags |= CWCursor; tPtr->view->attribs.cursor = tPtr->view->screen->textCursor; W_SetViewBackgroundColor(tPtr->view, tPtr->view->screen->white); tPtr->text = wmalloc(MIN_TEXT_BUFFER); tPtr->textLen = 0; tPtr->bufferSize = MIN_TEXT_BUFFER; tPtr->flags.enabled = 1; WMCreateEventHandler(tPtr->view, ExposureMask | StructureNotifyMask | FocusChangeMask, handleEvents, tPtr); tPtr->font = WMRetainFont(tPtr->view->screen->normalFont); tPtr->flags.bordered = DEFAULT_BORDERED; tPtr->flags.beveled = True; tPtr->flags.alignment = DEFAULT_ALIGNMENT; tPtr->offsetWidth = WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font)) / 2, 1); W_ResizeView(tPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT); WMCreateEventHandler(tPtr->view, EnterWindowMask | LeaveWindowMask | ButtonReleaseMask | ButtonPressMask | KeyPressMask | Button1MotionMask, handleTextFieldActionEvents, tPtr); WMAddNotificationObserver(selectionNotification, tPtr->view, WMSelectionOwnerDidChangeNotification, (void *)XA_PRIMARY); WMAddNotificationObserver(realizeObserver, tPtr, WMViewRealizedNotification, tPtr->view); tPtr->flags.cursorOn = 1; return tPtr; }
WMHashTable *WMCreateHashTable(WMHashTableCallbacks callbacks) { HashTable *table; table = wmalloc(sizeof(HashTable)); table->callbacks = callbacks; table->size = INITIAL_CAPACITY; table->table = wmalloc(sizeof(HashItem *) * table->size); return table; }
static void removeColumn(WMBrowser * bPtr, int column) { int i, clearEnd, destroyEnd; WMList **clist; char **tlist; assert(bPtr != NULL); column = (column < 0) ? 0 : column; if (column >= bPtr->columnCount) { return; } if (column < bPtr->maxVisibleColumns) { clearEnd = bPtr->maxVisibleColumns; destroyEnd = bPtr->columnCount; bPtr->columnCount = bPtr->maxVisibleColumns; } else { clearEnd = column; destroyEnd = bPtr->columnCount; bPtr->columnCount = column; } if (column < bPtr->usedColumnCount) { bPtr->usedColumnCount = column; } for (i = column; i < clearEnd; i++) { if (bPtr->titles[i]) { wfree(bPtr->titles[i]); bPtr->titles[i] = NULL; } WMClearList(bPtr->columns[i]); } for (; i < destroyEnd; i++) { if (bPtr->titles[i]) { wfree(bPtr->titles[i]); bPtr->titles[i] = NULL; } WMRemoveNotificationObserverWithName(bPtr, WMListSelectionDidChangeNotification, bPtr->columns[i]); WMDestroyWidget(bPtr->columns[i]); bPtr->columns[i] = NULL; } clist = wmalloc(sizeof(WMList *) * (bPtr->columnCount)); tlist = wmalloc(sizeof(char *) * (bPtr->columnCount)); memcpy(clist, bPtr->columns, sizeof(WMList *) * (bPtr->columnCount)); memcpy(tlist, bPtr->titles, sizeof(char *) * (bPtr->columnCount)); wfree(bPtr->titles); wfree(bPtr->columns); bPtr->titles = tlist; bPtr->columns = clist; }
int wWorkspaceNew(WScreen *scr) { WWorkspace *wspace, **list; int i; if (w_global.workspace.count < MAX_WORKSPACES) { w_global.workspace.count++; wspace = wmalloc(sizeof(WWorkspace)); wspace->name = NULL; wspace->clip = NULL; if (!wspace->name) { static const char *new_name = NULL; static size_t name_length; if (new_name == NULL) { new_name = _("Workspace %i"); name_length = strlen(new_name) + 8; } wspace->name = wmalloc(name_length); snprintf(wspace->name, name_length, new_name, w_global.workspace.count); } if (!wPreferences.flags.noclip) wspace->clip = wDockCreate(scr, WM_CLIP, NULL); list = wmalloc(sizeof(WWorkspace *) * w_global.workspace.count); for (i = 0; i < w_global.workspace.count - 1; i++) list[i] = w_global.workspace.array[i]; list[i] = wspace; if (w_global.workspace.array) wfree(w_global.workspace.array); w_global.workspace.array = list; wWorkspaceMenuUpdate(w_global.workspace.menu); wWorkspaceMenuUpdate(w_global.clip.ws_menu); wNETWMUpdateDesktop(scr); WMPostNotificationName(WMNWorkspaceCreated, scr, (void *)(uintptr_t) (w_global.workspace.count - 1)); XFlush(dpy); return w_global.workspace.count - 1; } return -1; }
/* * Function: _wilddog_url_getParentStr * Description: Get the Parent path of the source path. * Input: p_src_path: The source path. * Output: N/A * Return: Pointer to the parent's path. */ STATIC Wilddog_Str_T * WD_SYSTEM _wilddog_url_getParentStr ( Wilddog_Str_T* p_src_path ) { int i; int size = 0; int pos = 0; Wilddog_Str_T* p_path = NULL; if(!p_src_path) return NULL; size = strlen((const char*)p_src_path); if(size == 1 && p_src_path[0] == '/') { return NULL; } for(i = size - 1; i >= 0; i--) { if(p_src_path[size - 1] == '/') continue; if(p_src_path[i] == '/') { pos = i; break; } } /* path do not have '/', invalid */ if((!pos) && (p_src_path[pos] != '/')) return p_path; if(pos == 0) { p_path = (Wilddog_Str_T *)wmalloc(2); if(NULL == p_path) return NULL; p_path[0] = '/'; return p_path; } p_path = (Wilddog_Str_T *)wmalloc(pos + 1); if(NULL == p_path) return NULL; strncpy((char*)p_path, (char*)p_src_path, pos); return p_path; }
static void registerDescriptionList(WMScreen * scr, WMView * view, WMArray * operationArray) { char *text, *textListItem, *textList; int count = WMGetArrayItemCount(operationArray); int i; int size = 0; /* size of XA_STRING info */ for (i = 0; i < count; i++) { size += strlen(WMGetDragOperationItemText(WMGetFromArray(operationArray, i))) + 1 /* NULL */; } /* create text list */ textList = wmalloc(size); textListItem = textList; for (i = 0; i < count; i++) { text = WMGetDragOperationItemText(WMGetFromArray(operationArray, i)); wstrlcpy(textListItem, text, size); /* to next text offset */ textListItem = &(textListItem[strlen(textListItem) + 1]); } XChangeProperty(scr->display, WMViewXID(view), scr->xdndActionDescriptionAtom, XA_STRING, XDND_ACTION_DESCRIPTION_FORMAT, PropModeReplace, (unsigned char *)textList, size); }
*/ Wilddog_Conn_T * WD_SYSTEM _wilddog_conn_init(Wilddog_Repo_T* p_repo) { Wilddog_CM_InitArg_T cm_initArg; Wilddog_Conn_T* p_repo_conn = NULL; if(!p_repo) return NULL; p_repo_conn = (Wilddog_Conn_T*)wmalloc(sizeof(Wilddog_Conn_T)); if( NULL ==p_repo_conn) return NULL; p_repo_conn->p_conn_repo = p_repo; p_repo->p_rp_conn = p_repo_conn; p_repo_conn->f_conn_ioctl = (Wilddog_Func_T)_wilddog_conn_ioctl; cm_initArg.p_repo= p_repo; cm_initArg.f_conn_cb = (Wilddog_Func_T)_wilddog_conn_cb_ioctl; p_repo_conn->p_cm_l = (void*)_wilddog_cm_ioctl( CM_CMD_INIT,&cm_initArg,0); if( p_repo_conn->p_cm_l == NULL ) { wfree(p_repo_conn); p_repo_conn = NULL; } return p_repo_conn;
WTexPixmap *wTextureMakePixmap(WScreen *scr, int style, const char *pixmap_file, XColor *color) { WTexPixmap *texture; XGCValues gcv; RImage *image; image = get_texture_image(scr, pixmap_file); if (!image) return NULL; texture = wmalloc(sizeof(WTexture)); texture->type = WTEX_PIXMAP; texture->subtype = style; texture->normal = *color; XAllocColor(dpy, scr->w_colormap, &texture->normal); gcv.background = gcv.foreground = texture->normal.pixel; gcv.graphics_exposures = False; texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground | GCBackground | GCGraphicsExposures, &gcv); texture->pixmap = image; return texture; }
WMMaskedEvents* WMMaskEvents(WMView* view) { W_MaskedEvents *mask; unsigned int i; Bool changed = False; mask = wmalloc(sizeof(W_MaskedEvents)); mask->view = view; mask->procs = WMCreateArray(0); mask->data = WMCreateArray(0); for (i = 0; i < WMGetArrayItemCount(W_GetViewEventHandlers(view)); i++) { W_EventHandler *h = (W_EventHandler*) WMGetFromArray(W_GetViewEventHandlers(view), i); if (h->eventMask == (ButtonPressMask|ButtonReleaseMask| EnterWindowMask|LeaveWindowMask|ButtonMotionMask)) { WMAddToArray(mask->procs, h->proc); WMAddToArray(mask->data, h->clientData); /* we change only the first handler to our one, because they seem to be processed upside-down and we want the dnd-handler to be processed first. */ if (changed == False) { h->proc = W_MaskedEventHandler; h->clientData = (void*) mask; changed = True; } else { WMDeleteEventHandler(view, h->eventMask, h->proc, h->clientData); } } } return mask; }
Panel *InitMouseSettings(WMWidget *parent) { _Panel *panel; modifierNames[0] = wstrdup(_("Shift")); modifierNames[1] = wstrdup(_("Lock")); modifierNames[2] = wstrdup(_("Control")); modifierNames[3] = wstrdup(_("Mod1")); modifierNames[4] = wstrdup(_("Mod2")); modifierNames[5] = wstrdup(_("Mod3")); modifierNames[6] = wstrdup(_("Mod4")); modifierNames[7] = wstrdup(_("Mod5")); panel = wmalloc(sizeof(_Panel)); panel->sectionName = _("Mouse Preferences"); panel->description = _("Mouse speed/acceleration, double click delay,\n" "mouse button bindings etc."); panel->parent = parent; panel->callbacks.createWidgets = createPanel; panel->callbacks.updateDomain = storeData; AddSection(panel, ICON_FILE); return panel; }
WMSplitView *WMCreateSplitView(WMWidget * parent) { WMSplitView *sPtr; sPtr = wmalloc(sizeof(WMSplitView)); sPtr->widgetClass = WC_SplitView; sPtr->view = W_CreateView(W_VIEW(parent)); if (!sPtr->view) { wfree(sPtr); return NULL; } sPtr->view->self = sPtr; WMSetViewNotifySizeChanges(sPtr->view, True); WMCreateEventHandler(sPtr->view, ExposureMask | StructureNotifyMask | ClientMessageMask, handleEvents, sPtr); WMCreateEventHandler(sPtr->view, ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask, handleActionEvents, sPtr); WMAddNotificationObserver(handleViewResized, sPtr, WMViewSizeDidChangeNotification, sPtr->view); sPtr->subviews = WMCreateArrayWithDestructor(8, wfree); return sPtr; }
WTexTGradient *wTextureMakeTGradient(WScreen *scr, int style, const RColor *from, const RColor *to, const char *pixmap_file, int opacity) { WTexTGradient *texture; XGCValues gcv; RImage *image; image = get_texture_image(scr, pixmap_file); if (!image) return NULL; texture = wmalloc(sizeof(WTexture)); texture->type = style; texture->opacity = opacity; texture->color1 = *from; texture->color2 = *to; texture->normal.red = (from->red + to->red) << 7; texture->normal.green = (from->green + to->green) << 7; texture->normal.blue = (from->blue + to->blue) << 7; XAllocColor(dpy, scr->w_colormap, &texture->normal); gcv.background = gcv.foreground = texture->normal.pixel; gcv.graphics_exposures = False; texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground | GCBackground | GCGraphicsExposures, &gcv); texture->pixmap = image; return texture; }
WMLabel *WMCreateLabel(WMWidget * parent) { Label *lPtr; lPtr = wmalloc(sizeof(Label)); lPtr->widgetClass = WC_Label; lPtr->view = W_CreateView(W_VIEW(parent)); if (!lPtr->view) { wfree(lPtr); return NULL; } lPtr->view->self = lPtr; lPtr->textColor = WMRetainColor(lPtr->view->screen->black); WMCreateEventHandler(lPtr->view, ExposureMask | StructureNotifyMask, handleEvents, lPtr); W_ResizeView(lPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT); lPtr->flags.alignment = DEFAULT_ALIGNMENT; lPtr->flags.relief = DEFAULT_RELIEF; lPtr->flags.imagePosition = DEFAULT_IMAGE_POSITION; lPtr->flags.noWrap = 1; return lPtr; }
bool wsheet_add_obj(struct wsheet* wsh, uint16_t type, void* data, int32_t l, int32_t t, int32_t r, int32_t b) { int32_t i, j; struct obj* o = wmalloc(sizeof(*o)); wassert(o); rect_set(&o->extent, l, t, r, b); o->ty = type; o->ref = 0; o->priv = data; for (i = 0; i < wsh->rowN; i++) { for (j = 0; j < wsh->colN; j++) { if (rect_is_overlap2(&o->extent, &wsh->divs[i][j].boundary)) div_add_obj(&wsh->divs[i][j], o); } } /* if obj is not added anywhere, destroy it! */ if (!o->ref) { wfree(o); return false; } else return true; }
Wilddog_Str_T * getHostFromUrl(Wilddog_Str_T *url) { int length = 0; int m = 0, n = 0; int i = 0; Wilddog_Str_T *host = NULL; length = strlen(url); for(i = 0; i < length; i++) { if(*(url+i) == '/' && *(url+i+1) == '/') break; } m = i+2; for(i = m; i < length; i++) { if(*(url+i) == '/') break; } n = i-1; host = wmalloc(n-m+2); if(NULL == host) { } strncpy(host, url+m, n-m+1); return host; }
/*---------------------------------------------------------------------- * wCoreCreate-- * Creates a brand new child window. * The window will have a border width of 0 and color is black. * * Returns: * A initialized core window structure. * * Side effects: * A window context for the created window is saved. * * Notes: * The event mask is initialized to a default value. *--------------------------------------------------------------------- */ WCoreWindow *wCoreCreate(WCoreWindow *parent, int x, int y, int width, int height) { WCoreWindow *core; int vmask; XSetWindowAttributes attribs; core = wmalloc(sizeof(WCoreWindow)); vmask = CWBorderPixel | CWCursor | CWEventMask | CWColormap; attribs.cursor = wCursor[WCUR_DEFAULT]; attribs.background_pixmap = None; attribs.background_pixel = parent->screen_ptr->black_pixel; attribs.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask; attribs.colormap = parent->screen_ptr->w_colormap; core->window = XCreateWindow(dpy, parent->window, x, y, width, height, 0, parent->screen_ptr->w_depth, CopyFromParent, parent->screen_ptr->w_visual, vmask, &attribs); core->width = width; core->height = height; core->screen_ptr = parent->screen_ptr; core->descriptor.self = core; XSaveContext(dpy, core->window, wWinContext, (XPointer) & core->descriptor); return core; }
static char *dataDescription(WMPropList * plist) { const unsigned char *data; char *retVal; int i, j, length; data = WMDataBytes(plist->d.data); length = WMGetDataLength(plist->d.data); retVal = (char *)wmalloc(2 * length + length / 4 + 3); retVal[0] = '<'; for (i = 0, j = 1; i < length; i++) { retVal[j++] = num2char((data[i] >> 4) & 0x0f); retVal[j++] = num2char(data[i] & 0x0f); if ((i & 0x03) == 3 && i != length - 1) { /* if we've just finished a 32-bit int, add a space */ retVal[j++] = ' '; } } retVal[j++] = '>'; retVal[j] = '\0'; return retVal; }
void WMResetHashTable(WMHashTable * table) { HashItem *item, *tmp; int i; for (i = 0; i < table->size; i++) { item = table->table[i]; while (item) { tmp = item->next; RELKEY(table, item->key); wfree(item); item = tmp; } } table->itemCount = 0; if (table->size > INITIAL_CAPACITY) { wfree(table->table); table->size = INITIAL_CAPACITY; table->table = wmalloc(sizeof(HashItem *) * table->size); } else { memset(table->table, 0, sizeof(HashItem *) * table->size); } }
static void rebuildTable(WMHashTable * table) { HashItem *next; HashItem **oldArray; int i; int oldSize; int newSize; oldArray = table->table; oldSize = table->size; newSize = table->size * 2; table->table = wmalloc(sizeof(char *) * newSize); table->size = newSize; for (i = 0; i < oldSize; i++) { while (oldArray[i] != NULL) { next = oldArray[i]->next; rellocateItem(table, oldArray[i]); oldArray[i] = next; } } wfree(oldArray); }
void WMSetViewDragSourceProcs(WMView * view, WMDragSourceProcs * procs) { if (view->dragSourceProcs) wfree(view->dragSourceProcs); view->dragSourceProcs = wmalloc(sizeof(WMDragSourceProcs)); *view->dragSourceProcs = *procs; if (procs->dropDataTypes == NULL) view->dragSourceProcs->dropDataTypes = defDropDataTypes; if (procs->wantedDropOperation == NULL) view->dragSourceProcs->wantedDropOperation = defWantedDropOperation; /* Note: askedOperations can be NULL, if wantedDropOperation never returns WDOperationAsk. */ if (procs->acceptDropOperation == NULL) view->dragSourceProcs->acceptDropOperation = defAcceptDropOperation; if (procs->beganDrag == NULL) view->dragSourceProcs->beganDrag = defBeganDrag; if (procs->endedDrag == NULL) view->dragSourceProcs->endedDrag = defEndedDrag; if (procs->fetchDragData == NULL) view->dragSourceProcs->fetchDragData = defFetchDragData; }
WMTabView *WMCreateTabView(WMWidget * parent) { TabView *tPtr; WMScreen *scr = WMWidgetScreen(parent); tPtr = wmalloc(sizeof(TabView)); tPtr->widgetClass = WC_TabView; tPtr->view = W_CreateView(W_VIEW(parent)); if (!tPtr->view) { wfree(tPtr); return NULL; } tPtr->view->self = tPtr; tPtr->view->delegate = &delegate; tPtr->lightGray = WMCreateRGBColor(scr, 0xd9d9, 0xd9d9, 0xd9d9, False); tPtr->tabColor = WMCreateRGBColor(scr, 0x8420, 0x8420, 0x8420, False); tPtr->font = WMRetainFont(scr->normalFont); tPtr->flags.type = WTTopTabsBevelBorder; tPtr->flags.bordered = 1; tPtr->flags.uniformTabs = 0; tPtr->flags.enabled = 1; WMCreateEventHandler(tPtr->view, ExposureMask | StructureNotifyMask | ButtonPressMask, handleEvents, tPtr); WMResizeWidget(tPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT); tPtr->tabHeight = WMFontHeight(tPtr->font) + 3; return tPtr; }
static void initMotionProcess(WMView * view, WMDraggingInfo * info, XEvent * event, WMPoint * startLocation) { WMScreen *scr = W_VIEW_SCREEN(view); /* take ownership of XdndSelection */ XDND_SELECTION_PROCS(info) = (WMSelectionProcs *) wmalloc(sizeof(WMSelectionProcs)); XDND_SELECTION_PROCS(info)->convertSelection = convertSelection; XDND_SELECTION_PROCS(info)->selectionLost = selectionLost; XDND_SELECTION_PROCS(info)->selectionDone = selectionDone; XDND_TIMESTAMP(info) = event->xmotion.time; if (!WMCreateSelectionHandler(view, scr->xdndSelectionAtom, CurrentTime, XDND_SELECTION_PROCS(info), NULL)) { wwarning("could not get ownership or DND selection"); return; } registerDropTypes(scr, view, info); if (XDND_SOURCE_ACTION(info) == W_VIEW_SCREEN(view)->xdndActionAsk) registerSupportedOperations(view); if (view->dragSourceProcs->beganDrag != NULL) { view->dragSourceProcs->beganDrag(view, startLocation); } }
struct W_Balloon *W_CreateBalloon(WMScreen * scr) { Balloon *bPtr; bPtr = wmalloc(sizeof(Balloon)); bPtr->view = W_CreateUnmanagedTopView(scr); if (!bPtr->view) { wfree(bPtr); return NULL; } bPtr->view->self = bPtr; bPtr->textColor = WMRetainColor(bPtr->view->screen->black); WMCreateEventHandler(bPtr->view, StructureNotifyMask, handleEvents, bPtr); W_ResizeView(bPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT); bPtr->flags.alignment = DEFAULT_ALIGNMENT; bPtr->table = WMCreateHashTable(WMIntHashCallbacks); bPtr->delay = DEFAULT_DELAY; bPtr->flags.enabled = 1; return bPtr; }