Example #1
0
void Frame::init()
{
    maximized = false;
    set_state(1);
    state = "WithdrawnState";
    shaped = false;

    XSelectInput(QX11Info::display(), winId(), KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
                 KeymapStateMask | ButtonMotionMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask |
                 VisibilityChangeMask | ExposureMask | StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask);

    XSetWindowAttributes at;
    at.event_mask = ColormapChangeMask|PropertyChangeMask;
    XChangeWindowAttributes(QX11Info::display(), c_win, CWEventMask, &at);

    XGrabServer(QX11Info::display());

    // get the client geometry
    get_client_geometry();
    // get the client hints
    get_wm_hints();
    // get the client normal hints
    get_wm_normal_hints();
    // get the client prot
    get_wm_protocols();
    // get the client icon to show on header
    get_icon();
    // get the client name
    get_wm_name();
    // set the frame geometry
    set_frame_geometry();
    // set the window modality
    set_window_modality();

    shaped = query_shape();
    if (shaped)
        reshape();

    XSetWindowBorderWidth(QX11Info::display(), c_win, 0);  //client
    XSetWindowBorderWidth(QX11Info::display(), winId(), 0);  //frame

    // *** THE MOST IMPORTANT FUNCTION *** // reparent client with frame
    XReparentWindow(QX11Info::display(), c_win, winId(), lateral_bdr_width, top_bdr_height);
    qDebug() << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
    qDebug() << "Reparent Client:" << c_win << "with Frame:" << winId() << "- Name:" << cl_name();
    qDebug() << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";

    XAddToSaveSet(QX11Info::display(), c_win);
    // move and resize client
    XMoveResizeWindow(QX11Info::display(), c_win, lateral_bdr_width, top_bdr_height+3, client_w, client_h);

    //if the frame is too large, maximize it
    if (frame_w >= QApplication::desktop()->width()-20 || frame_h >= QApplication::desktop()->height()-40)
    {
        maximize_it();
    }
    else // normal size
    {
        // move the frame in desktop center and resize
        move((QApplication::desktop()->width()/2)-(frame_w/2), (QApplication::desktop()->height()/2)-(frame_h/2));
        resize(frame_w, frame_h);
    }
    qDebug() << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
    qDebug() << "Frame_x:" << frame_x << "Frame_y:" << frame_y << "Frame_w:" << frame_w << "Frame_h:" << frame_h;
    qDebug() << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << "\n";

    if (frame_type != "Splash") // Splash frame have no header and no border
    {
        // create frame borders/header
        create_borders();
        // set the header pixmap
        set_inactive();
        splash = false;
    }
    else
    {
        qDebug() << "Frame:" << winId() << "Name:" << wm_name << "is Splash type";
        splash = true;
    }

    // send _NET_ACTIVE_WINDOW property
    Atom _net_active_window = XInternAtom(QX11Info::display(), "_NET_ACTIVE_WINDOW", False);
    XClientMessageEvent xev;
    xev.type = ClientMessage;
    xev.window = c_win;
    xev.message_type = _net_active_window;
    xev.format = 32;
    xev.data.l[0] = 1; // from application
    xev.data.l[1] = CurrentTime;
    xev.data.l[2] = 0;
    XSendEvent(QX11Info::display(), QApplication::desktop()->winId(), False, StructureNotifyMask, (XEvent *)&xev);

    // map client
    XMapWindow(QX11Info::display(), c_win);
    XSync(QX11Info::display(), false);
    XUngrabServer(QX11Info::display());

    // show frame
    show();
}
Example #2
0
 void close(const UUID& uuid)
 {
     set_inactive(uuid);
 }
/** MAIN */
int main( int argc, char **argv)
{
int i, frame_count;
int horz, vert;      /* width and height of the frame */
uint8_t *frame[3];  /*pointer to the 3 color planes of the input frame */
struct area_s inarea;
struct color_yuv coloryuv;
int input_fd = 0;    /* std in */
int output_fd = 1;   /* std out */
int darker = 0;  /* how much darker should the image be */
int copy_pixel = 0; /* how much pixels we should use for filling up the area */
int average_pixel = 0; /* how much pixel to use for average */
y4m_stream_info_t istream, ostream;
y4m_frame_info_t iframe;

inarea.width=0; inarea.height=0; inarea.voffset=0; inarea.hoffset=0;

coloryuv.luma    = LUMA;  /*Setting the luma to black */
coloryuv.chroma_b = CHROMA; /*Setting the chroma to center, means white */
coloryuv.chroma_r = CHROMA; /*Setting the chroma to center, means white */

(void)mjpeg_default_handler_verbosity(verbose);

  /* processing commandline */
  process_commandline(argc, argv, &inarea, &darker, &copy_pixel, &coloryuv,
                      &average_pixel);

  y4m_init_stream_info(&istream);
  y4m_init_stream_info(&ostream);
  y4m_init_frame_info(&iframe);

  /* First read the header of the y4m stream */
  i = y4m_read_stream_header(input_fd, &istream);
  
  if ( i != Y4M_OK)   /* a basic check if we really have y4m stream */
    mjpeg_error_exit1("Input stream error: %s", y4m_strerr(i));
  else 
    {
      /* Here we copy the input stream info to the output stream info header */
      y4m_copy_stream_info(&ostream, &istream);

      /* Here we write the new output header to the output fd */
      y4m_write_stream_header(output_fd, &ostream);

      horz = y4m_si_get_width(&istream);   /* get the width of the frame */
      vert = y4m_si_get_height(&istream);  /* get the height of the frame */

      if ( (inarea.width + inarea.hoffset) > horz)
      mjpeg_error_exit1("Input width and offset larger than framewidth,exit");
 
      if ( (inarea.height + inarea.voffset) > vert)
      mjpeg_error_exit1("Input height and offset larger than frameheight,exit");

      /* Here we allocate the memory for on frame */
      frame[0] = malloc( horz * vert );
      frame[1] = malloc( (horz/2) * (vert/2) );
      frame[2] = malloc( (horz/2) * (vert/2) );

      /* Here we set the initial number of of frames */
      /* We do not need it. Just for showing that is does something */
      frame_count = 0 ; 

      /* This is the main loop here can filters effects, scaling and so 
      on be done with the video frames. Just up to your mind */
      /* We read now a single frame with the header and check if it does not
      have any problems or we have alreaddy processed the last without data */
      while(y4m_read_frame(input_fd, &istream, &iframe, frame) == Y4M_OK)
        {
           frame_count++; 

           /* You can do something usefull here */
           if (darker != 0)
             set_darker(inarea, horz, vert, frame, darker);
           else if (copy_pixel != 0)
             copy_area(inarea, horz, vert, frame, copy_pixel);
           else if (average_pixel != 0)
             average_area(inarea, horz, vert, frame, average_pixel);
           else
             set_inactive(inarea, horz, vert, frame, &coloryuv);

           /* Now we put out the read frame */
           y4m_write_frame(output_fd, &ostream, &iframe, frame);
        }

      /* Cleaning up the data structures */
      y4m_fini_stream_info(&istream);
      y4m_fini_stream_info(&ostream);
      y4m_fini_frame_info(&iframe);

    }

    /* giving back the memory to the system */
    free(frame[0]);
    frame[0] = 0;
    free(frame[1]);
    frame[1] = 0;
    free(frame[2]);
    frame[2] = 0;

  exit(0); /* exiting */ 
}