Example #1
0
File: events.c Project: Limsik/e17
unsigned char
handle_key_press(event_t *ev)
{
    XWMHints *wm_hints;
#ifdef COUNT_X_EVENTS
    static unsigned long keypress_cnt = 0;
#endif

    PROF_INIT(handle_key_press);
    D_EVENTS(("handle_key_press(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window));
#if UNUSED_BLOCK
    REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0);
#endif

    COUNT_EVENT(keypress_cnt);
    if (!(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_NO_INPUT))) {
        lookup_key(ev);
    }
    if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_URG_ALERT)) {
        wm_hints = XGetWMHints(Xdisplay, TermWin.parent);
        wm_hints->flags &= ~XUrgencyHint;
        XSetWMHints(Xdisplay, TermWin.parent, wm_hints);
        XFree(wm_hints);
    }
    PROF_DONE(handle_key_press);
    PROF_TIME(handle_key_press);
    return 1;
}
Example #2
0
void
scrollbar_draw_downarrow(unsigned char image_state, unsigned char force_modes)
{

    D_SCROLLBAR(("scrollbar_draw_downarrow(%u, 0x%02x)\n", (unsigned int) image_state, (unsigned int) force_modes));
    if (image_state != IMAGE_STATE_CURRENT) {
        if ((image_state == IMAGE_STATE_NORMAL) && (images[image_down].current != images[image_down].norm)) {
            images[image_down].current = images[image_down].norm;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_SELECTED) && (images[image_down].current != images[image_down].selected)) {
            images[image_down].current = images[image_down].selected;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_CLICKED) && (images[image_down].current != images[image_down].clicked)) {
            images[image_down].current = images[image_down].clicked;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_DISABLED) && (images[image_down].current != images[image_down].disabled)) {
            images[image_down].current = images[image_down].disabled;
            force_modes = MODE_MASK;
        }
    }
    if (!image_mode_is(image_down, MODE_MASK)) {
        /* Solid mode.  Redraw every time since it's cheap. */
        if (BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_FLOATING)) {
            XSetWindowBackground(Xdisplay, scrollbar.dn_win, PixColors[bgColor]);
            XClearWindow(Xdisplay, scrollbar.dn_win);
        } else {
            XSetForeground(Xdisplay, gc_scrollbar, images[image_down].current->bg);
            XFillRectangle(Xdisplay, scrollbar.dn_win, gc_scrollbar, 0, 0, scrollbar_arrow_width(), scrollbar_arrow_height());
        }
        XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_down].current->bg, ""));
        XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_down].current->bg, ""));
        if (image_state == IMAGE_STATE_CLICKED) {
            scrollbar_set_downarrow_pressed(1);
            draw_downarrow_clicked(scrollbar.dn_win, gc_top, gc_bottom, 0, 0, scrollbar_arrow_width() - 1, scrollbar_get_shadow());
        } else {
            scrollbar_set_downarrow_pressed(0);
            draw_downarrow_raised(scrollbar.dn_win, gc_top, gc_bottom, 0, 0, scrollbar_arrow_width() - 1, scrollbar_get_shadow());
        }
        return;
    }
    if (!((images[image_down].mode & MODE_MASK) & (force_modes))) {
        return;
    }
    render_simage(images[image_down].current, scrollbar.dn_win, scrollbar_arrow_width(), scrollbar_arrow_height(), image_down, 0);
}
Example #3
0
void
scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes)
{

    D_SCROLLBAR(("scrollbar_draw_anchor(%u, 0x%02x)\n", (unsigned int) image_state, (unsigned int) force_modes));
    if (image_state != IMAGE_STATE_CURRENT) {
        if ((image_state == IMAGE_STATE_NORMAL) && (images[image_sa].current != images[image_sa].norm)) {
            images[image_sa].current = images[image_sa].norm;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_SELECTED) && (images[image_sa].current != images[image_sa].selected)) {
            images[image_sa].current = images[image_sa].selected;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_CLICKED) && (images[image_sa].current != images[image_sa].clicked)) {
            images[image_sa].current = images[image_sa].clicked;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_DISABLED) && (images[image_sa].current != images[image_sa].disabled)) {
            images[image_sa].current = images[image_sa].disabled;
            force_modes = MODE_MASK;
        }
        if ((image_state == IMAGE_STATE_NORMAL) && (images[image_st].current != images[image_st].norm)) {
            images[image_st].current = images[image_st].norm;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_SELECTED) && (images[image_st].current != images[image_st].selected)) {
            images[image_st].current = images[image_st].selected;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_CLICKED) && (images[image_st].current != images[image_st].clicked)) {
            images[image_st].current = images[image_st].clicked;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_DISABLED) && (images[image_st].current != images[image_st].disabled)) {
            images[image_st].current = images[image_st].disabled;
            force_modes = MODE_MASK;
        }
    }
    if (!image_mode_is(image_sa, MODE_MASK)) {
        /* Solid mode.  Redraw every time since it's cheap. */
#ifdef XTERM_SCROLLBAR
        if (scrollbar.type == SCROLLBAR_XTERM) {
            int x = ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? 1 : 0);

            XSetForeground(Xdisplay, gc_stipple, images[image_sa].current->bg);
            XFillRectangle(Xdisplay, scrollbar.sa_win, gc_stipple, x + 1, 0, scrollbar_anchor_width() - x - 1,
                           scrollbar_anchor_height());
            XClearWindow(Xdisplay, scrollbar.sa_win);
        }
