void handle_xevents() { XEvent event; while (XPending(display)) { XNextEvent(display, &event); if (event.type == Expose) updates = imlib_update_append_rect(updates, event.xexpose.x, event.xexpose.y, event.xexpose.width, event.xexpose.height); } }
void drag_client(Client * c, int mouse_x, int mouse_y) { XEvent ev; Client *exposed; int startx, starty; startx = c->x; starty = c->y; /* XGrabServer(disp); */ #ifdef DEBUG fprintf(stdout, "in drag_client: %d,%d\n", mouse_x, mouse_y); #endif for (;;) { XMaskEvent(disp, ButtonReleaseMask | PointerMotionMask | ExposureMask, &ev); switch (ev.type) { case MotionNotify: #ifdef DEBUG fprintf(stdout, "got MotionNotify: %d,%d\n", ev.xmotion.x_root, ev.xmotion.y_root); #endif c->x = startx + (ev.xmotion.x_root - mouse_x); c->y = starty + (ev.xmotion.y_root - mouse_y); #ifdef DEBUG fprintf(stdout, "c->x, c->y: %d,%d\n", c->x, c->y); #endif if (!MOVE_AFTER_DRAG) { XMoveWindow(disp, c->frame, c->x, c->y); XFlush(disp); if (!SEND_CONFIGURE_AFTER_DRAG) icccm_send_configure_event(c); } break; case ButtonRelease: /* XUngrabServer(disp); */ return; case Expose: exposed = find_client_by_frame(ev.xexpose.window); if (exposed) { exposed->updates = imlib_update_append_rect(exposed->updates, ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height); redraw_client(exposed); } break; } } }
void feh_menu_deselect_selected(feh_menu * m) { feh_menu_item *i; if (!m) return; i = feh_menu_find_selected(m); if (i) { D(("found a selected menu, deselecting it\n")); MENU_ITEM_SET_NORMAL(i); m->updates = imlib_update_append_rect(m->updates, i->x, i->y, i->w, i->h); m->needs_redraw = 1; } return; }
static void feh_event_handle_LeaveNotify(XEvent * ev) { if ((menu_root) && (ev->xcrossing.window == menu_root->win)) { feh_menu_item *ii; D(("It is for a menu\n")); for (ii = menu_root->items; ii; ii = ii->next) { if (MENU_ITEM_IS_SELECTED(ii)) { D(("Unselecting menu\n")); MENU_ITEM_SET_NORMAL(ii); menu_root->updates = imlib_update_append_rect(menu_root->updates, ii->x, ii->y, ii->w, ii->h); menu_root->needs_redraw = 1; } } feh_raise_all_menus(); } return; }
void feh_menu_select(feh_menu * m, feh_menu_item * i) { MENU_ITEM_SET_SELECTED(i); m->updates = imlib_update_append_rect(m->updates, i->x, i->y, i->w, i->h); m->needs_redraw = 1; if (m->next) { m->next->prev = NULL; feh_menu_hide(m->next, TRUE); m->next = NULL; } if (i->submenu) { feh_menu *mm; mm = feh_menu_find(i->submenu); if (mm) feh_menu_show_at_submenu(mm, m, i); else if (i->func_gen_sub) feh_menu_show_at_submenu(i->func_gen_sub(m), m, i); } return; }
void feh_menu_calc_size(feh_menu * m) { int prev_w, prev_h; feh_menu_item *i; int j = 0, count = 0, max_w = 0, max_h = 0, icon_w = 0, next_w = 0; int toggle_w = 0; prev_w = m->w; prev_h = m->h; m->calc = 0; for (i = m->items; i; i = i->next) { int w, h; feh_menu_entry_get_size(m, i, &w, &h); if (w > max_w) max_w = w; if (h > max_h) max_h = h; if (i->submenu) { next_w = FEH_MENU_SUBMENU_W; if (FEH_MENU_SUBMENU_H > max_h) max_h = FEH_MENU_SUBMENU_H; } if (i->is_toggle) { toggle_w = FEH_MENU_TOGGLE_W + FEH_MENU_TOGGLE_PAD; if (FEH_MENU_TOGGLE_H > max_h) max_h = FEH_MENU_TOGGLE_H; } count++; } for (i = m->items; i; i = i->next) { if (i->icon) { Imlib_Image im; im = i->icon; if (im) { int iw, ih, ow, oh; iw = gib_imlib_image_get_width(im); ih = gib_imlib_image_get_height(im); if (ih <= max_h) { ow = iw; oh = ih; } else { ow = (iw * max_h) / ih; oh = max_h; } if (ow > icon_w) icon_w = ow; } } } m->h = FEH_MENU_PAD_TOP; for (i = m->items; i; i = i->next) { i->x = FEH_MENU_PAD_LEFT; i->y = m->h; i->w = max_w + icon_w + toggle_w + next_w; i->icon_x = FEH_MENUITEM_PAD_LEFT; i->toggle_x = i->icon_x + icon_w; i->text_x = i->toggle_x + toggle_w; i->sub_x = i->text_x + max_w; if (i->text) i->h = max_h; else i->h = FEH_MENU_SEP_MAX_H; m->h += i->h; j++; } m->h += FEH_MENU_PAD_BOTTOM; m->w = next_w + toggle_w + icon_w + max_w + FEH_MENU_PAD_LEFT + FEH_MENU_PAD_RIGHT; if ((prev_w != m->w) || (prev_h != m->h)) { if (m->pmap) XFreePixmap(disp, m->pmap); m->pmap = 0; m->needs_redraw = 1; XResizeWindow(disp, m->win, m->w, m->h); m->updates = imlib_update_append_rect(m->updates, 0, 0, m->w, m->h); } D(("menu size calculated. w=%d h=%d\n", m->w, m->h)); /* Make sure bg is same size */ if (m->bg) { int bg_w, bg_h; bg_w = gib_imlib_image_get_width(m->bg); bg_h = gib_imlib_image_get_height(m->bg); if (m->w != bg_w || m->h != bg_h) { Imlib_Image newim = imlib_create_image(m->w, m->h); D(("resizing bg to %dx%d\n", m->w, m->h)); gib_imlib_blend_image_onto_image(newim, m->bg, 0, 0, 0, bg_w, bg_h, 0, 0, m->w, m->h, 0, 0, 1); gib_imlib_free_image_and_decache(m->bg); m->bg = newim; } } return; }