diff options
Diffstat (limited to 'src/menus.c')
-rw-r--r-- | src/menus.c | 159 |
1 files changed, 81 insertions, 78 deletions
diff --git a/src/menus.c b/src/menus.c index 8aa99c7..c446eed 100644 --- a/src/menus.c +++ b/src/menus.c @@ -171,12 +171,12 @@ InitMenus(void) * * \param name the name of the key * \param cont the context to look for the key press in - * \param mods modifier keys that need to be pressed + * \param mods2 modifier keys that need to be pressed * \param func the function to perform * \param win_name the window name (if any) * \param action the action string associated with the function (if any) */ -Bool AddFuncKey (char *name, int cont, int mods, int func, char *win_name, +Bool AddFuncKey (char *name, int cont, int mods2, int func, char *win_name, char *action) { FuncKey *tmp; @@ -198,7 +198,7 @@ Bool AddFuncKey (char *name, int cont, int mods, int func, char *win_name, { if (tmp->keysym == keysym && tmp->cont == cont && - tmp->mods == mods) + tmp->mods == mods2) break; } @@ -213,7 +213,7 @@ Bool AddFuncKey (char *name, int cont, int mods, int func, char *win_name, tmp->keysym = keysym; tmp->keycode = keycode; tmp->cont = cont; - tmp->mods = mods; + tmp->mods = mods2; tmp->func = func; tmp->win_name = win_name; tmp->action = action; @@ -342,18 +342,18 @@ void InitTitlebarButtons (void) } } - tb->dstx = (h - tb->width + 1) / 2; + tb->dstx = (int)(((unsigned)h - tb->width + 1) / 2); if (tb->dstx < 0) { /* clip to minimize copying */ tb->srcx = -(tb->dstx); - tb->width = h; + tb->width = (unsigned)h; tb->dstx = 0; } else { tb->srcx = 0; } - tb->dsty = (h - tb->height + 1) / 2; + tb->dsty = (int)(((unsigned)h - tb->height + 1) / 2); if (tb->dsty < 0) { tb->srcy = -(tb->dsty); - tb->height = h; + tb->height = (unsigned)h; tb->dsty = 0; } else { tb->srcy = 0; @@ -385,7 +385,7 @@ PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure) XSetForeground(dpy, Scr->NormalGC, mi->hi_back); XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset, - mr->width, Scr->EntryHeight); + (unsigned)mr->width, (unsigned)Scr->EntryHeight); MyFont_ChangeGC(mi->hi_fore, mi->hi_back, &Scr->MenuFont); @@ -401,7 +401,7 @@ PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure) XSetForeground(dpy, Scr->NormalGC, mi->back); XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset, - mr->width, Scr->EntryHeight); + (unsigned)mr->width, (unsigned)Scr->EntryHeight); MyFont_ChangeGC(mi->fore, mi->back, &Scr->MenuFont); gc = Scr->NormalGC; @@ -422,8 +422,8 @@ PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure) Scr->pullPm = CreateMenuIcon (Scr->MenuFont.height, &Scr->pullW, &Scr->pullH); } - x = mr->width - Scr->pullW - 5; - y = y_offset + ((Scr->MenuFont.height - Scr->pullH) / 2); + x = (int)((unsigned)mr->width - (Scr->pullW + 5)); + y = (int)((unsigned)y_offset + (((unsigned)Scr->MenuFont.height - Scr->pullH) / 2)); XCopyPlane(dpy, Scr->pullPm, mr->w, gc, 0, 0, Scr->pullW, Scr->pullH, x, y, 1); } @@ -436,7 +436,7 @@ PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure) /* fill the rectangle with the title background color */ XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset, - mr->width, Scr->EntryHeight); + (unsigned)mr->width, (unsigned)Scr->EntryHeight); { XSetForeground(dpy, Scr->NormalGC, mi->fore); @@ -713,19 +713,19 @@ AddToMenu(MenuRoot *menu, const char *item, const char *action, menu->last = tmp; tmp->item = item; - tmp->strlen = strlen(item); + tmp->strlen = (short)strlen(item); tmp->action = action; tmp->next = NULL; tmp->sub = NULL; tmp->state = 0; - tmp->func = func; + tmp->func = (short)func; if (!Scr->HaveFonts) CreateFonts(); width = MyFont_TextWidth(&Scr->MenuFont, item, tmp->strlen); if (width <= 0) width = 1; if (width > menu->width) - menu->width = width; + menu->width = (short)width; tmp->user_colors = FALSE; if (Scr->Monochrome == COLOR && fore != NULL) @@ -736,7 +736,7 @@ AddToMenu(MenuRoot *menu, const char *item, const char *action, Scr->FirstTime = TRUE; GetColor(COLOR, &tmp->fore, fore); GetColor(COLOR, &tmp->back, back); - Scr->FirstTime = save; + Scr->FirstTime = (short)save; tmp->user_colors = TRUE; } if (sub != NULL) @@ -787,7 +787,7 @@ MakeMenu(MenuRoot *mr) { if (mr->pull == TRUE) { - mr->width += 16 + 10; + mr->width = (short)(mr->width + (16 + 10)); } width = mr->width + 10; @@ -798,13 +798,13 @@ MakeMenu(MenuRoot *mr) cur->x = 5; else { - cur->x = width - MyFont_TextWidth(&Scr->MenuFont, cur->item, - cur->strlen); + cur->x = (short)(width - MyFont_TextWidth(&Scr->MenuFont, cur->item, + cur->strlen)); cur->x /= 2; } } - mr->height = mr->items * Scr->EntryHeight; - mr->width += 10; + mr->height = (short)(mr->items * Scr->EntryHeight); + mr->width = (short)(mr->width + 10); if (Scr->Shadow) { @@ -849,8 +849,8 @@ MakeMenu(MenuRoot *mr) valuemask, &attributes); - XSaveContext(dpy, mr->w, MenuContext, (caddr_t)mr); - XSaveContext(dpy, mr->w, ScreenContext, (caddr_t)Scr); + XSaveContext(dpy, mr->w, MenuContext, (XPointer)mr); + XSaveContext(dpy, mr->w, ScreenContext, (XPointer)Scr); mr->mapped = UNMAPPED; } @@ -932,14 +932,15 @@ MakeMenu(MenuRoot *mr) num -= 1; for (i = 0, cur = start->next; i < num && cur; i++, cur = cur->next) { - f3.red += fred; - f3.green += fgreen; - f3.blue += fblue; +#define AddColor(target,source) target = (unsigned short)(target + source) + AddColor(f3.red, fred); + AddColor(f3.green, fgreen); + AddColor(f3.blue, fblue); save_fore = f3; - b3.red += bred; - b3.green += bgreen; - b3.blue += bblue; + AddColor(b3.red, bred); + AddColor(b3.green, bgreen); + AddColor(b3.blue, bblue); save_back = b3; XAllocColor(dpy, cmap, &f3); @@ -999,7 +1000,7 @@ PopUpMenu (MenuRoot *menu, int x, int y, Bool center) WindowNameCount++; if (WindowNameCount != 0) { - WindowNames = malloc(sizeof(TwmWindow *) * WindowNameCount); + WindowNames = malloc(sizeof(TwmWindow *) * (size_t)WindowNameCount); WindowNames[0] = Scr->TwmRoot.next; for(tmp_win = Scr->TwmRoot.next->next , WindowNameCount=1; tmp_win != NULL; @@ -1228,7 +1229,7 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) if (event.type == ButtonPress) { MenuEndResize(tmp_win); - XMoveResizeWindow(dpy, w, AddingX, AddingY, AddingW, AddingH); + XMoveResizeWindow(dpy, w, AddingX, AddingY, (unsigned)AddingW, (unsigned)AddingH); break; } @@ -1402,7 +1403,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, else Bell(XkbBI_Info,0,tmp_win->w); - Scr->SortIconMgr = save_sort; + Scr->SortIconMgr = (short)save_sort; } break; @@ -1576,16 +1577,16 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, * in case of stupid or wicked fast servers */ if (ConstrainedMoveTime && - (eventp->xbutton.time - last_time) < ConstrainedMoveTime) + (eventp->xbutton.time - last_time) < (Time)ConstrainedMoveTime) { int width, height; ConstMove = TRUE; ConstMoveDir = MOVE_NONE; - ConstMoveX = eventp->xbutton.x_root - DragX - JunkBW; - ConstMoveY = eventp->xbutton.y_root - DragY - JunkBW; - width = DragWidth + 2 * JunkBW; - height = DragHeight + 2 * JunkBW; + ConstMoveX = (int)((unsigned)eventp->xbutton.x_root - (unsigned)DragX - JunkBW); + ConstMoveY = (int)((unsigned)eventp->xbutton.y_root - (unsigned)DragY - JunkBW); + width = (int)((unsigned)DragWidth + 2 * JunkBW); + height = (int)((unsigned)DragHeight + 2 * JunkBW); ConstMoveXL = ConstMoveX + width/3; ConstMoveXR = ConstMoveX + 2*(width/3); ConstMoveYT = ConstMoveY + height/3; @@ -1611,8 +1612,10 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, * MoveOutline's below. */ MoveOutline(rootw, - origDragX - JunkBW, origDragY - JunkBW, - DragWidth + 2 * JunkBW, DragHeight + 2 * JunkBW, + (int)((unsigned)origDragX - JunkBW), + (int)((unsigned)origDragY - JunkBW), + (int)((unsigned)DragWidth + 2 * JunkBW), + (int)((unsigned)DragHeight + 2 * JunkBW), tmp_win->frame_bw, moving_icon ? 0 : tmp_win->title_height); /* @@ -1692,7 +1695,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, WindowMoved = FALSE; if (!Scr->OpaqueMove) UninstallRootColormap(); - return TRUE; /* XXX should this be FALSE? */ + return TRUE; /* XXX should this be FALSE? */ } if (Event.type == releaseEvent) { @@ -1745,32 +1748,32 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, break; case MOVE_VERT: - ConstMoveY = eventp->xmotion.y_root - DragY - JunkBW; + ConstMoveY = (int)((unsigned)eventp->xmotion.y_root - (unsigned)DragY - JunkBW); break; case MOVE_HORIZ: - ConstMoveX= eventp->xmotion.x_root - DragX - JunkBW; + ConstMoveX= (int)((unsigned)eventp->xmotion.x_root - (unsigned)DragX - JunkBW); break; } if (ConstMoveDir != MOVE_NONE) { - int xl, yt, xr, yb, w, h; + int xl, yt, xr, yb, w2, h; xl = ConstMoveX; yt = ConstMoveY; - w = DragWidth + 2 * JunkBW; - h = DragHeight + 2 * JunkBW; + w2 = (int)((unsigned)DragWidth + 2 * JunkBW); + h = (int)((unsigned)DragHeight + 2 * JunkBW); if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) { - xr = xl + w; + xr = xl + w2; yb = yt + h; if (xl < 0) xl = 0; if (xr > Scr->MyDisplayWidth) - xl = Scr->MyDisplayWidth - w; + xl = Scr->MyDisplayWidth - w2; if (yt < 0) yt = 0; @@ -1782,34 +1785,34 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, if (Scr->OpaqueMove) XMoveWindow(dpy, DragWindow, xl, yt); else - MoveOutline(eventp->xmotion.root, xl, yt, w, h, + MoveOutline(eventp->xmotion.root, xl, yt, w2, h, tmp_win->frame_bw, moving_icon ? 0 : tmp_win->title_height); } } else if (DragWindow != None) { - int xl, yt, xr, yb, w, h; + int xl, yt, xr, yb, w2, h; if (!menuFromFrameOrWindowOrTitlebar) { - xl = eventp->xmotion.x_root - DragX - JunkBW; - yt = eventp->xmotion.y_root - DragY - JunkBW; + xl = (int)((unsigned)eventp->xmotion.x_root - (unsigned)DragX - JunkBW); + yt = (int)((unsigned)eventp->xmotion.y_root - (unsigned)DragY - JunkBW); } else { - xl = eventp->xmotion.x_root - (DragWidth / 2); - yt = eventp->xmotion.y_root - (DragHeight / 2); + xl = (int)(eventp->xmotion.x_root - (DragWidth / 2)); + yt = (int)(eventp->xmotion.y_root - (DragHeight / 2)); } - w = DragWidth + 2 * JunkBW; - h = DragHeight + 2 * JunkBW; + w2 = (int)((unsigned)DragWidth + 2 * JunkBW); + h = (int)((unsigned)DragHeight + 2 * JunkBW); if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) { - xr = xl + w; + xr = xl + w2; yb = yt + h; if (xl < 0) xl = 0; if (xr > Scr->MyDisplayWidth) - xl = Scr->MyDisplayWidth - w; + xl = Scr->MyDisplayWidth - w2; if (yt < 0) yt = 0; @@ -1822,7 +1825,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, if (Scr->OpaqueMove) XMoveWindow(dpy, DragWindow, xl, yt); else - MoveOutline(eventp->xmotion.root, xl, yt, w, h, + MoveOutline(eventp->xmotion.root, xl, yt, w2, h, tmp_win->frame_bw, moving_icon ? 0 : tmp_win->title_height); } @@ -2000,7 +2003,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, case F_CUT: strlcpy(tmp, action, sizeof(tmp)); strlcat(tmp, "\n", sizeof(tmp)); - XStoreBytes(dpy, tmp, strlen(tmp)); + XStoreBytes(dpy, tmp, (int)strlen(tmp)); break; case F_CUTFILE: @@ -2012,7 +2015,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, if (ptr) { fd = open (ptr, O_RDONLY); if (fd >= 0) { - count = read (fd, buff, MAX_FILE_SIZE - 1); + count = (int)read (fd, buff, MAX_FILE_SIZE - 1); if (count > 0) XStoreBytes (dpy, buff, count); close(fd); } else { @@ -2095,20 +2098,20 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, register TwmWindow *t; int len; - len = strlen(action); + len = (int)strlen(action); for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { - if (!strncmp(action, t->name, len)) + if (!strncmp(action, t->name, (size_t)len)) if (WarpThere(t)) break; } if (!t) { for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { - if (!strncmp(action, t->class.res_name, len)) + if (!strncmp(action, t->class.res_name, (size_t)len)) if (WarpThere(t)) break; } if (!t) { for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { - if (!strncmp(action, t->class.res_class, len)) + if (!strncmp(action, t->class.res_class, (size_t)len)) if (WarpThere(t)) break; } } @@ -2125,7 +2128,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, int len; Window raisewin = None, iconwin = None; - len = strlen(action); + len = (int)strlen(action); if (len == 0) { if (tmp_win && tmp_win->list) { raisewin = tmp_win->list->iconmgr->twm_win->frame; @@ -2136,7 +2139,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, } } else { for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { - if (strncmp (action, t->icon_name, len) == 0) { + if (strncmp (action, t->icon_name, (size_t)len) == 0) { if (t->list && t->list->iconmgr->twm_win->mapped) { raisewin = t->list->iconmgr->twm_win->frame; iconwin = t->list->icon; @@ -2175,7 +2178,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, fd = open(ptr, O_RDONLY); if (fd >= 0) { - count = read(fd, buff, MAX_FILE_SIZE - 1); + count = (int)read(fd, buff, MAX_FILE_SIZE - 1); if (count > 0) XStoreBytes(dpy, buff, count); @@ -2505,7 +2508,7 @@ Iconify(TwmWindow *tmp_win, int def_x, int def_y) XMapWindow(dpy, tmp_win->list->icon); XGetWindowAttributes(dpy, tmp_win->w, &winattrs); - eventMask = winattrs.your_event_mask; + eventMask = (unsigned long)winattrs.your_event_mask; /* iconify transients first */ for (t = Scr->TwmRoot.next; t != NULL; t = t->next) @@ -2525,9 +2528,9 @@ Iconify(TwmWindow *tmp_win, int def_x, int def_y) * cause a transition to the Withdrawn state. */ t->mapped = FALSE; - XSelectInput(dpy, t->w, eventMask & ~StructureNotifyMask); + XSelectInput(dpy, t->w, (long)(eventMask & (unsigned long)(~StructureNotifyMask))); XUnmapWindow(dpy, t->w); - XSelectInput(dpy, t->w, eventMask); + XSelectInput(dpy, t->w, (long)eventMask); XUnmapWindow(dpy, t->frame); if (t->icon_w) XUnmapWindow(dpy, t->icon_w); @@ -2553,9 +2556,9 @@ Iconify(TwmWindow *tmp_win, int def_x, int def_y) * cause a transition to the Withdrawn state. */ tmp_win->mapped = FALSE; - XSelectInput(dpy, tmp_win->w, eventMask & ~StructureNotifyMask); + XSelectInput(dpy, tmp_win->w, (long)(eventMask & (unsigned long)(~StructureNotifyMask))); XUnmapWindow(dpy, tmp_win->w); - XSelectInput(dpy, tmp_win->w, eventMask); + XSelectInput(dpy, tmp_win->w, (long)eventMask); XUnmapWindow(dpy, tmp_win->frame); SetMapStateProp(tmp_win, IconicState); @@ -2623,7 +2626,7 @@ Identify (TwmWindow *t) for (i = 0; i < n; i++) { twidth = MyFont_TextWidth(&Scr->DefaultFont, Info[i], - strlen(Info[i])); + (int)strlen(Info[i])); if (twidth > width) width = twidth; } @@ -2643,7 +2646,7 @@ Identify (TwmWindow *t) } else { px = py = 0; } - XMoveResizeWindow(dpy, Scr->InfoWindow, px, py, width, height); + XMoveResizeWindow(dpy, Scr->InfoWindow, px, py, (unsigned)width, (unsigned)height); XMapRaised(dpy, Scr->InfoWindow); InfoLines = n; } @@ -2743,7 +2746,7 @@ BumpWindowColormap (TwmWindow *tmp, int inc) if (!tmp) return; if (inc && tmp->cmaps.number_cwins > 0) { - cwins = malloc(sizeof(ColormapWindow *) * tmp->cmaps.number_cwins); + cwins = malloc(sizeof(ColormapWindow *) * (size_t)tmp->cmaps.number_cwins); if (cwins) { if ((previously_installed = /* SUPPRESS 560 */(Scr->cmapInfo.cmaps == &tmp->cmaps && @@ -2921,8 +2924,8 @@ send_clientmessage (Window w, Atom a, Time timestamp) ev.window = w; ev.message_type = _XA_WM_PROTOCOLS; ev.format = 32; - ev.data.l[0] = a; - ev.data.l[1] = timestamp; + ev.data.l[0] = (long)a; + ev.data.l[1] = (long)timestamp; XSendEvent (dpy, w, False, 0L, (XEvent *) &ev); } |