#endif /* XTERM_SCROLLBAR */
#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR)
        if (scrollbar.type == SCROLLBAR_MOTIF || scrollbar.type == SCROLLBAR_NEXT) {
            if (BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_FLOATING)) {
                XSetWindowBackground(Xdisplay, scrollbar.sa_win, PixColors[bgColor]);
                XClearWindow(Xdisplay, scrollbar.sa_win);
            } else {
                XSetForeground(Xdisplay, gc_scrollbar, images[image_sa].current->bg);
                XFillRectangle(Xdisplay, scrollbar.sa_win, gc_scrollbar, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height());
            }
            XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sa].current->bg, ""));
            XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sa].current->bg, ""));
            if (scrollbar_anchor_is_pressed()) {
                draw_shadow(scrollbar.sa_win, gc_bottom, gc_top, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(),
                            scrollbar_get_shadow());
            } else {
                draw_shadow(scrollbar.sa_win, gc_top, gc_bottom, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(),
                            scrollbar_get_shadow());
            }
        }
#endif
        return;
    }
    if (!((images[image_sa].mode & MODE_MASK) & (force_modes))) {
        return;
    }
    if (scrollbar_anchor_height() > 1) {
        unsigned char thumb;
        Pixmap pmap;

        thumb = (images[image_st].current->iml) ? 1 : 0;
        render_simage(images[image_sa].current, scrollbar.sa_win, scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa,
                      thumb);
        pmap = images[image_sa].current->pmap->pixmap;
        /* Draw the thumb if there is one. */
        if (thumb) {
            unsigned short tw = 0, th = 0;
            imlib_t *iml = images[image_st].current->iml, *siml = images[image_sa].current->iml;

            if (image_mode_is(image_st, MODE_IMAGE) && iml->im) {
#ifdef PIXMAP_SUPPORT
                imlib_context_set_image(iml->im);
                tw = imlib_image_get_width();
                th = imlib_image_get_height();
#endif
            } else if (siml->bevel) {
                tw = scrollbar_anchor_width() - (siml->bevel->edges->left + siml->bevel->edges->right);
                th = scrollbar_anchor_width() - (siml->bevel->edges->top + siml->bevel->edges->bottom);
            } else if (siml->border) {
                tw = scrollbar_anchor_width() - (siml->border->left + siml->border->right);
                th = scrollbar_anchor_width() - (siml->border->top + siml->border->bottom);
            } else if (iml->bevel) {
                tw = iml->bevel->edges->left + iml->bevel->edges->right + 4;
                th = iml->bevel->edges->top + iml->bevel->edges->bottom + 4;
            }
            UPPER_BOUND(tw, scrollbar_anchor_width());
            UPPER_BOUND(th, scrollbar_anchor_height() >> 1);
            D_SCROLLBAR(("Thumb width/height has been calculated at %hux%hu.\n", tw, th));
            if ((tw > 0) && (th > 0)) {
                paste_simage(images[image_st].current, image_st, scrollbar.sa_win, pmap, (scrollbar_anchor_width() - tw) >> 1,
                             (scrollbar_anchor_height() - th) >> 1, tw, th);
                XSetWindowBackgroundPixmap(Xdisplay, scrollbar.sa_win, pmap);
                XClearWindow(Xdisplay, scrollbar.sa_win);
                IMLIB_FREE_PIXMAP(pmap);
                images[image_sa].current->pmap->pixmap = None;
            }
        }