Mercurial > dillo_port1.3
view src/xembed.cc @ 1958:7860a3051241
Fix for endless loop with META refresh and same URL or no URL at all
author | Jorge Arellano Cid <jcid@dillo.org> |
---|---|
date | Fri, 15 Apr 2011 14:08:53 -0300 |
parents | edcc3394e016 |
children | 3e1144e4a40f |
line wrap: on
line source
/* * File: xembed.cc * * Copyright (C) 2009 Jorge Arellano Cid <jcid@dillo.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. */ #include <string.h> #include <ctype.h> #define FL_INTERNALS #include <FL/Fl_Window.H> #include <FL/Fl.H> #include <FL/x.H> #include "xembed.hh" #ifdef X_PROTOCOL typedef enum { XEMBED_EMBEDDED_NOTIFY = 0, XEMBED_WINDOW_ACTIVATE = 1, XEMBED_WINDOW_DEACTIVATE = 2, XEMBED_REQUEST_FOCUS = 3, XEMBED_FOCUS_IN = 4, XEMBED_FOCUS_OUT = 5, XEMBED_FOCUS_NEXT = 6, XEMBED_FOCUS_PREV = 7, XEMBED_GRAB_KEY = 8, XEMBED_UNGRAB_KEY = 9, XEMBED_MODALITY_ON = 10, XEMBED_MODALITY_OFF = 11, } XEmbedMessageType; void Xembed::setXembedInfo(unsigned long flags) { unsigned long buffer[2]; Atom xembed_info_atom = XInternAtom (fl_display, "_XEMBED_INFO", false); buffer[0] = 1; buffer[1] = flags; XChangeProperty (fl_display, xid, xembed_info_atom, xembed_info_atom, 32, PropModeReplace, (unsigned char *)buffer, 2); } void Xembed::sendXembedEvent(uint32_t message) { XClientMessageEvent xclient; memset (&xclient, 0, sizeof (xclient)); xclient.window = xid; xclient.type = ClientMessage; xclient.message_type = XInternAtom (fl_display, "_XEMBED", false); xclient.format = 32; xclient.data.l[0] = fl_event_time; xclient.data.l[1] = message; XSendEvent(fl_display, xid, False, NoEventMask, (XEvent *)&xclient); XSync(fl_display, False); } int Xembed::handle(int e) { if (e == FL_PUSH) sendXembedEvent(XEMBED_REQUEST_FOCUS); return Fl_Window::handle(e); } static int event_handler(int e) { Atom xembed_atom = XInternAtom (fl_display, "_XEMBED", false); if (fl_xevent->type == ClientMessage) { if (fl_xevent->xclient.message_type == xembed_atom) { long message = fl_xevent->xclient.data.l[1]; switch (message) { case XEMBED_WINDOW_ACTIVATE: // Force a ConfigureNotify message so fltk can get the new // coordinates after a move of the embedder window. #if 0 PORT1.3 w->resize(0, 0, w->w(), w->h()); #endif break; case XEMBED_WINDOW_DEACTIVATE: break; default: break; } } } return 0; } // TODO: Implement more XEMBED support; void Xembed::create() { createInternal(xid); setXembedInfo(1); Fl::add_handler(event_handler); } void Xembed::createInternal(uint32_t parent) { Fl_Window *window = this; Colormap colormap = fl_colormap; XSetWindowAttributes attr; attr.border_pixel = 0; attr.colormap = colormap; attr.bit_gravity = 0; // StaticGravity; int mask = CWBorderPixel|CWColormap|CWEventMask|CWBitGravity; int W = window->w(); if (W <= 0) W = 1; // X don't like zero... int H = window->h(); if (H <= 0) H = 1; // X don't like zero... int X = window->x(); int Y = window->y(); attr.event_mask = ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | KeymapStateMask | FocusChangeMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask; Fl_X::set_xid(window, XCreateWindow(fl_display, parent, X, Y, W, H, 0, // borderwidth fl_visual->depth, InputOutput, fl_visual->visual, mask, &attr)); } #else // X_PROTOCOL void Xembed::setXembedInfo(unsigned long flags) {}; void Xembed::sendXembedEvent(uint32_t message) {}; int Xembed::handle(int e) { return Fl_Window::handle(e); } void Xembed::create() { #if 0 PORT1.3 Fl_Window::create(); #endif } #endif