summaryrefslogtreecommitdiffstats
path: root/templates/machine/raspberrypi2/50_bblayers.conf.inc
blob: 1250b359f90c02c2e040c2bbe7cbc12e1ae5ba75 (plain)
1
BBLAYERS =+ "${METADIR}/meta-raspberrypi"
8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (C) 2017 Mentor Graphics Development (Deutschland) GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef TMCAGLWM_APP_HPP
#define TMCAGLWM_APP_HPP

#include <json-c/json.h>

#include <atomic>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <experimental/optional>

#include "afb_binding_api.hpp"
#include "config.hpp"
#include "controller_hooks.hpp"
#include "layers.hpp"
#include "layout.hpp"
#include "policy.hpp"
#include "result.hpp"
#include "wayland.hpp"

namespace wl {
struct display;
}

namespace genivi {
struct controller;
}

namespace wm {

using std::experimental::optional;

/* DrawingArea name used by "{layout}.{area}" */
static const char *kNameLayoutNormal = "normal";
static const char *kNameLayoutSplit = "split";
static const char *kNameAreaFull = "full";
static const char *kNameAreaMain = "main";
static const char *kNameAreaSub = "sub";

/* Key for json obejct */
static const char *kKeyDrawingName = "drawing_name";
static const char *kKeyDrawingArea = "drawing_area";

struct id_allocator {
   unsigned next = 1;

   // Surfaces that where requested but not yet created
   std::unordered_map<unsigned, std::string> id2name;
   // std::unordered_set<unsigned> pending_surfaces;
   std::unordered_map<std::string, unsigned> name2id;

   id_allocator(id_allocator const &) = delete;
   id_allocator(id_allocator &&) = delete;
   id_allocator &operator=(id_allocator const &);
   id_allocator &operator=(id_allocator &&) = delete;

   // Insert and return a new ID
   unsigned generate_id(std::string const &name) {
      unsigned sid = this->next++;
      this->id2name[sid] = name;
      // this->pending_surfaces.insert({sid});
      this->name2id[name] = sid;
      logdebug("allocated new id %u with name %s", sid, name.c_str());
      return sid;
   }

   // Lookup by ID or by name
   optional<unsigned> lookup(std::string const &name) const {
      auto i = this->name2id.find(name);
      return i == this->name2id.end() ? nullopt : optional<unsigned>(i->second);
   }

   optional<std::string> lookup(unsigned id) const {
      auto i = this->id2name.find(id);
      return i == this->id2name.end() ? nullopt
                                       : optional<std::string>(i->second);
   }

   // Remove a surface id and name
   // I don't think I will need this, do I?
   void remove_id(std::string const &name) {
      auto i = this->name2id.find(name);
      if (i != this->name2id.end()) {
         this->id2name.erase(i->second);
         this->name2id.erase(i);
      }
   }

   void remove_id(unsigned id) {
      auto i = this->id2name.find(id);
      if (i != this->id2name.end()) {
         this->name2id.erase(i->second);
         this->id2name.erase(i);
      }
   }
};

struct App {
   struct binding_api api;
   struct controller_hooks chooks;

   // This is the one thing, we do not own.
   struct wl::display *display;

   std::unique_ptr<struct genivi::controller> controller;
   std::vector<std::unique_ptr<struct wl::output>> outputs;

   struct config config;

   // track current layouts separately
   layer_map layers;

   // ID allocation and proxy methods for lookup
   struct id_allocator id_alloc;

   // Set by AFB API when wayland events need to be dispatched
   std::atomic<bool> pending_events;

   std::vector<int> pending_end_draw;

   Policy policy;

   explicit App(wl::display *d);
   ~App() = default;

   App(App const &) = delete;
   App &operator=(App const &) = delete;
   App(App &&) = delete;
   App &operator=(App &&) = delete;

   int init();

   int dispatch_events();
   int dispatch_pending_events();

   void set_pending_events();

   result<int> api_request_surface(char const *drawing_name);
   char const *api_activate_surface(char const *drawing_name, char const *drawing_area);
   char const *api_deactivate_surface(char const *drawing_name);
   char const *api_enddraw(char const *drawing_name);
   void api_ping();

   // Events from the compositor we are interested in
   void surface_created(uint32_t surface_id);
   void surface_removed(uint32_t surface_id);

private:
   optional<int> lookup_id(char const *name);
   optional<std::string> lookup_name(int id);

   bool pop_pending_events();

   void enqueue_flushdraw(int surface_id);
   void check_flushdraw(int surface_id);

   int init_layers();

   void surface_set_layout(int surface_id, optional<int> sub_surface_id = nullopt);
   void layout_commit();

   // TMC WM Events to clients
   void emit_activated(char const *label);
   void emit_deactivated(char const *label);
   void emit_syncdraw(char const *label, char const *area);
   void emit_flushdraw(char const *label);
   void emit_visible(char const *label, bool is_visible);
   void emit_invisible(char const *label);
   void emit_visible(char const *label);

   void activate(int id);
   void deactivate(int id);
   void deactivate_main_surface();

   bool can_split(struct LayoutState const &state, int new_id);
   void try_layout(struct LayoutState &state,
                   struct LayoutState const &new_layout,
                   std::function<void(LayoutState const &nl)> apply);
};

}  // namespace wm

#endif  // TMCAGLWM_APP_HPP